# ***************************************************************
#     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 penplot cmds used from bin/
#
#   5 Mar 05.  WJS
#	jgofs.a users also need err_stub.c since jgofs.a mods...
# updated for v1.5 JGOFS software clh, November 3, 1998
#
TOPLEVEL =  ../../
# place executables in jgofsdir/bin
BINDIR = ${TOPLEVEL}bin/
LIBDIR = ../lib/
SRCDIR = ./

TODO = ${BINDIR}axis0  \
       ${BINDIR}laxis  \
       ${BINDIR}text   \
       ${BINDIR}ch     \
       ${BINDIR}view   \
       ${BINDIR}window \
       ${BINDIR}axis   \
       ${BINDIR}ers    \
       ${BINDIR}pl     \
       ${BINDIR}dash   \
       ${BINDIR}ez     \
       ${BINDIR}p      \
       ${BINDIR}pns    \
       ${BINDIR}p2     \
       ${BINDIR}tekgif

all:   ${TODO}

${BINDIR}axis0:${SRCDIR}axis0.f ${LIBDIR}penplot.a ${LIBDIR}jgofsf.a ${LIBDIR}penplot.com
	@- test -d ${BINDIR} || mkdir ${BINDIR}
	$(FC) ${SRCDIR}axis0.f ${LIBDIR}penplot.a ${LIBDIR}jgofsf.a -o $@
		
${BINDIR}ers:${SRCDIR}ers.f ${LIBDIR}penplot.a
	$(FC) ${SRCDIR}ers.f ${LIBDIR}penplot.a ${LIBDIR}jgofsf.a -o $@
	
${BINDIR}laxis:${SRCDIR}laxis.f ${LIBDIR}penplot.a ${LIBDIR}jgofsf.a ${LIBDIR}penplot.com
	$(FC) ${SRCDIR}laxis.f ${LIBDIR}penplot.a ${LIBDIR}jgofsf.a -o $@

${BINDIR}text:${SRCDIR}text.f ${LIBDIR}penplot.a ${LIBDIR}jgofsf.a ${LIBDIR}penplot.com
	$(FC) ${SRCDIR}text.f ${LIBDIR}penplot.a ${LIBDIR}jgofsf.a -o $@

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

#
# special case - use simple cc command below
#  the -cckr switch to the compiler causes bizarre change to the
#  executable image, resulting in a long narrow GIF rather than
#  a rectangular xy plot.  clh november 24, 1998
#
${BINDIR}tekgif:${SRCDIR}tekbit2.o ${SRCDIR}tekgif.o
	cc ${SRCDIR}tekbit2.o ${SRCDIR}tekgif.o -o $@
${SRCDIR}tekbit2.o:${SRCDIR}tekbit2.c
	cc -c ${SRCDIR}tekbit2.c -o $@
${SRCDIR}tekgif.o:${SRCDIR}tekgif.c
	cc -c ${SRCDIR}tekgif.c -o $@

PLOT_SRC = ${SRCDIR}pl.f
DASH_SRC = ${SRCDIR}dash.f
EZ_SRC   = ${SRCDIR}ez.f

ERR_STUB = ${LIBDIR}err_stub.c

PLOT_OBJS = $(PLOT_SRC:.f=.o) $(ERR_STUB:.c=.o) \
		${LIBDIR}penplot.a ${LIBDIR}jgofs.a ${LIBDIR}jgofsf.a
DASH_OBJS = $(DASH_SRC:.f=.o) $(ERR_STUB:.c=.o) \
		${LIBDIR}penplot.a ${LIBDIR}jgofs.a ${LIBDIR}jgofsf.a
EZ_OBJS   = $(EZ_SRC:.f=.o)  $(ERR_STUB:.c=.o) \
		${LIBDIR}jgofs.a ${LIBDIR}jgofsf.a

${BINDIR}pl: $(PLOT_OBJS)
	$(FC) $(PLOT_OBJS) -o $@
${BINDIR}dash: $(DASH_OBJS)
	$(FC) $(DASH_OBJS) -o $@
${BINDIR}ez:   $(EZ_OBJS)
	$(FC) $(EZ_OBJS) -o $@

${BINDIR}p:p.tmp
	sed "s*jgofstempdir*${TEMPDIR}*" ${SRCDIR}p.tmp > $@
	chmod +x ${BINDIR}p
${BINDIR}pns:pns.tmp
	sed "s*jgofstempdir*${TEMPDIR}*" ${SRCDIR}pns.tmp > $@
	chmod +x ${BINDIR}pns
${BINDIR}p2:p2.tmp
	sed "s*jgofstempdir*${TEMPDIR}*" ${SRCDIR}p2.tmp >$@
	chmod +x ${BINDIR}p2
	
${BINDIR}axis:${SRCDIR}axis
	cp ${SRCDIR}axis ${BINDIR}axis
	chmod +x ${BINDIR}axis	
${BINDIR}view:${SRCDIR}view
	cp ${SRCDIR}view ${BINDIR}view
	chmod +x ${BINDIR}view
${BINDIR}window:${SRCDIR}window
	cp ${SRCDIR}window ${BINDIR}window
	chmod +x ${BINDIR}window

clean:
	-rm ${SRCDIR}tekbit2.o ${SRCDIR}tekgif.o   \
	${SRCDIR}pl.o ${SRCDIR}dash.o ${SRCDIR}ez.o \
	${TODO}
