2 # Example makefile using some of mjotex (fonts, theorems) and a BibTeX
7 LATEX = pdflatex -file-line-error -halt-on-error
9 # The name of this document.
12 # A space-separated list of bib files. These must all belong to paths
13 # contained in your $BIBINPUTS environment variable.
16 # A space-separated list of the mjotex files that you use. The path to
17 # mjotex must be contain in your $TEXINPUTS environment variable.
18 MJOTEX = mjo-fonts.tex mjo-theorems.tex
20 # Use kpsewhich (from the kpathsea suite) to find the absolute paths
21 # of the bibtex/mjotex files listed in in $(BIBS)/$(MJOTEX).
22 BIBPATHS = $(shell kpsewhich $(BIBS))
23 MJOTEXPATHS = $(shell kpsewhich $(MJOTEX))
26 # The first target is the default, so put the PDF document first.
28 # The voodoo here is to avoid rebuilding the project when nothing has
29 # changed. Each compilation pass with pdflatex will produce a new aux
30 # file, even if nothing has changed. That cases Make to think that we
31 # need to regenerate the bbl file, which in turn means we need to
32 # rebuild the whole project...
34 # To avoid that, we save a copy of the current aux file and compare it
35 # to the new one afterwards. If the files are the same, great, put the
36 # old one (with the old timestamp) back. If not, we need to compile
37 # again, so we just invoke $(MAKE) again on this target.
39 # The process is kind of like finding a fixpoint of `make` with
40 # respect to the contents of the aux file.
42 $(PN).pdf: $(PN).tex $(PN).aux $(PN).bbl $(MJOTEXPATHS)
43 mv $(PN).aux $(PN).aux.bak
44 $(LATEX) $< && $(LATEX) $<
45 if cmp -s $(PN).aux $(PN).aux.bak; then \
46 mv $(PN).aux.bak $(PN).aux; \
51 $(PN).aux: $(PN).tex $(BIBPATHS)
58 # Clean up leftover junk.
61 rm -f *.{out,nav,snm,toc,aux,log,pdf,bcf,xml,bbl,blg,bib}
66 # If this document will be published, the publisher isn't going to
67 # have your BibTeX database or your mjotex files. So, you need to
68 # package them up along with the code for your document. This target
69 # will create a "dist" directory and copy the necessary stuff there.
74 cp $(PN).tex $(PN).bbl $(BIBPATHS) $(MJOTEXPATHS) dist/