PANDOC = pandoc
TEX = pandoc
texsrc = template.tex handin.md
htmlsrc = handin.md static/style.css
pdf = out.pdf
html = out.html static/style.css
FLAGS = --latex-engine=pdflatex --css=style.css
basename = $(shell basename $(CURDIR))

package: $(pdf) $(html)
	mkdir -p out/pdf
	cp $(pdf) out/pdf/
	mv out/pdf/out.pdf out/pdf/$(basename).pdf

	mkdir -p out/html
	cp $(html) out/html/
	mv out/html/out.html out/html/$(basename).html

out.pdf : $(texsrc)
	$(TEX) $(filter-out $<,$^ ) -o $@ --template=$< $(FLAGS)


out.html: $(htmlsrc)
	$(PANDOC) handin.md -o $@ $(FLAGS)


.PHONY: clean
clean :
	rm out.pdf
	rm out.html
	rm -R out