summaryrefslogtreecommitdiff
path: root/Makefile
blob: 05a557a5e42644f4392a16fcebd1f32fb3b33261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)')