SHELL = bash -o pipefail articles = $(sort $(filter-out public/index,$(patsubst %.md,%,$(wildcard public/*.md)))) all: public/index.html public/index.atom $(addsuffix .html,$(articles)) public/%.html: public/%.md page page.html.erb util.rb Makefile write-atomic ./page html $< | ./write-atomic $@ public/index.md : index index.md.erb .var.articles $(addsuffix .md,$(articles)) util.rb Makefile write-atomic ./index md $(filter %.md,$^) | ./write-atomic $@ public/index.atom: index index.atom.erb .var.articles $(addsuffix .md,$(articles)) util.rb Makefile write-atomic ./index atom $(filter %.md,$^) | ./write-atomic $@ clean: rm -f -- public/*.html public/*.atom public/index.md .var* .tmp* .var.%: FORCE write-ifchanged @printf '%s' $(call quote.shell,$($*)) | sed 's/^/#/' | ./write-ifchanged $@ -include $(wildcard .var.*) .PHONY: FORCE .PHONY: all clean .DELETE_ON_ERROR: .SECONDARY: define nl endef # I put this as the last line in the file because it confuses Emacs syntax # highlighting and makes the remainder of the file difficult to edit. quote.shell = $(subst $(nl),'$$'\n'','$(subst ','\'',$1)')