summaryrefslogtreecommitdiff
path: root/Makefile
blob: d5cd91bed4ba04c6b705dcc935ceffc2a5a6fc20 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Set the default target #######################################################
phony += all
all:

# Boilerplate ##################################################################
SHELL = bash
phony += FORCE
.DELETE_ON_ERROR:
.SECONDARY:

# Development server ###########################################################
serve: serve-8000
serve-%: all
	dir=$$(mktemp -d -t) && trap 'fusermount -u "$$dir"; rmdir "$$dir"' EXIT && unionfs -o ro out:src "$$dir" && (cd "$$dir" && python3 -m http.server $*)
phony += serve serve-%

# Real rules to actually make the website ######################################

RUBYLIB=$(realpath .)/lib
export RUBYLIB

patsubst-all = $(if $1,$(call patsubst-all,$(wordlist 2,$(words $1),$1),$2,$(patsubst $(firstword $1),$2,$3)),$3)

html.suffixes = md org erb
html.src = $(shell find src -type f \( -false $(foreach s,$(html.suffixes), -o -name '*.$s' -o -name '*.$s.m4' ) \) | grep -v /web/)
html.out = $(call patsubst-all,$(addprefix src/%.,$(html.suffixes)),out/%.html,$(patsubst %.m4,%,$(html.src)))
all: $(html.out)
all: out/style.css
all: out/header-path.svg

pagerender.deps = bin/pagerender lib/pandoc.rb lib/template.erb lib/footer.md

out/%: src/%.m4
	mkdir -p -- $(@D)
	m4 -P < $< > $@
out/%: out/%.m4
	m4 -P < $< > $@

out/%.html: src/%.md $(pagerender.deps)
	mkdir -p -- $(@D)
	bin/pagerender $< > $@
out/%.html: out/%.md $(pagerender.deps)
	bin/pagerender $< > $@

out/%.html: src/%.org $(pagerender.deps)
	mkdir -p -- $(@D)
	bin/pagerender $< > $@
out/%.html: out/%.org $(pagerender.deps)
	bin/pagerender $< > $@

out/%.html: src/%.erb $(pagerender.deps)
	mkdir -p -- $(@D)
	bin/pagerender $< > $@
out/%.html: out/%.erb $(pagerender.deps)
	bin/pagerender $< > $@

var-%:
	@printf '%s\n' $(call quote.shell,$($*))

out/%.css: src/%.scss
	scss -s < $< > $@

# Recurse into the logos folder ################################################
outdir=out/logos
srcdir=src/logos
topoutdir=out
topsrcdir=src
include src/logos/Makefile

# Boilerplate ##################################################################

.PHONY: $(phony)

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)')