# This is buggy: it replaces *all* occurrences of documentclass
# maybe this helps: https://stackoverflow.com/questions/6278057/replace-only-first-match-in-multiple-files-with-perl

%-handout.pdf: %.tex
	cat $< | perl -0777 -p -e 's/^\\documentclass\[/\\documentclass\[handout,/' -e 's/^\\documentclass{/\\documentclass\[handout\]{/' | lualatex -jobname=$(basename $@)
	cat $< | perl -0777 -p -e 's/^\\documentclass\[/\\documentclass\[handout,/' -e 's/^\\documentclass{/\\documentclass\[handout\]{/' | lualatex -jobname=$(basename $@)

clean:
	rm -f *-handout.pdf
