sections = $(shell find sections/ -name '*.md' | sort -V)

pandoc = \
	@ pandoc $(1)         \
	--toc                 \
	--standalone          \
	--pdf-engine=xelatex  \
	-F pandoc-crossref    \
	-o $(2).pdf

all: lectures.pdf

clean:
	rm lectures.pdf

lectures.pdf: $(sections) images
	$(call pandoc, $(sections), lessons)