# ***************************************************************
#     Remember to source opt-build-env first, if you are building 
#  any sub-set of these files outside of toplevel opt-build procedure 
# ***************************************************************
# makefile for JGOFS commands,etc. used from bin/
# updated for v1.5 JGOFS software clh, November 3, 1998
# added default.h to list make; corrected its dependencies, clh, Sep 8, 1999
# added make for strpbrk.tmp, clh, Nov 8, 1999
# mod Dec.8,1999 clh
#       re-write fixurl in perl because the C version of fixurl
#	was core-dumping; faster than debugging the C code.
#
#
TOPLEVEL =  ../../
# place executables in jgofsdir/bin
BINDIR = ${TOPLEVEL}bin/
LIBDIR = ../lib/
INCDIR = ../include/
SRCDIR = ./
#
#
DATASYS-EXECS = ${BINDIR}list    \
                ${BINDIR}listvar

MANIPULATORS =  ${BINDIR}fixurl	\
		${BINDIR}geturl  \
		${BINDIR}htmlesc \
		${BINDIR}htmlunesc \
		${BINDIR}nawkscr \
		${BINDIR}poststring \
		${BINDIR}strpbrk \
		${BINDIR}trigram_util

all:   ${DATASYS-EXECS} ${MANIPULATORS}
#
# data system executables - these targets can be run from command line
#
${BINDIR}list:${SRCDIR}list.c ${INCDIR}default.h ${LIBDIR}jgofs.a
	@- (test -d ${BINDIR} || mkdir ${BINDIR})
	$(CC) -DOPTIONS='"${INCDIR}default.h"' \
	${SRCDIR}list.c ${LIBDIR}jgofs.a -o $@

${BINDIR}listvar:${INCDIR}default.h ${INCDIR}inner.h \
		${LIBDIR}jgofs.a ${SRCDIR}listvar.c
	$(CC) -DOPTIONS='"${INCDIR}default.h"' \
	      -DINNEROPTIONS='"${INCDIR}inner.h"' \
	       ${SRCDIR}listvar.c ${LIBDIR}jgofs.a -o $@
#
# manipulating executables - inserting or patching up i/o
#
${BINDIR}fixurl: ${SRCDIR}fixurl.tmp
	sed "s*perllocation*${PERL}*g" < ${SRCDIR}fixurl.tmp >$@
	-chmod +x $@

${BINDIR}htmlesc:${SRCDIR}htmlesc.o ${SRCDIR}htmlescape.c
	$(CC) htmlesc.o -o $@
${SRCDIR}htmlesc.o: ${SRCDIR}htmlesc.c

${BINDIR}htmlunesc:${SRCDIR}htmlunesc.o ${SRCDIR}htmlunescape.c
	$(CC) ${SRCDIR}htmlunesc.o -o $@
${SRCDIR}htmlunesc.o: ${SRCDIR}htmlunesc.c

${BINDIR}geturl:${SRCDIR}geturl.tmp
	sed "s*perllocation*${PERL}*g" < ${SRCDIR}geturl.tmp >$@
	-chmod +x $@

${BINDIR}nawkscr:${SRCDIR}nawkscr
	-cp ${SRCDIR}nawkscr ${BINDIR}nawkscr
	-chmod +x $@

${BINDIR}poststring:${SRCDIR}poststring.o
	$(CC) ${SRCDIR}poststring.o -o $@
${SRCDIR}poststring.o: ${SRCDIR}poststring.c

${BINDIR}trigram_util: ${SRCDIR}trigram_util.o ${LIBDIR}jgofs.a 
		$(CC) ${CFLAGS} \
		trigram_util.o \
		${LIBDIR}jgofs.a -o $@

${BINDIR}strpbrk: ${SRCDIR}strpbrk.tmp
	sed "s*perllocation*${PERL}*g" < ${SRCDIR}strpbrk.tmp >$@
	-chmod +x $@
#
clean:
	-rm ${SRCDIR}poststring.o  \
	${SRCDIR}trigram_util.o \
 	${SRCDIR}htmlesc.o ${SRCDIR}htmlunesc.o \
	${DATASYS-EXECS} \
	${MANIPULATORS}
