]> gitweb.michael.orlitzky.com - mjotex.git/blob - makefile
Add mjo-theorem-star.tex.
[mjotex.git] / makefile
1 #
2 # Example makefile using mjotex and a BibTeX references database.
3 #
4
5 # The latex compiler.
6 LATEX = pdflatex -file-line-error -halt-on-error
7
8 # The name of this document.
9 PN := paper
10
11 # A space-separated list of bib files. These must all belong to paths
12 # contained in your $BIBINPUTS environment variable.
13 BIBS = references.bib
14
15 # A space-separated list of the mjotex files that you use. The path to
16 # mjotex must be contain in your $TEXINPUTS environment variable.
17 MJOTEX = mjo-algorithm.tex mjo-arrow.tex mjo-common.tex mjo-cone.tex
18 MJOTEX += mjo-convex.tex mjo-font.tex mjo-linear_algebra.tex mjo-misc.tex
19 MJOTEX += mjo-proof_by_cases.tex mjo-theorem.tex mjo-theorem-star.tex
20 MJOTEX += mjo-topology.tex
21
22 # Use kpsewhich (from the kpathsea suite) to find the absolute paths
23 # of the bibtex/mjotex files listed in in $(BIBS)/$(MJOTEX). The SRCS
24 # variable should contain all (Bib)TeX source files for the document.
25 SRCS = $(PN).tex $(shell kpsewhich $(BIBS)) $(shell kpsewhich $(MJOTEX))
26
27
28 # The first target is the default, so put the PDF document first.
29 #
30 # The voodoo here is to avoid rebuilding the project when nothing has
31 # changed. Each compilation pass with pdflatex will produce a new aux
32 # file, even if nothing has changed. That cases Make to think that we
33 # need to regenerate the bbl file, which in turn means we need to
34 # rebuild the whole project...
35 #
36 # To avoid that, we save a copy of the current aux file and compare it
37 # to the new one afterwards. If the files are the same, great, put the
38 # old one (with the old timestamp) back. If not, we need to compile
39 # again, so we just invoke $(MAKE) again on this target.
40 #
41 # The process is kind of like finding a fixpoint of `make` with
42 # respect to the contents of the aux file.
43 #
44 $(PN).pdf: $(SRCS) $(PN).aux $(PN).bbl
45 mv $(PN).aux $(PN).aux.bak
46 $(LATEX) $< && $(LATEX) $<
47 if cmp -s $(PN).aux $(PN).aux.bak; then \
48 mv $(PN).aux.bak $(PN).aux; \
49 else \
50 $(MAKE) $@; \
51 fi;
52
53 $(PN).aux: $(SRCS)
54 $(LATEX) $<
55
56 $(PN).bbl: $(PN).aux
57 bibtex $<
58
59
60 # Clean up leftover junk.
61 .PHONY: clean
62 clean:
63 rm -f *.{out,nav,snm,toc,aux,log,pdf,bcf,xml,bbl,blg,bib}
64 rm -rf dist/
65
66
67
68 # If this document will be published, the publisher isn't going to
69 # have your BibTeX database or your mjotex files. So, you need to
70 # package them up along with the code for your document. This target
71 # will create a "dist" directory and copy the necessary stuff there.
72 #
73 .PHONY: dist
74 dist: $(PN).bbl
75 mkdir -p dist
76 cp $(SRCS) $(PN).bbl dist/