# Build the design document and the implementation journal.
# Requires: pdflatex, latexmk, and rsvg-convert for the figs target.

DOCS = design journal

.PHONY: all clean watch figs design journal

all: design journal

design: design.pdf

journal: journal.pdf

design.pdf: design.tex figures/*.pdf
	latexmk -pdf -interaction=nonstopmode design.tex

journal.pdf: journal.tex figures/*.pdf
	latexmk -pdf -interaction=nonstopmode journal.tex

# Convert any SVG figures generated by the Rust crate into PDFs for inclusion.
figs:
	@for svg in figures/*.svg; do \
		[ -f "$$svg" ] || continue; \
		pdf="$${svg%.svg}.pdf"; \
		echo "Converting $$svg -> $$pdf"; \
		rsvg-convert -f pdf -o "$$pdf" "$$svg"; \
	done

watch-design:
	latexmk -pdf -pvc -interaction=nonstopmode design.tex

watch-journal:
	latexmk -pdf -pvc -interaction=nonstopmode journal.tex

clean:
	latexmk -C
	rm -f *.aux *.log *.out *.toc *.fls *.fdb_latexmk *.synctex.gz
