# file: Makefile	G. Moody		4 April 2001
#			Last revised:	      7 November 2002	plt 2.1
# Top-level `make' description file for `plt'.  See `INSTALL'.

# Version and release numbers.
PLTVER=2.1
PLTREL=1

# `make all' (or just `make') compiles the targets but does not install them.
# You must have write permission in the `src' directory, but nothing more is
# needed.
all:
	cd src; make all
	cd misc; make all

# `make install' compiles the targets if necessary, then installs the `plt'
# script and the targets in BINDIR.  It edits `lwcat' to set the correct path
# name for `pslw.pro', and installs `lwcat' and `gvcat' in BINDIR and
# `pslw.pro' in PSPDIR.  You must have write permission in BINDIR and PSPDIR.
install:	force-install
	cd src; make install
	cd misc; make install

# This is a kludge, so that `make install' will work under MS-Windows even
# though MS-Windows can't tell the difference between `INSTALL' and 'install'.
force-install:
	touch force-install

# `make mswplt':  install on MS-Windows (lwplt only, no xplt)
# You *must* use the free Cygwin C compiler and tools -- MSVC and other
# commercial compilers *will not work*.  See the README for details.
mswplt:
	cd src; make mswplt

# PostScript driver for plt
lwplt:
	cd src; make lwplt

# Utility for calculating PostScript bounding boxes
makeplthead:
	cd src; make makeplthead

# X11 driver for plt
xplt:
	cd src; make xplt

# Utility that creates an X11 window in which xplt draws
xpltwin:
	cd src; make xpltwin

# Print a listing of plt sources.
listing:
	cd src; make listing

# Print a copy of the plt Tutorial and Cookbook (requires that lpr
# be able to print a PostScript document;  see doc/Makefile).
hardcopy:
	cd doc; make hardcopy

# Show figures from the plt Tutorial and Cookbook in an X window.
xdemo:	all
	cd doc; make xdemo

# Show figures from the plt Tutorial and Cookbook in a GhostScript window.
psdemo:	all
	cd doc; make psdemo

# Create a distribution file in the parent directory using GNU tar.
tarball:
	touch timestamp
	make clean
	cd ..; tar cfvz plt-$(PLTVER).tar.gz plt-$(PLTVER)

# Create source and binary RPMs
RPMROOT=/usr/src/redhat

rpms:		tarball	
	cp -p ../plt-$(PLTVER).tar.gz $(RPMROOT)/SOURCES
	sed s/PLTVER/$(PLTVER)/ <plt.spec | \
	 sed s/PLTREL/$(PLTREL)/ >$(RPMROOT)/SPECS/plt-$(PLTVER)-$(PLTREL).spec
	if [ -x /usr/bin/rpmbuild ]; \
	 then rpmbuild -ba $(RPMROOT)/SPECS/plt-$(PLTVER)-$(PLTREL).spec; \
	 else rpm -ba $(RPMROOT)/SPECS/plt-$(PLTVER)-$(PLTREL).spec; \
	fi
	mv $(RPMROOT)/RPMS/*/plt*rpm ..
	mv $(RPMROOT)/SRPMS/plt*rpm ..
	rm -f $(RPMROOT)/SPECS/plt-$(PLTVER)-$(PLTREL).spec

# Remove binary and backup files.
clean:
	cd src; make clean
	cd doc; make clean
	cd misc; make clean
	rm -f *~ core force-install timestamp

