##########################################################################
# This Makefile understands the sequence of events that build and print
# documents using LaTeX.  The following targets are defined:
#
#	default		- builds a ``.dvi'' file
#	show-dvi	- displays the dvi file on screen
#	show-ps		- displays the postscript file on screen
#	print-2upd	- prints the postscript file 2 up double sided
#	print-2up	- prints the postscript file 2 up
#	print-1upd	- prints the postscript file 1 up double sided
#	print-1up	- prints the postscript file 1 up
#	bib		- runs bibtex
#	force		- removes the default ``.dvi'' file and runs make;
#			  useful when LaTeX reports another run is needed
#	major		- increments the major number in the version
#	minor		- increments the minor number in the version
#	sminor		- increments the subminor number in the version;
#			  happens automatically every time a file changes
#	clean		- removes the targets and log files
#	real-clean	- does a clean and removes all the intermediate
#			  LaTeX files, eg the table of contents
#
# Unfortunately, it is not possible for Make to know in the general case
# when the bibliography is out of date.  This Makefile will assume the
# bibliograph is out of date if the file of entries ever changes, but that
# does not mean you have used them in your document.  Also, you may add a
# citation to your document and there is no way to detect this.  For these
# reasons the creation of the bibliography is not done automatically.  If
# it needs to be done you must type ``make bib''.
##########################################################################

##########################################################################
# Instructions to Make, for generation of nice-looking papers using LaTeX.
# For slides, change latex to slitex.
##########################################################################

.SUFFIXES:	.pic .tex .dvi .tty .ps

.pic.tex:;	tpic $<

.tex.dvi:;	latex $<

.dvi.tty:;	dvi2tty $< > $@

.dvi.ps:;	dvips $< -o $@

############################################################################
# Substitute for all the "XXX" sequences as appropriate.  Create as many
# PART and INC macros as necessary; add them to the PARTS and INCS lines
# respectively and add a dependency at the end of the Makefile as indicated.
#
# *NOTE* - This Makefile assumes you use all features.  If, for example,
# you do not use any bibliographies, then there are a few things that should
# be commented out.  It is left as an exercise in understanding Makefiles
# for the user to match features with their dependencies that need to be
# commented out in any given application of this template.
############################################################################

## Commands to print postscript file

PRINTER=	lp7

PTXT-2UPd=	enscript -l -2r -p- $? | psduplex -P$(PRINTER)
PTXT-2UP=	enscript -l -2r -P$(PRINTER) $?
PTXT-1UPd=	enscript -l -p- $? | psduplex -P$(PRINTER)
PTXT-1UP=	lpr -P$(PRINTER) $?

## Command to display dvi files on screen
SDVI=		xdvi

## Command to display postscript files on screen
SPS=		ghostview

## Do NOT include the .tex on TARGET

TARGET=		user

## You MUST include the .tex on PART?, INC? and BIBS.

PART1=		preface.tex
PART2=		intro.tex
PART3=		overview.tex
PART4=		reg.tex
PART5=		send.tex
PART6=		receive.tex
PART7=          database.tex
PART9=		crl.tex
PART10=		custom.tex
PART11=		quickref.tex
PART12=		glossary.tex
PARTS=		$(PART1) $(PART2) $(PART3) $(PART4) $(PART5) $(PART6) \
		$(PART7) $(PART9) $(PART10) $(PART11) $(PART12)

INCS=		preamble.tex lcustom.tex trademark.tex

BIBS=		doc.bib

ALL=		$(TARGET).tex $(PARTS) $(INCS) $(BIBS)

############################################################################
# The following targets are completely defined, if you are using all
# features of this Makefile (see above).  The only tailoring required beyond
# this point is at the very end of this file, where PART? and INC?
# dependencies must be listed.
############################################################################

$(TARGET).dvi:	$(TARGET).tex $(PARTS) $(TARGET).vrsn

############################################################################
# Okay, if you are NOT using bibtex to manage your bibliography then comment
# out this dependency by inserting a '#' character at the beginning of the
# line.
############################################################################

##$(TARGET).tex:	$(TARGET).bbl

$(TARGET).bbl:	$(BIBS)
		@echo The bibliography entries are out of date with respect to
		@echo the bibliography database.  Please do a \"make bib\"
		@echo when this \"make\" completes.

show-dvi:	$(TARGET).dvi
		$(SDVI) $(TARGET).dvi

show-ps:	$(TARGET).ps
		$(SPS) $(TARGET).ps

print:		$(TARGET).ps
		$(PPS) -P$(PRINTER) $(TARGET).ps

bib:
		$(MAKE) $(MFLAGS)
		bibtex $(TARGET)
		$(MAKE) $(MFLAGS) force

force:
		-rm -f $(TARGET).dvi $(TARGET).ps
		$(MAKE) $(MFLAGS)

major:
		version.sh $(TARGET) 1 0 0
		$(MAKE) $(MFLAGS)

minor:
		version.sh $(TARGET) 1 0
		$(MAKE) $(MFLAGS)

sminor:
		version.sh $(TARGET) 1
		$(MAKE) $(MFLAGS)

clean:
		-rm -f *.log *.dvi *.tty *.ps *.blg

real-clean:	clean
		-rm -f *.aux *.lof *.lot *.toc *.bbl

distribution:	real-clean
		-rm -f *~ #*

$(TARGET).vrsn:	$(ALL) $(TARGET).major $(TARGET).minor $(TARGET).sminor \
			version.sh
		version.sh $(TARGET)

############################################################################
# If the PART? files include any other files, ie the INC? lines have been
# completed above, appropriate dependencies must be created as indicated
# below.
############################################################################

$(PART8):	$(INC8)
