# makefile.serv	 26 Aug 04.  WJS
#	(from makefile.list)

#  BINDIR is where executables should end up
#  LIBDIR is where jgofs library lives
#  MASTERINCDIR is where "system" .h files live
#  SRCDIR is where the main program sources are (and where their object
#       files will end up)
HTMLOPT = html${OPT}
BINDIR = ../../${HTMLOPT:htmlopt=opt}bin
LIBDIR = ../lib
MASTERINCDIR = ../include
SRCDIR = .

OPTIONS = ${MASTERINCDIR}/default.h
INNEROPTIONS = ${MASTERINCDIR}/inner.h

#	Program-specific compilation flags
CFLAGS = -g

#	.h files on which serv depends
#	This list is used for dependency only - I_LIST and the source
#	code control which files are actually used in the compilation.
#	Be nice if we could tie the 2 together, wouldn't it?!
include ${MASTERINCDIR}/h_file_dependency_macros.include

#	List of directories from .h files in INCLUDED_FILES, separated by -Is 
#	Order of specification is significant.
#	No problem if no .h files in a directory and/or if a directory
#	  does not exist.
#	(-I ${SRCDIR} is default; included here to show syntax)
#	(Could get rid of -Is if I knew how to parse in make.  Sigh)
I_LIST = -I${MASTERINCDIR} -I${SRCDIR}

#	Compile-time constants
SWITCHES = -DOPTIONS='"${OPTIONS}"' \
	   -DINNEROPTIONS='"${INNEROPTIONS}"'	\
	   -DOPTIONSERVER='"${OPTIONSERVER}"'	\
	   -DJGOFSDIR='"${JGOFSDIR}"'

#       libraries required.  SYSLIB list needs leading hyphens
LIB_LIST = ${LIBDIR}/jgofs.a
#SYSLIB_LIST =


all: ${BINDIR}/serv ${CONFIG_FILE}


${BINDIR}/serv: ${SRCDIR}/serv.o ${LIB_LIST} ${CONFIG_FILE}
	@- test -d ${BINDIR} || mkdir ${BINDIR}
	$(CC) ${CFLAGS} \
		${SRCDIR}/serv.o \
		${LIB_LIST} \
		-o $@

${SRCDIR}/serv.o: ${SRCDIR}/serv.c \
		  ${INCLUDED_FILES} ${UTILS_H_DEPENDS} ${PATH_INFO_H_DEPENDS} \
		  ${CONFIG_FILE}
	$(CC) ${CFLAGS} \
		${SWITCHES} \
		${I_LIST} \
		-c ${SRCDIR}/serv.c \
		-o $@
