From c8428889c5221c191c386df8a62ea7282311193e Mon Sep 17 00:00:00 2001
From: Sam Yates <yates@cscs.ch>
Date: Wed, 15 Mar 2017 11:19:33 +0100
Subject: [PATCH] Base report generation `makefile` on `latexmk`. (#191)

Using latexmk simplifies the makefile structure and avoids many of the problems with redundant pdflatex invocation.

Rewrite docs/model/makefile and docs/model/images/makefile to use latexmk for building and cleaning.
Remove generated report.bbl from repo.
---
 docs/model/images/makefile | 17 ++++++++++++-----
 docs/model/makefile        | 26 +++++++++-----------------
 docs/model/report.bbl      |  9 ---------
 3 files changed, 21 insertions(+), 31 deletions(-)
 delete mode 100644 docs/model/report.bbl

diff --git a/docs/model/images/makefile b/docs/model/images/makefile
index 94ba1a4d..c8d50c64 100644
--- a/docs/model/images/makefile
+++ b/docs/model/images/makefile
@@ -1,7 +1,14 @@
-all : cable.pdf soma.pdf
+.PHONY: all
 
-cable.pdf : cable.tex
-	pdflatex cable.tex
+sources := cable.tex soma.tex
+
+all: $(patsubst %.tex,%.pdf,$(sources))
+
+LATEXMK := latexmk -pdf -halt-on-error
+
+%.pdf: %.tex
+	$(LATEXMK) $<
+
+clean:
+	for s in $(sources); do $(LATEXMK) -C "$$s"; done
 
-soma.pdf : soma.tex
-	pdflatex soma.tex
diff --git a/docs/model/makefile b/docs/model/makefile
index f7bb82ba..8e70717f 100644
--- a/docs/model/makefile
+++ b/docs/model/makefile
@@ -1,21 +1,13 @@
-report.pdf : *.tex images.dir bib
-	pdflatex report.tex
+images := images/cable.pdf images/soma.pdf
 
-images.dir:
-	make -C images
+LATEXMK := latexmk -e '$$clean_ext=q/bbl run.xml/' -pdf -use-make -halt-on-error
 
-force : report.pdf
-	pdflatex report.tex
+report.pdf : report.tex appendix.tex formulation.tex symbols.tex SelfArx.cls bibliography.bib ${images}
+	$(LATEXMK) $<
 
-bib : *.tex bibliography.bib
-	pdflatex report.tex
-	bibtex report
-	pdflatex report.tex
-	pdflatex report.tex
+images/%.pdf: images/%.tex
+	make -C images $(patsubst images/%,%,$@)
 
-clean :
-	rm -f *.pdf
-	rm -f *.log
-	rm -f *.out
-	rm -f *.aux
-	rm -f *.toc
+clean:
+	$(LATEXMK) -C report.tex
+	make -C images clean    
diff --git a/docs/model/report.bbl b/docs/model/report.bbl
deleted file mode 100644
index bc1039fa..00000000
--- a/docs/model/report.bbl
+++ /dev/null
@@ -1,9 +0,0 @@
-\begin{thebibliography}{1}
-
-\bibitem{lindsay_2004}
-K.~Lindsay, J.~Rosenberg, and G.~Tucker.
-\newblock From maxwell's equations to the cable equation and beyond.
-\newblock {\em Progress in Biophysics and Molecular Biology}, 85(1):71 -- 116,
-  2004.
-
-\end{thebibliography}
-- 
GitLab