1.PHONY:	alberta pdf indices bbl tgz tex_tgz full_tgz clean vclean new
2
3SILENT    = > /dev/null 2>&1
4SRCLTX    = -src-specials
5LATEX     = latex -interaction batchmode $(SRCLTX) $(SILENT)
6TEX       = tex -interaction batchmode $(SRCLTX) $(SILENT)
7PDFLATEX  = pdflatex -interaction batchmode $(SRCLTX) $(SILENT)
8BIBTEX    = bibtex $(SILENT)
9MAKEINDEX = makeindex $(SILENT)
10FGREP     = fgrep $(SILENT)
11
12BOOK_FILES = \
13 adapt-concept.tex \
14 bas-concept.tex \
15 concept.tex \
16 defs.tex \
17 dof-concept.tex \
18 mesh-concept.tex \
19 preface.tex \
20 rc-concept.tex \
21 submesh-concept.tex
22
23MAN_FILES =\
24 defs.tex\
25 addon-tools.tex \
26 adapt-tools.tex \
27 alberta-book.tex \
28 alberta-man.tex \
29 alberta.tex \
30 assemble-tools.tex \
31 bas-impl.tex \
32 chain-impl.tex \
33 concept.tex \
34 defs.tex \
35 dof-impl.tex \
36 ellipt.tex \
37 est-tools.tex \
38 eval-tools.tex \
39 examples.tex \
40 init-element-impl.tex \
41 files.tex \
42 graph-tools.tex \
43 heat.tex \
44 impl.tex \
45 intro.tex \
46 mesh-impl.tex \
47 nonlin.tex \
48 param-impl.tex \
49 periodic-impl.tex \
50 preface.tex \
51 rc-impl.tex \
52 solve-tools.tex \
53 splitindex.tex \
54 struct-func.tex \
55 submesh-impl.tex \
56 tools.tex \
57 traverse-impl.tex \
58 util-impl.tex
59
60default: alberta-man.pdf # alberta.pdf
61
62alberta.tex: alberta.bib
63
64alberta.dvi: alberta.tex
65	$(LATEX) alberta
66	$(LATEX) alberta
67	$(LATEX) alberta
68	bibtex alberta
69	tex \\def\\idx{alberta}\\input splitindex
70	makeindex alberta-idx.idx
71	makeindex alberta-cdx.idx
72	makeindex alberta-mdx.idx
73	makeindex alberta-ddx.idx
74	makeindex alberta-fdx.idx
75	$(LATEX) alberta
76	$(LATEX) alberta
77
78indices:
79	tex \\def\\idx{alberta}\\input splitindex
80	makeindex alberta-idx.idx
81	makeindex alberta-cdx.idx
82	makeindex alberta-mdx.idx
83	makeindex alberta-ddx.idx
84	makeindex alberta-fdx.idx
85
86alberta.ps: alberta.dvi
87	dvips -Pamz -Pcmz -ta4 -Pa4 -o $@ $<
88
89alberta:
90	$(LATEX) alberta
91
92alberta.pdf: $(MAN_FILES) $(BOOK_FILES)
93	$(PDFLATEX) alberta
94	$(PDFLATEX) alberta
95	$(PDFLATEX) alberta
96	bibtex alberta
97	tex \\def\\idx{alberta}\\input splitindex
98	makeindex alberta-idx.idx
99	makeindex alberta-cdx.idx
100	makeindex alberta-mdx.idx
101	makeindex alberta-ddx.idx
102	makeindex alberta-fdx.idx
103	$(PDFLATEX) alberta
104	$(PDFLATEX) alberta
105	$(PDFLATEX) alberta
106
107MAXITER=4
108
109bookmanstuff: alberta-book.tex $(BOOK_FILES) alberta-man.tex ${MAN_FILES}
110	@cnt=0; stop=false;\
111echo "Setup: running LaTeX";\
112$(LATEX) alberta-man; $(LATEX) alberta-book;\
113while test "$$stop" = "false" -a "$$cnt" -lt $(MAXITER); do\
114  cnt=$$(($${cnt} + 1));\
115  echo -n "Iteration $$cnt: running BibTeX ... ";\
116  $(BIBTEX) alberta-man; $(BIBTEX) alberta-book;\
117  echo -n "running makeindex ... ";\
118  $(TEX) \\def\\idx{alberta-man}\\input splitindex;\
119  $(MAKEINDEX) alberta-man-idx.idx;\
120  $(MAKEINDEX) alberta-man-cdx.idx;\
121  $(MAKEINDEX) alberta-man-mdx.idx;\
122  $(MAKEINDEX) alberta-man-ddx.idx;\
123  $(MAKEINDEX) alberta-man-fdx.idx;\
124  echo "running LaTeX.";\
125  $(LATEX) alberta-man; $(LATEX) alberta-book;\
126  if ! $(FGREP) "There were undefined references" alberta-man.log &&\
127     ! $(FGREP) "There were undefined references" alberta-book.log; then\
128    stop=true;\
129  fi;\
130done; \
131if test $$cnt -ge $(MAXITER); then\
132  echo "Not all references could be resolved after $$cnt iterations.";\
133  rm alberta-man.pdf alberta-book.pdf;\
134  exit 1;\
135else\
136  echo "Success after $$cnt iterations.";\
137fi
138
139alberta-man.pdf alberta-book.pdf: Makefile\
140  alberta-book.tex $(BOOK_FILES) alberta-man.tex ${MAN_FILES}
141	make LATEX="$(PDFLATEX)" bookmanstuff
142
143alberta-man.dvi alberta-book.dvi: Makefile\
144  alberta-book.tex $(BOOK_FILES) alberta-man.tex ${MAN_FILES}
145	make LATEX="$(LATEX)" bookmanstuff
146
147tgz:
148	tar cvf - Makefile *.tex *.bib {EPS,Logo}/*.eps | gzip -9v > doc.tgz
149	@ls -l doc.tgz
150
151tex_tgz:
152	tar cvf - Makefile *.tex *.bib | gzip -9v > doc_tex.tgz
153	@ls -l doc_tex.tgz
154
155full_tgz:
156	tar cvf - Makefile *.tex *.bib {EPS,Logo}/*.{eps,sc,obj,pdf} | gzip -9v > doc_all.tgz
157	@ls -l doc_all.tgz
158
159clean:
160	find . \( -name \*~ -o -name \*.out -o -name \*.aux -o -name \*.dvi -o -name \*.log -o -name \*.ilg -o -name \*.blg \) -exec /bin/rm -f {} \;
161
162auxclean: clean
163	find . \( -name \*.bbl -o -name \*.idx  -o -name \*.toc\
164 -o -name \*.bbl -o -name \*.idx -o -name \*.ind -o -name \*.lof\
165 -o -name \*.lot -o -name \*.\*pk -o -name \*.tfm \) -exec /bin/rm -f {} \;
166
167vclean: auxclean
168	rm -f *.pdf *.dvi *.ps
169
170new: vclean alberta.pdf
171