-DOC:=a
+DOCS:=a
LATEX:=pdflatex
BIBTEX:=bibtex
+BIBTEXFLAGS:=
LATEXFLAGS:=-file-line-error -halt-on-error -no-shell-escape
-TEXS:=$(wildcard *.tex)
+TEXS:=$(filter-out preamble.tex,$(wildcard *.tex))
+PREAMBLE:=$(wildcard preamble.tex)
-.PHONY: all
-.SECONDARY: $(DOC).fmt
+.PHONY: all clean
+.SECONDARY: $(addsuffix .fmt,$(DOCS))
-all: $(DOC).pdf
+all: $(addsuffix .pdf,$(DOCS))
-%.fmt: preamble.tex
+%.fmt: %.pre
$(LATEX) $(LATEXFLAGS) -ini -jobname="$(basename $@)" "&$(LATEX) $<\dump"
-%.pdf: %.tex %.fmt %.bib $(TEXS)
+%.pdf: %.mlog
+ grep -iFq 'Rerun to get' $< &&\
+ $(LATEX) $(LATEXFLAGS) $(basename $<) || true
+
+%.mlog: %.tex %.fmt %.bib $(TEXS)
$(LATEX) $(LATEXFLAGS) $<
- grep -q '^\\bibdata{' $(basename $<).aux && $(BIBTEX) $(basename $<) || true
- $(LATEX) $(LATEXFLAGS) $< | tee $(basename $<).mlog
- grep -iqF 'rerun' $(basename $<).mlog &&\
- $(LATEX) $(LATEXFLAGS) $< || true
+ grep -q '^\\bibdata{' $(basename $<).aux &&\
+ $(BIBTEX) $(BIBTEXFLAGS) $(basename $<) || true
+ $(LATEX) $(LATEXFLAGS) $< | tee $@
clean:
- $(RM) $(addprefix $(DOC).,aux log fmt toc bbl blg mlog run.xml out pdf)
+ $(RM) $(foreach DOC,$(DOCS),\
+ $(addprefix $(DOC).,aux log fmt toc bbl blg run.xml out pdf))