2 # Example makefile using mjotex and a BibTeX references database.
6 LATEX = pdflatex -file-line-error -halt-on-error
8 # The name of this document.
11 # A space-separated list of bib files. These must all belong to paths
12 # contained in your $BIBINPUTS environment variable.
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-common.tex mjo-cone.tex mjo-convex.tex
18 MJOTEX += mjo-font.tex mjo-linear_algebra.tex mjo-proof_by_cases.tex
19 MJOTEX += mjo-theorem.tex mjo-topology.tex
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))
27 # The first target is the default, so put the PDF document first.
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...
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.
40 # The process is kind of like finding a fixpoint of `make` with
41 # respect to the contents of the aux file.
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; \
59 # Clean up leftover junk.
62 rm -f *.{out,nav,snm,toc,aux,log,pdf,bcf,xml,bbl,blg,bib}
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.
75 cp $(SRCS) $(PN).bbl dist/