elaborate on communication
[msc-thesis1617.git] / Makefile
1 DOCS:=thesis
2 GREP?=grep
3 LATEX?=pdflatex
4 BIBTEX?=bibtex
5 BIBTEXFLAGS:=
6 MAKEGL?=makeglossaries
7 MAKEGLFLAGS?=
8 MAKEINDEX?=makeindex
9 LATEXFLAGS:=-file-line-error -halt-on-error #-no-shell-escape
10
11 FIGURES:=$(patsubst fig/%.dot,img/%.png,$(wildcard fig/*.dot))
12 LISTINGS:=$(wildcard listings/*)
13 TEXS:=$(wildcard *.bib)
14 BIBS:=$(wildcard *.tex)
15
16 .PHONY: all clean
17 .SECONDARY: $(DOCS:%=%.fmt) $(FIGURES)
18
19 all: $(DOCS:%=%.pdf)
20
21 %.fmt: %.pre
22 $(LATEX) $(LATEXFLAGS) -ini -jobname="$(basename $<)" "&$(LATEX) $<\dump"
23
24 %.pdf: %.mlog
25 if grep -Fiq "Rerun" $<; then $(LATEX) $(LATEXFLAGS) $(basename $<); fi
26
27 %.mlog: %.tex %.fmt $(BIBS) $(TEXS) $(FIGURES) $(LISTINGS)
28 $(LATEX) $(LATEXFLAGS) $<
29 if $(GREP) -q '^\\bibdata{' $(basename $<).aux; then $(BIBTEX) $(BIBTEXFLAGS) $(basename $<); fi
30 if $(GREP) -q '\@istfilename' $(basename $<).aux; then $(MAKEGL) $(MAKEGLFLAGS) $(basename $<); fi
31 if [ -f $(basename $<).idx ]; then $(MAKEINDEX) $(basename $<); fi
32 $(LATEX) $(LATEXFLAGS) $< | tee $@
33
34 img/%.png: fig/%.dot
35 dot -Tpng $< > $@
36
37 clean: $(DOCS:%=clean-%)
38 $(RM) $(FIGURES)
39
40 clean-%:
41 $(RM) $(addprefix $(@:clean-%=%).,acn acr alg aux bbl blg fmt glg glo\
42 gls ist lof log lol lot mlog out pdf tdo toc)