.PHONY: default
default:

.PHONY: clean
clean:
	find latex \
		-type f \
		\( \
		-iname "*.aux" \
		-o -iname "*.nav" \
		-o -iname "*.out" \
		-o -iname "*.toc" \
		-o -iname "*.snm" \
		-o -iname "*.log" \
		-o -iname "*.eps" \
		\) \
		-delete
	find latex revealjs -iname "*.pdf" -type f -delete
	rm -rf latex/fonts revealjs/node_modules

latex/fonts:
	mkdir $@

.PHONY: fonts
fonts: latex/fonts
	wget -P latex/fonts -c -q \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-Black.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-BlackItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-Bold.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-BoldItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-Light.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-LightItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-Medium.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-MediumItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-Regular.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-RegularItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-Thin.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto/Roboto-ThinItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto-slab/Roboto-Slab-Bold.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto-slab/Roboto-Slab-Light.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto-slab/Roboto-Slab-Regular.ttf \
	https://cdn.jsdelivr.net/npm/roboto-fontface/fonts/roboto-slab/Roboto-Slab-Thin.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-Bold.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-BoldItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-Italic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-Light.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-LightItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-Medium.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-MediumItalic.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-Regular.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-Thin.ttf \
	https://cdn.jsdelivr.net/npm/roboto-mono-webfont/fonts/RobotoMono-ThinItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraMono-Bold.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraMono-Medium.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraMono-Regular.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Bold.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-BoldItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Book.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-BookItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Eight.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-EightItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-ExtraBold.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-ExtraBoldItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-ExtraLight.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-ExtraLightItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Four.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-FourItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Hair.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-HairItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Heavy.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-HeavyItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Light.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Italic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-LightItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Medium.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-MediumItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Regular.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-SemiBold.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-SemiBoldItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Thin.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-ThinItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Two.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-TwoItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-Ultra.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-UltraItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-UltraLightItalic.ttf \
	https://cdn.jsdelivr.net/npm/mozilla-fira-pack/Fira/ttf/FiraSans-UltraLight.ttf

revealjs/node_modules:
	(cd $(@D) && npm install)

revealjs/%/index.pdf: revealjs/%/index.html
	decktape --no-sandbox -s 1920x1200 $< $@

latex/%/index.pdf: latex/%/index.tex
	(cd $(@D) && latexmk -lualatex index.tex)

%.pdf: %.svg
	inkscape -D -z --file="$<" --export-pdf="$@"

%/handout.pdf: %/handout.odt
	libreoffice --headless --convert-to pdf "$<" --outdir $(@D)
