# A makefile for the stuff now in libg++/etc

srcdir = .

#### package, host, target, and site dependent Makefile fragments come in here.
##

check: graph $(srcdir)/test.dat $(srcdir)/test2.dat
	./graph -d -c 3 -g 2 -l "a diagonal line" -X "x axis" -Y "y axis" -m 1\
	        <$(srcdir)/test2.dat >test2.pl
	./graph -d <$(srcdir)/test.dat >test.pl
	@echo use plot to look at the plot files test.pl and test2.pl
run_tests: check

OBJECTS = pPlex.o pXPlex.o eGetOpt.o ePlotFile.o read_data.o tick_intrvl.o
DEPEND_SOURCES = $(srcdir)/*.cc

libgraph.a : $(OBJECTS)
	rm -f libgraph.a
	$(AR) $(AR_FLAGS) libgraph.a $(OBJECTS)
	$(RANLIB) libgraph.a

graph : graph.o libgraph.a
	$(CXX) graph.o libgraph.a $(LIBS) -lm -o $@

graph.o: pXPlex.h pPlex.h

pXPlex.h pXPlex.cc:
	PROTODIR=$(PROTODIR); export PROTODIR; ../../genclass/genclass point val XPlex p
pPlex.h pPlex.cc:
	PROTODIR=$(PROTODIR); export PROTODIR; ../../genclass/genclass point val Plex p

# GNU tail doesn't handle -r - use the 'tac' program instead.
REVERSE_LINES = tail -r
#REVERSE_LINES = tac

$(srcdir)/test.dat:
	-echo 0 0 1 1 2 0 | spline | $(REVERSE_LINES) > $(srcdir)/test.dat

$(srcdir)/test2.dat:
	echo 0 0 >$(srcdir)/test2.dat
	echo 1 1 "label for 1 1" >>$(srcdir)/test2.dat
	echo 2 2 >>$(srcdir)/test2.dat
	echo 3 3 "label for 3 3" >>$(srcdir)/test2.dat
	echo 4 4 >>$(srcdir)/test2.dat

DIST = Makefile graph.tex ChangeLog \
eGetOpt.cc		read_data.cc \
eGetOpt.h		read_data.h \
ePlotFile.cc		tick_intrvl.cc \
ePlotFile.h		tick_intrvl.h \
graph.cc		pdefs.h

graph.tar.Z : $(DIST) CHECKSUMS
	tar cfz $@ $^ CHECKSUMS

CHECKSUMS : $(DIST)
	sum $(DIST) >CHECKSUMS

dist : graph-dist.tar.Z

graph-dist.tar.Z : $(DIST)
	-rm -rf graph-dist
	mkdir graph-dist
	ln $(DIST) graph-dist
	tar cfz graph-dist.tar.Z $(DIST)
	rm -rf graph-dist

graph.shar : pdefs.h graph.cc Makefile graph.texinfo
	shar  pdefs.h graph.cc Makefile graph.texinfo > $@
