#
#	Makefile for LaTeX version of DKBTrace manual
#	George Ferguson, ferguson@cs.rochester.edu , 14 June 1991.
#
#	Read carefully if you don't have "makeindex" or "fig2dev".
#

PAPER = dkb212
SRCS  = notices.tex overview.tex starting.tex options.tex tutorial.tex \
	language.tex display.tex utils.tex works.tex quests.tex \
	convert.tex hints.tex compile.tex porting.tex history.tex \
	refs.tex concl.tex authors.tex
FIGS =  axes.tex layers.tex csg0.tex csg1.tex csg2.tex csg3.tex csg4.tex \
	distort.tex lefthand.tex log.tex map1.tex map2.tex \
	marble.tex parse1.tex parse2.tex parse3.tex plane.tex \
	project.tex skyup.tex torus.tex turb.tex vectors.tex
INDEX = index.tex

#
# Rule for creating latex figures from fig files
#
.SUFFIXES: .tex .fig
.fig.tex:
	fig2dev -L latex -l 2 $< >$@

#
# Fairly useless top-level target, often needs to be repeated, but
# something had to be here.
#
$(PAPER): $(SRCS) $(FIGS)
	latex $(PAPER)
	latex $(PAPER)

#
# Reformat the manual and rebuild the index. Do not use if you don't
# have makeindex.
#
all: $(SRCS) $(FIGS)
	latex $(PAPER)
	make index
	latex $(PAPER)

#
# We send the output of makeindex through sed since we used
#    \catcode`\_=12
# to allow underscores to go through, but we need them mapped
# back to \_ or they come out as raised dots. Why? I have no idea.
#
index:
	cat $(PAPER).idx | \
	  makeindex -i -t $(PAPER).ilg | \
	  sed 's/_/\\_/' >$(INDEX)

# remove all the bilge, except the index file and the latex figures
clean:
	rm -f *.aux *.log *.dvi *.toc *.lof *.idx *.ilg *.~

# remove everything including the index (do not use if you don't
# have "makeindex" to rebuild it with) and the figures in latex form
# (don not use if you don't have "fig2dev" to rebuild them with)
spotless: clean
	rm -f $(INDEX) $(FIGS)
	touch $(INDEX)
