Skip to content

Instantly share code, notes, and snippets.

@moriglia
Last active April 25, 2022 10:14
Show Gist options
  • Save moriglia/7e73287cb32c8072e45c0bd2fd427f8a to your computer and use it in GitHub Desktop.
Save moriglia/7e73287cb32c8072e45c0bd2fd427f8a to your computer and use it in GitHub Desktop.
Makefile for compiling tex files (starting with 3 digits) in pdfs. Tune your pattern in the ALLPDF variable
OUTDIR ?= `pwd`
DRAFTFLAGS = -draftmode --shell-escape -interaction nonstopmode -output-directory $(OUTDIR)
PDFFLAGS = --shell-escape -interaction nonstopmode -output-format pdf -output-directory $(OUTDIR)
ALLPDF = $(patsubst %.tex,%.pdf,$(shell find . -iregex \.\/[0-9]+_.*\.tex))
.PHONY: clean cleanpdf all
all: $(ALLPDF)
%.log %.aux: %.tex
pdflatex $(DRAFTFLAGS) $<
%.bbl: %.aux
bibtex $<
ifdef MAKEBIB
%.pdf: %.bbl
pdflatex $(DRAFTFLAGS) $*.tex
else
%.pdf: %.log # Make a draft once
endif
# Finally make the pdf
pdflatex $(PDFFLAGS) $*.tex
clean:
rm -rf *.aux *.log
cleanpdf:
# Do not remove pdfs that are not produced by make
rm -rf $(ALLPDF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment