NAME = document TEX = $(NAME).tex SRC = $(TEX) PDF = $(TEX:.tex=.pdf) TEXMK = latexmk -shell-escape -lualatex -interaction=nonstopmode QPDF = qpdf --linearize --replace-input MKDIR = mkdir -p ECHO = echo CD = cd MV = mv REPORT_DIR = report IMG_DIR = imgs all: $(PDF) $(PDF): %.pdf: %.tex ifneq ($(wildcard $(IMG_DIR)/.*),) $(TEXMK) $< @$(QPDF) $@ 2>/dev/null |: else # Generate SVG if no imgs/ directory found @$(MAKE) generate_svg @$(MAKE) $@ endif EXTS = aux fdb_latexmk fls log nav out snm synctex.gz toc clean: rm -rf $(PDF) _minted-$(NAME)/ $(IMG_DIR)/ \ $(foreach ext,$(EXTS),$(NAME).$(ext)) generate_svg: @$(MKDIR) $(IMG_DIR) # List of Lsystem to generate as pair `name,n`, space separated @$(CD) ..; $(MAKE) -s generation; \ for pair in \ snow,5 koch,2 koch1,2 koch2,3 koch3,3 koch5,4 sierp,7 gosp6,4 gosp4,2 \ star,7 moore,3 peano,3 koch8,6 pyramid,3 carpet,4 square,4 pentaplexy,3 \ triangles,3 blocks,2; do \ IFS=',' read -r nom n <<< "$$pair"; \ $(MAKE) -s NOCHECK=1 tortue nom=$$nom n=$$n; \ $(MAKE) -s NOCHECK=1 traceur; $(MAKE) -s svg; \ $(MV) image.svg $(REPORT_DIR)/$(IMG_DIR)/$$nom.svg; \ $(ECHO) "'$$nom' generated with $$n iterations."; \ done