MAIN=$(sh grep -l '\documentclass' *.tex) TEXFILES=$(filter-out $(MAIN), $(sh ls *.tex)) PDFLATEX=pdflatex PDF=$(MAIN:.tex=.pdf) DEFAULT: pdf pdf : $(PDF) $(PDF) : $(MAIN) $(TEXFILES) $(PDFLATEX) $(MAIN) $(PDFLATEX) $(MAIN)
- The variable
MAINis automatically populated with grep searching for a file that contains the string
\documentclass(hopefully finds the correct one...)
TEXFILESare all other files with the file extension .tex.
MAINfile. You can change this according to your preference.
PDFLATEXis the program name to generate PDF from LaTeX input.
- The first rule is the default when
makeis invoked without parameters. To avoid confusion and accidental overwriting, a striking
DEFAULT-target is used that just tells
maketo build the PDF.
- The rule for
make pdfis propably only useful, if also rules for Postscript and DVI are implemented. For beginners: stick to using
pdflatexto directly generate PDF files. The old way with DVI is obsolete (unless your printing service can only handle Postscript).
- The PDF is generated from all .tex files.
To get the references right,
pdflatexis called twice.
- If you're using an index or BibLaTeX/BibTeX, then append their invokation and add another two calls to
If the generation takes too long, add a
quicktarget, that unconditionally calls
pdflatexonce. After fixing typos or only minor modifications, this often suffices.
::make quick : $(PDFLATEX) $(MAIN)