#
#  makefile for srcp (Simple Remote CoPy) version 2
#

# common source files
S_COMMON_SOC  = srcp_util_soc.c 
S_COMMON      = srcp_util.c $(S_COMMON_SOC) 

#
# servers macros
#

# server files
S_SRCP_SRV = srcp_srv.c srcp_app_srv.c $(S_COMMON)
O_SRCP_SRV = $(S_SRCP_SRV:.c=.o)
T_SRCP_SRV = server_hw2_2860

#
# clients macros
#

# client files
S_SRCP_CLNT = srcp_clnt.c srcp_app_clnt.c $(S_COMMON)
O_SRCP_CLNT = $(S_SRCP_CLNT:.c=.o)
T_SRCP_CLNT = client_hw2_2860

# location of the base for header files and libraries
# ~/unpv12e
# CURRENT_DIR = ~/cs515/hw2/v05
BASE_DIR = ../../../unpv12e

# compiler and compile flag
CFLAGS  = 
INC_DIRS = -I$(BASE_DIR) -I$(BASE_DIR)/intro
CC      = gcc $(INC_DIRS)

# libraries
# COMM_LIBS = -lresolv -lsocket -lnsl -lpthread
COMM_LIBS = -lsocket
LIBS     = $(BASE_DIR)/libunp.a $(COMM_LIBS) 
# MY_LIB = $(CURRENT_DIR)/libmyerror.a

# executables
PROGS	= $(T_SRCP_SRV) $(T_SRCP_CLNT)
all : $(PROGS)  

# .o files are created by default rules

# executable rules
# server rules
$(T_SRCP_SRV):   $(O_SRCP_SRV)
	$(CC) $(CFLAGS) -o $@ $(O_SRCP_SRV) $(LIBS)

# client rules
$(T_SRCP_CLNT):   $(O_SRCP_CLNT)
	$(CC) $(CFLAGS) -o $@ $(O_SRCP_CLNT) $(LIBS)

# other rules
clean:          
	rm -f $(PROGS) *.o core
