# examples/Makefile.examples.in for PLplot
# configured by our CMake-based build system to examples/Makefile.examples
# in the build tree and installed as examples/Makefile in the install tree.

# Copyright (C) 2004, 2008  Alan W. Irwin
# 
# This file is part of PLplot.
#
# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with the file PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

# This Makefile should not be used in the build tree.  It is meant for use
# only in the install tree.  It is first configured, then installed 
# (with the name Makefile) in the _installed_ examples directory as a 
# convenience to the user for building all the examples without having 
# to invoke make in the individual sub-directories of examples.

SUBDIRS = c c++ f77 f95 tk java ada ocaml
all: c/x01c

# Need real file here as target so that tests don't depend on all (which means
# they would always be out of date).

c/x01c:
	target=`echo $@`; \
	list='$(SUBDIRS)'; for subdir in $$list; do \
	  if test -d "$$subdir"; then \
	    echo "Making $$target in $$subdir"; \
	    (cd $$subdir && $(MAKE)); \
	  fi; \
	done

test: x01c.psc     \
	x01c01.gif x01c01.jpeg x01c01.png  x01c01.svg x01c01.xfig x01c.pstex compare

x01c.psc:  c/x01c
	echo psc all front-ends
	./plplot-test.sh --verbose --device=psc

#: c/x01c
#	echo pdfcairo
#	./plplot-test.sh --verbose --front-end=c --device=pdfcairo

#: c/x01c
#	echo pngcairo
#	./plplot-test.sh --verbose --front-end=c --device=pngcairo

#: c/x01c
#	echo pscairo
#	./plplot-test.sh --verbose --front-end=c --device=pscairo

#: c/x01c
#	echo svgcairo
#	./plplot-test.sh --verbose --front-end=c --device=svgcairo

x01c01.gif: c/x01c
	echo gif
	./plplot-test.sh --verbose --front-end=c --device=gif

x01c01.jpeg: c/x01c
	echo jpeg
	./plplot-test.sh --verbose --front-end=c --device=jpeg

x01c01.png: c/x01c
	echo png
	./plplot-test.sh --verbose --front-end=c --device=png

#: c/x01c
#	echo psttfc
#	./plplot-test.sh --verbose --front-end=c --device=psttfc

x01c01.svg: c/x01c
	echo svg
	./plplot-test.sh --verbose --front-end=c --device=svg

x01c01.xfig: c/x01c
	echo xfig
	./plplot-test.sh --verbose --front-end=c --device=xfig

x01c.pstex: c/x01c
	echo pstex
	./plplot-test.sh --verbose --front-end=c --device=pstex

compare: x01c.psc
	echo compare
	./test_diff.sh

test_interactive: c/x01c
	./plplot-test-interactive.sh

clean: test_clean
	target=`echo $@`; \
	list='$(SUBDIRS)'; for subdir in $$list; do \
	  if test -d "$$subdir"; then \
	    echo "Making $$target in $$subdir"; \
	    (cd $$subdir && $(MAKE) $$target); \
	  fi; \
	done

test_clean:
	rm -f *.psc *.pdfcairo *.pngcairo *.pscairo *.svgcairo \
	*.gif *.jpeg *.png *.psttfc *.svg *.xfig *.pstex* *.txt test.error

.PHONY : all clean test test_clean test_interactive compare
