SHELL = /bin/sh .SUFFIXES: # All notes referenced with internal links, starting from `index.md`. NOTES = $(shell pandoc lua pandoc/collect_notes.lua index.md) # All pages referenced with internal links, starting from `index.md`. PAGES := $(patsubst %.md,public_html/%.html,$(NOTES)) # All parts referenced with internal links in `$(1)`, plus the sitemap. PARTS = $(patsubst %.md,public_html/%.html.part,$(shell pandoc lua pandoc/collect_links.lua $(1))) public_html/sitemap.html.part PANDOCFLAGS = --data-dir pandoc .PHONY: all all: $(PAGES) .SECONDEXPANSION: public_html/%.html: flags = $(patsubst %,-M parts=%,$(filter-out $<,$^)) public_html/%.html: %.md $$(call PARTS,%.md) @echo $^ pandoc $(PANDOCFLAGS) -d bavbavhaus.net.yaml -M slug=$* $(flags) -o $@ $< .SECONDARY: public_html/%.html.part: %.md pandoc $(PANDOCFLAGS) -d bavbavhaus.net.part.yaml --id-prefix $* -M url=$*.html -M slug=$* -o $@ $< public_html/sitemap.html.part: $(NOTES) pandoc lua pandoc/sitemap.lua index.md $@ dest/%.docx: %.md test -d dest || mkdir dest pandoc --data-dir pandoc --resource-path pandoc -d docx.yaml -o $@ $< .PHONY: clean clean: $(RM) public_html/*.html.part $(RM) public_html/*.html $(RM) -r dest