I'm trying to simplify/improve the Makefile for compiling my thesis. The Makefile works nicely for compiling the whole thing; I've got something like this:
show: thesis.pdf
open thesis.pdf
thesis.pdf: *.tex
pdflatex --shell-escape thesis
This allows me to type make
and any changes are detected (if any) and it's recompiled before being displayed.
Now I'd like to extend it to conditionally compile only individual chapters. For example, this allows me to write make xpmt
to get just a single chapter in a round-about sort of way:
xpmt: ch-xpmt.pdf
open ch-xpmt.pdf
ch-xpmt.pdf: xpmt.tex
pdflatex --shell-escape --jobname=ch-xpmt \
"\includeonly{xpmt}\input{thesis}"
But I don't want to have to write this down identically for each individual chapter. How can I write the rules above in a general enough way to avoid repetition?
(More of an exercise in learning how to write Makefiles rather than to solve any real problem; obviously in this case it would actually be trivial to copy and paste the above code enough times!)