CC=cc
APP=MyRPCService
IDLFILE=MyRPCService.x
FILE_PREFIX=MyRPCService
ONCRPC_HOME=..\..\..\oncrpc.sdk



#This is template makefile for building Netbula ONC RPC
#client and server with MS Visual C++.

#To use it, follow the comments and make simple subsitutions
#set IDLFILE to the .x file
#set ONCRPC_HOME to the folder which contains oncrpc.sdk

!include <ntwin32.mak>

#In the next, you specify the programmer supplied object file names.
#You specify the object file names, as the make rules knows
#how to build the object files from C/C++ sources.

#server specific user objects, such as server implementation

USER_SERV_OBJS=$(APP)_imp.obj

#client specific user objects
USER_CLNT_OBJS=cxx_client_main.obj

#objects shared by client and server
COMMON_OBJS=

#The folder to contain the built executables
EXEDIR=$(APP)ExeBuild
SERVER_PROG=$(EXEDIR)\$(APP)Server.exe
CLIENT_PROG=$(EXEDIR)\$(APP)Client.exe

#Additional link flags
CLNT_LD_FLAGS=
SERV_LD_FLAGS=
SYS_LDFLAGS=

##The rest should not be modified

#this should be the path of the rpcgen executable
ONCRPC= $(ONCRPC_HOME)\bin\rpcgen
PWLIBDIR=$(ONCRPC_HOME)\win32lib

!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF

PWLDFLAG=$(PWLIBDIR)\pwrpc32.lib

all: $(EXEDIR) server client

$(EXEDIR):
	if not exist "$(EXEDIR)\$(NULL)" mkdir "$(EXEDIR)"

server: $(SERVER_PROG)
client: $(CLIENT_PROG)
clean: 
	del  $(FILE_PREFIX)_svc.c
	del $(FILE_PREFIX)_clnt.c 
	del $(FILE_PREFIX)_xdr.c
	del $(FILE_PREFIX).h
	del *.obj

$(FILE_PREFIX)_svc.c $(FILE_PREFIX)_cln.c $(FILE_PREFIX)_xdr.c: $(IDLFILE)
	$(ONCRPC) $(IDLFILE) 


$(SERVER_PROG): \
		 $(FILE_PREFIX)_xdr.obj \
		 $(FILE_PREFIX)_svc.obj \
		 $(USER_SERV_OBJS)\
		$(COMMON_OBJS)
	$(link) $(conlflags) /out:$@  \
	$(FILE_PREFIX)_xdr.obj \
	$(FILE_PREFIX)_svc.obj \
	$(USER_SERV_OBJS)\
	$(COMMON_OBJS)  \
	$(SERV_LD_FLAGS) $(SYS_LDFLAGS) $(PWLDFLAG) $(conlibsdll)

$(CLIENT_PROG): \
		 $(FILE_PREFIX)_xdr.obj \
		 $(FILE_PREFIX)_clnt.obj \
		 $(USER_CLNT_OBJS)\
		 $(COMMON_OBJS) 
	$(link) $(conlflags) /out:$@\
		 $(FILE_PREFIX)_xdr.obj \
		 $(FILE_PREFIX)_clnt.obj \
		 $(USER_CLNT_OBJS)\
		 $(COMMON_OBJS) \
	$(CLNT_LD_FLAGS) $(SYS_LDFLAGS) $(PWLDFLAG) $(conlibsdll)


PWINCDIR=$(ONCRPC_HOME)\include\ 
PW_CC_FLAG= /I$(PWINCDIR)
CVV=  $(PW_CC_FLAG) -DWIN32 $(cdebug) -c -W3 $(cvarsdll) 

.c.obj:
    $(cc) $(CVV)  $*.c  

.cpp.obj:
    $(cc) $(CVV)  $*.cpp

.cxx.obj:
    $(cc) $(CVV)  $*.cxx

