LIBS=-lplplotdtk -lMatrix -ltk8.0 -ltcl8.0 -L/usr/X11R6/lib -lX11  -lm -lc

all: plplot_octave.oct plplot_stub.m demos

plplot_octave.oct: plplot_octave.cc
	mkoctfile -v plplot_octave.cc $(LIBS)
	cp plplot_octave.oct PLplot

plplot_octave.cc tmp_stub: plplot.h
	matwrap -language octave plplot.h -o plplot_octave.cc -stub tmp_stub

plplot_stub.m: etc/plplot.doc etc/po.dvi tmp_stub massage
	head -5 tmp_stub > plplot_stub.m
	echo "# It was also massaged to add online documentation" >> plplot_stub.m
	echo "# extracted from some PLplot distribution files" >> plplot_stub.m
	echo	>> plplot_stub.m
	echo "1;" >> plplot_stub.m
	echo >> plplot_stub.m
	./massage >> plplot_stub.m
	cp plplot_stub.m PLplot

doc: etc/po.dvi

etc/po.dvi:
	make -C etc

demos: demos/.stamp

demos/.stamp:
	make -C demos

distclean:
	-rm *.o plplot_octave.oct plplot_octave.cc plplot_stub.m massage \
	octave-core tmp_stub core PLplot/plplot_octave.oct PLplot/plplot_stub.m
	make -C etc distclean
	make -C demos clean

clean:
	-rm *.o plplot_octave.oct massage \
	octave-core core
	make -C etc clean
	make -C demos clean

install:
	@echo "cp -r PLplot <where you want it/PLplot>"
