#
# ***************************************************************
#     Remember to source opt-build-env first, if you are building 
#  any sub-set of these files outside of toplevel build procedure 
# ***************************************************************

#   4 Mar 05.  makefile.info from makefile.aaserv.  WJS
#	serv now has its own makefile, and dir doesn't need one.
#	Accordingly, remove dir and serv from TODO.
#		Add directory creation to info - should have been
#	there (and in dir's section) in case serv was NOT built
#	by this make file.
#
# htmlbindir changes for optionserver to optbin
#
HTMLBINDIR  = ../../optbin
LIBDIR = ../lib
SRCDIR = ./

# TODO = ${HTMLBINDIR}/serv       \
#     ${HTMLBINDIR}/dir        \
#      ${HTMLBINDIR}/info
TODO = ${HTMLBINDIR}/info

all: ${TODO}

${HTMLBINDIR}/serv: ${SRCDIR}serv.o ${LIBDIR}/jgofs.a
	@-test -d ${HTMLBINDIR} || mkdir ${HTMLBINDIR}
	$(CC) ${CFLAGS} ${SRCDIR}serv.o ${LIBDIR}/jgofs.a  -o $@
${SRCDIR}serv.o:${SRCDIR}serv.c
	$(CC) ${CFLAGS} -DOPTIONSERVER='"${OPTIONSERVER}"' \
	-DJGOFSDIR='"${JGOFSDIR}"' -c ${SRCDIR}serv.c

# Purpose:
#   builds dir, from PERL version
#
# NOTE:  env $PERL contains location of perl interpreter on this machine.
#
##############
# Values used to replace variables in template (*.tmp) file are:
#
#  (PERL version only) PERL:  which, if any, perl to use
#                      Example:       /usr/local/bin/perl
#
#  (if any) DMONAME:  name of program for which this is DMO
#                      Example:     US BIO-PROJ
#
#  MYADDR:     this machine's alias on the WWW
#                      Example:     www.jgofs.org:80
#
#  JGOFSDIR:   top of the jgofs software tree; parent of OBJECTROOT
#                      Example:     /users/jgofs
#
#  OBJDIR:  below OBJECTROOT, where to begin looking for object defn's
#                      Example:      /jgofs
#
#  BUTTONIMAGESDIR:  directory where image files are located, relative to 
#                 MYADDR's DocumentRoot.  Intention is to find the GIF 
#                 used to indicate the current directory, 'youhere.gif'.
#
#  INFOSERVER:  by default, machine and program used to serve
#               documentation files
#                      Example:     www.jgofs.org:80/jg/info
#
#  The length of the string formed by appending "objects" to value of JGOFSDIR
#                      Example:     /users/jgofs/objects == 20
##############
#
# Where to place the custom 'dir'
#
LEN=`(echo "${JGOFSDIR}/objects" | ${NAWK} '{print length}')`

${HTMLBINDIR}/dir: ${SRCDIR}dir_pl.tmp
	@test -d $(PERL) || set PERL="/usr/local/bin/perl"
	@-test -d ${HTMLBINDIR} || mkdir ${HTMLBINDIR}
	sed "s*perllocation*${PERL}*g;\
	     s*myaddr*${MYADDR}*g;\
	     s*dmoname*${DMONAME}*g;\
	     s*jgofsdir*${JGOFSDIR}*g;\
	     s*objectdir*${OBJDIR}*g;\
	     s*imagedirectory*${BUTTONIMAGESDIR}*g;\
	     s*informationserver*${INFOSERVER}*g" <${SRCDIR}dir_pl.tmp > $@
	chmod +x $@;

# Purpose:
#   builds info
#
# NOTE:  env $PERL contains location of perl interpreter on this machine.
#
##############
# Values used to replace variables in template (*.tmp) file are:
#
#  (PERL version only) PERL:  which, if any, perl to use
#                      Example:       /usr/local/bin/perl
#
#  (if any) DMONAME:  name of program for which this is DMO
#                      Example:     US BIO-PROJ
#
#  INFOSERVER:  by default, machine and program used to serve
#               documentation files
#                      Example:   www.jgofs.org:80/jg/info
#
#  BUTTONIMAGESDIR:  directory where image files are located, relative to 
#                 MYADDR's DocumentRoot.  Intention is to find the GIF 
#                 files used for the 'Directory' and 'Data display' buttons.
#
##############
#

${HTMLBINDIR}/info: ${SRCDIR}info_pl.tmp
	@test -d $(PERL) || set PERL="/usr/local/bin/perl"
	@-test -d ${HTMLBINDIR} || mkdir ${HTMLBINDIR}
	sed "s*perllocation*${PERL}*g;\
		s*dmoname*${DMONAME}*g;\
		s*imagedirectory*${BUTTONIMAGESDIR}*g;\
		s*informationserver*${INFOSERVER}*g" < ${SRCDIR}info_pl.tmp > $@
	chmod +x $@;

############
clean:
	-rm ${SRCDIR}serv.o \
	${TODO}
