#       Makefile for RPC tests on priam
#
#
TARGET = next
T = ..
RPC = ../../..
RRC = $(RPC)/rts/c
RPC_INC = $(RRC)
RPCRTS_H = $(RPC_INC)/rpcrts.h

#       Choose the RPC library to use:

RPCLIB = $(RPC)/rts/c/$(TARGET)/librpc.a

RPCC = $(RPC)/compiler/p2c/$(TARGET)/rpcc
CFLAGS = -I$(RPC_INC)

.c.o	:	; cc -c $(CFLAGS) $*.c

#-----------------------------------------------------------

all : time_cli_c time_ser_c big_ser_c big_cli_c cback_cli_c cback_ser_c
	touch all

time_ser_c : time_ser_c.o time_sub_c.o $(RPCLIB) $(RPCRTS_H)

	cc -I$(RPC_INC) -o time_ser_c time_ser_c.o time_sub_c.o $(RPCLIB)
	chmod +x time_ser_c

time_ser_c.o : time_ser_c.c $(RPCRTS_H) 
	cc -c -I$(RPC_INC) time_ser_c.c

time_ser_c.c : $(T)/time.rpc $(RPCC) $(RPCRTS_H)
	$(RPCC) -byvalue -sgenericc=time_ser_c.c $(T)/time.rpc

time_sub_c.o : $(T)/time_sub_c.c $(RPCRTS_H)
	cc -c -I$(RPC_INC) $(T)/time_sub_c.c

time_cli_c : time_cli_c.o time_prog_c.o $(RPCLIB) $(RPCRTS_H)
	cc -I$(RPC_INC) -o time_cli_c time_cli_c.o time_prog_c.o $(RPCLIB) -lm
	chmod +x time_cli_c
time_cli_c.o : time_cli_c.c $(RPCRTS_H)
	cc -c -I$(RPC_INC) time_cli_c.c
time_cli_c.c : $(T)/time.rpc $(RPCC) $(RPCRTS_H)
	$(RPCC) -byvalue -cgenericc=time_cli_c.c $(T)/time.rpc
time_prog_c.o : $(T)/time_prog_c.c $(RPCRTS_H)
	cc -c -I$(RPC_INC) $(T)/time_prog_c.c
#____________________________________________________________________


big_ser_c : big_ser_c.o big_sub_c.o $(T)/big_sloop_c.c $(RPCLIB) $(RPCRTS_H)

	cc -I$(RPC_INC) -o big_ser_c \
	      $(T)/big_sloop_c.c big_ser_c.o big_sub_c.o $(RPCLIB)
	chmod +x big_ser_c

big_ser_c.o : big_ser_c.c $(RPCRTS_H)
	cc -c -I$(RPC_INC) big_ser_c.c

big_ser_c.c : $(T)/big.rpc $(RPCC)
	$(RPCC) -sgenericc=big_ser_c.c $(T)/big.rpc

big_sub_c.o : $(T)/big_sub_c.c $(RPCRTS_H)
	cc -c -I$(RPC_INC) -I.. $(T)/big_sub_c.c

big_cli_c : big_cli_c.o big_prog_c.o $(RPCLIB)
	cc -o big_cli_c big_cli_c.o big_prog_c.o $(RPCLIB) -lm

big_cli_c.o : big_cli_c.c $(RPCRTS_H)
	cc -c -I$(RPC_INC) big_cli_c.c

big_cli_c.c : $(T)/big.rpc $(RPCC)
	$(RPCC) -cgenericc=big_cli_c.c $(T)/big.rpc

big_prog_c.o : $(T)/big_prog_c.c $(RPCRTS_H)
	cc -c -I$(RPC_INC) -I.. $(T)/big_prog_c.c

#____________________________________________________________________

cback1_ser_c.c : $(T)/cback1.rpc $(RPCC)
	$(RPCC) -byvalue -sgenericc=cback1_ser_c.c $(T)/cback1.rpc
cback1_cli_c.c : $(T)/cback1.rpc $(RPCC)
	$(RPCC) -byvalue -cgenericc=cback1_cli_c.c $(T)/cback1.rpc

cback2_ser_c.c : $(T)/cback2.rpc $(RPCC)
	$(RPCC) -byvalue -sgenericc=cback2_ser_c.c $(T)/cback2.rpc
cback2_cli_c.c : $(T)/cback2.rpc $(RPCC)
	$(RPCC) -byvalue -cgenericc=cback2_cli_c.c $(T)/cback2.rpc

cback1_ser_c.o : cback1_ser_c.c $(RPCHEADER)
cback1_cli_c.o : cback1_cli_c.c $(RPCHEADER)
cback2_ser_c.o : cback2_ser_c.c $(RPCHEADER)
cback2_cli_c.o : cback2_cli_c.c $(RPCHEADER)

cback_ser_c : cback1_ser_c.o cback2_cli_c.o cback_sub_c.o $(RPCLIB)
	cc -o cback_ser_c cback1_ser_c.o cback2_cli_c.o cback_sub_c.o $(RPCLIB)

cback_cli_c : cback2_ser_c.o cback1_cli_c.o cback_prog_c.o $(RPCLIB)
	cc -o cback_cli_c cback2_ser_c.o cback1_cli_c.o cback_prog_c.o $(RPCLIB)
	
cback_prog_c.o : $(T)/cback_prog_c.c
	cc -c -I$(RPC_INC) -I.. $(T)/cback_prog_c.c
	
cback_sub_c.o : $(T)/cback_sub_c.c
	cc -c -I$(RPC_INC) -I.. $(T)/cback_sub_c.c
	
