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