##############################################################################
# CONFIGURE -- set the names of where you want things installed, and where
# your copy of different binaries reside.  When you run 'make install', 
# it will rewrite tkgnuplot to use these paths.
#
# note: for any subdirectory you are going to use, the immediate parent
#       must already exist or the make will fail.
##############################################################################

# where is your version of wish?
WISH = /usr/local/bin/wish

# where is your version of tclsh?
TCLSH = /usr/local/bin/tclsh

# where is your version of sed?
SED = /bin/sed

# where is your version of Tix?
TIXLIB = /project/nero/lib/TixLib

# where do you want the tkgnuplot binary to reside?
BINDIR = /home/xerxes/contrib/bin

# where do you want the tkgnuplot libraries to reside?
LIBDIR = /home/xerxes/contrib/tkgnuplot

# where do you want the man page to reside? what section?
MANDIR = /home/xerxes/contrib/man
MANSECT = 1

##############################################################################
# That's all you should have to configure. Leave the below stuff alone.
##############################################################################
DIR = tkgnuplot
TARDIST = $(DIR).1.09.tar.gz
BITDIR = $(LIBDIR)/bitmaps

install:
	# making directories (ignore all "already exists" errors)
	-mkdir $(BINDIR)
	-mkdir $(LIBDIR)
	-mkdir $(BITDIR)
	-mkdir $(MANDIR)
	-mkdir $(MANDIR)/cat$(MANSECT)

	# copying files
	cat tkgnuplot | \
        $(SED) -e 's@^#!/usr/bin/wish -f@#!$(WISH) -f@' \
        -e 's@^set local_path "/home/neural01/gradst/claypool/proj/tkgnuplot"@set local_path "$(LIBDIR)"@' \
        -e 's@^set bitdir "/home/neural01/gradst/claypool/proj/tkgnuplot/bitmaps"@set bitdir "$(BITDIR)"@' \
	> $(BINDIR)/tkgnuplot
	cp *.tk $(LIBDIR)
	cp bitmaps/* $(BITDIR)
	cp tkgnuplot.man $(MANDIR)/cat$(MANSECT)/tkgnuplot.$(MANSECT)
	cp CHANGES $(LIBDIR)

	# setting permissions
	chmod og+rx $(BINDIR)/tkgnuplot
	chmod og+r $(LIBDIR)/*
	chmod og+r $(BITDIR)/*

	# making tcl/tk index
	echo auto_mkindex $(LIBDIR) *.tk | $(TCLSH)
	cp tclIndex $(LIBDIR)

###########################################################################
# Since I port the development version of tkgnuplot back and forth
# to school and home, make it easier to do this.
mark:
	cat tkgnuplot | \
        $(SED) -e 's@^#!/usr/local/bin/wish -f@#!/usr/bin/wish -f@' \
        -e 's@^set local_path "/home/neural01/gradst/claypool/proj/tkgnuplot"@set local_path "/home/mark/proj/tkgnuplot"@' \
        -e 's@^set bitdir "/home/neural01/gradst/claypool/proj/tkgnuplot/bitmaps"@set bitdir "/home/mark/proj/tkgnuplot/bitmaps"@' \
        -e 's@^set TIX_LIBRARY "/project/nero/lib/TixLib"@set TIX_LIBRARY "/usr/local/lib/tix"@' \
	> tkgnuplot.mark
	mv tkgnuplot.mark tkgnuplot
	chmod +x tkgnuplot

claypool:
	cat tkgnuplot | \
        $(SED) -e 's@^#!/usr/bin/wish -f@#!/usr/local/bin/wish -f@' \
        -e 's@^set local_path "/home/mark/proj/tkgnuplot"@set local_path "/home/neural01/gradst/claypool/proj/tkgnuplot"@' \
        -e 's@^set bitdir "/home/mark/proj/tkgnuplot/bitmaps"@set bitdir "/home/neural01/gradst/claypool/proj/tkgnuplot/bitmaps"@' \
        -e 's@^set TIX_LIBRARY "/usr/local/lib/tix"@set TIX_LIBRARY "/project/nero/lib/TixLib"@' \
	> tkgnuplot.claypool
	mv tkgnuplot.claypool tkgnuplot
	chmod +x tkgnuplot

###########################################################################
#
tar: $(TARDIST)

$(TARDIST): 
	cd ..; tar vzcf $(DIR)/$(TARDIST) \
	$(DIR)/README \
	$(DIR)/CHANGES \
	$(DIR)/Makefile \
	$(DIR)/add.tk \
	$(DIR)/browse.tk \
	$(DIR)/data \
	$(DIR)/dialog.tk \
	$(DIR)/global-variables.tk \
	$(DIR)/gnuplot.tk \
	$(DIR)/help.tk \
	$(DIR)/latex.tk \
	$(DIR)/main.tk \
	$(DIR)/ps.tk \
	$(DIR)/tkgnuplot \
	$(DIR)/tkgnuplot.man \
	$(DIR)/ToDo \
	$(DIR)/bitmaps/boxes.xbm \
	$(DIR)/bitmaps/dashed.xbm \
	$(DIR)/bitmaps/dots.xbm \
	$(DIR)/bitmaps/errorbars.xbm \
	$(DIR)/bitmaps/impulses.xbm \
	$(DIR)/bitmaps/lines.xbm \
	$(DIR)/bitmaps/linespoints.xbm \
	$(DIR)/bitmaps/points.xbm \
	$(DIR)/bitmaps/solid.xbm \
	$(DIR)/bitmaps/steps.xbm

clean: 
	/bin/rm -f core *~ $(TARDIST)


