#!/usr/bin/make

# Slides are the deliverable: this is the build that gets uploaded and the one
# that has to validate. The notes build is assembled from it afterwards and is
# only ever looked at while presenting.

# veraPDF's installer leaves a directory called verapdf on PATH which shadows
# the launcher inside it, so the full path is used. Override if yours differs.
VERAPDF ?= $(HOME)/bin/verapdf/verapdf

TEX := $(wildcard *.tex)
PDF := $(patsubst %.tex,%.pdf,$(TEX))
JOB := $(patsubst %.tex,%,$(TEX))

all: slides
slides: $(PDF)

%.pdf: %.tex
	latexmk -f -lualatex $<

# Double-width pages, slide left and notes right, for dspdfviewer and pdfpc.
notes: slides
	./mknotes $(JOB)

# PDF/UA-2 conformance of the slides. Only the slides build is expected to
# pass; the assembled notes PDF is untagged by design.
validate: slides
	$(VERAPDF) -f ua2 --format text $(PDF)

viewpdf: slides
	evince $(PDF)

pdfpc: notes
	pdfpc -n right $(JOB)-notes.pdf

clean:
	latexmk -C $(TEX)
	rm -f *.notes *.tmp *.nav *.snm *.pdfpc *-luamml-mathml.html
	rm -f $(JOB)-notes.pdf

.PHONY: all slides notes validate viewpdf pdfpc clean
