HANDOUTS = $(patsubst %.tex,%.pdf,$(wildcard */*/handout.tex))
REVEALJS = $(patsubst %.md,%.html,$(wildcard revealjs/*/index.md))
LATEX = $(patsubst %.tex,%.pdf,$(wildcard latex/*/index.tex))

all: ${HANDOUTS} ${REVEALJS} ${LATEX}

.PHONY: clean
clean:
	rm -f \
		*/*/*.aux \
		*/*/*.bbl \
		*/*/*.bcf \
		*/*/*.blg \
		*/*/*.fdb_latexmk \
		*/*/*.fls \
		*/*/*.log \
		*/*/*.nav \
		*/*/*.out \
		*/*/*.run.xml \
		*/*/*.snm \
		*/*/*.toc \
		*/*/*.xdv \
		*/*/handout.pdf \
		*/*/index.pdf \
		revealjs/*/index.html

revealjs/%/index.html: revealjs/%/*.md
	python3 revealjs/build.py $@

%/handout.pdf: %/handout.tex
	latexmk -cd -xelatex $<

latex/%/index.pdf: latex/%/index.tex
	latexmk -cd -xelatex $<
