# FILE NAME: Makefile 
# Makefile for the customized handle and pipes application
#
# definitions for this make file
#
APPL=transfer_data
IDLCMD=idl -v  
CHECK=../arithmetic      # Directory containing check_status.h
LIBS = -ldce -lpthreads -lc_r -lmach -lm		# DEC Alpha OSF/1
CFLAGS= -D_SHARED_LIBRARIES -Dalpha -D_REENTRANT	# DEC Alpha OSF/1
CC= cc 


#
# COMPLETE BUILD of the application
#
all:	utility local interface client server


#
# BUILD OF UTILITY to create and read files of float data  
#
utility:	float_util
float_util:	float_util.c
	$(CC) $(CFLAGS) -o float_util.exe float_util.c 


#
# LOCAL BUILD of the clients to test locally.
#
local:	interface  local_client_send  local_client_receive

local_client_send:	client_send.c client_alloc.c in_pull.c \
			   send_floats.c
	   $(CC) $(CFLAGS) -DLOCAL -I. -o local_client_send.exe \
		   client_send.c client_alloc.c in_pull.c send_floats.c 
# remove object files so they do not interfere with a real build
	   rm  client_send.o  send_floats.o  client_alloc.o  in_pull.o     

local_client_receive:	client_receive.c client_alloc.c out_push.c \
			   receive_floats.c
	   $(CC) $(CFLAGS) -DLOCAL -I. -o local_client_receive.exe client_receive.c \
		   client_alloc.c out_push.c receive_floats.c
# remove object files so they do not interfere with a real build
	   rm  client_receive.o receive_floats.o client_alloc.o out_push.o


#
# INTERFACE BUILD 
#
interface:	$(APPL).h $(APPL)_cstub.o $(APPL)_sstub.o $(APPL)_saux.o
$(APPL).h $(APPL)_cstub.o $(APPL)_sstub.o $(APPL)_saux.o:	$(APPL).idl
	   $(IDLCMD) $(APPL).idl


#
# CLIENT BUILDS  
#
client:	client_send  client_receive 
client_send:	client_send.o client_alloc.o in_pull.o \
		   binding.o do_string_binding.o $(APPL)_cstub.o 
	   $(CC) $(CFLAGS) -I$(CHECK) -o client_send.exe \
		   client_send.o client_alloc.o in_pull.o \
		   binding.o do_string_binding.o $(APPL)_cstub.o $(LIBS)

client_receive:	client_receive.o client_alloc.o out_push.o \
		   binding.o do_string_binding.o $(APPL)_cstub.o 
	   $(CC) $(CFLAGS) -I$(CHECK) -o client_receive.exe \
		   client_receive.o client_alloc.o out_push.o \
		   binding.o do_string_binding.o $(APPL)_cstub.o $(LIBS)

#
# module needed by both clients 
#
binding.o:	binding.c
	   $(CC) $(CFLAGS) -I$(CHECK) -c binding.c
	   
# module needed from remote_file application 
do_string_binding.o:	../remote_file/do_string_binding.c
	   $(CC) $(CFLAGS) -I$(CHECK) -c ../remote_file/do_string_binding.c


#
# SERVER BUILD.  Notice the server stub auxiliary file is required. 
#
server:	t_server
t_server:	$(APPL).h t_server.o send_floats.o receive_floats.o \
   $(APPL)_sstub.o $(APPL)_saux.o 
	   $(CC) $(CFLAGS) -I$(CHECK) -o t_server.exe t_server.o \
		   send_floats.o receive_floats.o \
		   $(APPL)_sstub.o $(APPL)_saux.o $(LIBS)

t_server.o:	t_server.c
	   $(CC) $(CFLAGS) -I$(CHECK) -c t_server.c
