aboutsummaryrefslogtreecommitdiff
path: root/v2/dynamic.mk
blob: 5121d61837374709792b4bc360e95ff8809e0bff (about) (plain) (blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
.POSIX:


all:

include generated.mk


.SUFFIXES:
.SUFFIXES: .page .md .content .conf .html .categoryentry .indexentry .xmlentry
.SUFFIXES: .mapentry .uncolored .slides .ps .pdf


.page.md:
	ln -f $<.i18n $@.i18n
	ln -f $< $@
	touch $@ $@.i18n

.md.content:
	awk 'sep >= 2; /^---$$/ {sep++}' < $< > $@

.md.conf:
	conf $< > $@

.md.html:
	html $< > $@

.md.categoryentry:
	category $< > $@

.md.indexentry:
	indexentry $< > $@

.md.xmlentry:
	xmlentry $< > $@

.md.mapentry:
	mapentry $< > $@

.uncolored:
	printf '%s\n%s\n%s\n' \
		"`head -n2 $<`" \
		"`cat src/content/img/dark-mode.xml`" \
		"`tail -n +3 $<`" \
		> $@

.slides.ps:
	exit 88

.ps.pdf:
	ps2pdf $< $@


all: public


$(all-generated.conf) $(all-generated.content): $(non-content)
$(all-generated.conf) $(pages-mds): i18n-index.sentinel
$(all-generated.conf): src/lib/base.conf src/lib/generated.conf

src/lib/generated.conf: src/bin/conf $(svgs)
	conf > $@

$(all-generated.categories):
	categories $@

$(all-generated.index): src/lib/generated.conf
	index $@

$(all-generated.xml):
	feed $@

$(all-generated.series):
	series $@

i18n-index.sentinel: po/i18n.mappings
	i18n < po/i18n.mappings
	touch $@

clean:
	rm -rf \
		$(all-generated) $(pages-mds) $(svgs) public/ *.sentinel       \
		generated.mk po/po4a.cfg po/*.mo                               \
		src/lib/generated.conf        src/lib/generated.*.conf         \
		src/content/.gitignore        src/content/sitemap.xml          \
		src/content/*/*.category      src/content/*/*/*.category       \
		src/content/*/*.categorysort  src/content/*/*/*.categorysort   \
		src/content/*/*.html          src/content/*/*/*.html           \
		src/content/*/*.extrahtml     src/content/*/*/*.extrahtml      \
		src/content/*/*.extrafeeds    src/content/*/*/*.extrafeeds     \
		src/content/*/*.html.*.txt    src/content/*/*/*.html.*.txt     \
		src/content/*/*.i18n          src/content/*/*/*.i18n           \
		src/content/*/*.sortdata      src/content/*/*/*.sortdata       \
		src/content/*/feed.*.xml      src/content/*/*/feed.*.xml       \
		src/content/*/*.md.next       src/content/*/*/*.md.next        \
		src/content/*/*.md.prev       src/content/*/*/*.md.prev        \


public: symlink-mappings.sentinel copy-content.sentinel copy-containers.sentinel

content = \
	$(all-generated.html)                \
	$(all-generated.index)               \
	$(all-generated.xml)                 \
	$(all-generated.pdf)                 \
	$(static-content)                    \
	$(svgs)                              \
	src/content/sitemap.xml              \

containers = \
	$(all-generated.snippets)            \
	$(all-generated.extrahtml)           \
	$(all-generated.extrafeeds)          \


src/content/sitemap.xml: $(all-generated.mapentry)
	sitemap > $@

symlink-mappings.sentinel: src/redirect.mappings
	awk '{print $$2}' src/redirect.mappings | \
		xargs dirname | \
		sort |          \
		uniq |          \
		xargs -P`nproc` -I% mkdir -p public/%
	< src/redirect.mappings \
		awk '{ printf "ln -rfs public/%s public/%s\n", $$2, $$1 }' | \
		sh
	touch $@

copy-content.sentinel: $(content) content-mkdir.sentinel
	echo $? | \
		tr ' ' '\n'             | \
		grep '^src/content/'    | \
		sed 's|^src/content/||' | \
		xargs -P`nproc` -I% ln -f src/content/% public/%
	touch $@

copy-containers.sentinel: $(containers) content-mkdir.sentinel
	echo $? | tr ' ' '\n' | grep '^src/content/' | \
		xargs sed 's|^src/content/||' | \
		xargs -P`nproc` -I% ln -f src/content/% public/%
	touch $@

content-mkdir.sentinel: $(content) $(containers)
	echo $? | \
		tr ' ' '\n'             | \
		grep '^src/content/'    | \
		sed 's|^src/content/||' | \
		xargs dirname           | \
		sort                    | \
		uniq                    | \
		xargs -P`nproc` -I% mkdir -p public/%
	touch $@


src/content/favicon.ico: src/content/img/favicon.svg
	convert src/content/img/favicon.svg $@

src/content/public.asc.txt:
	gpg --armour --export '$(EMAIL)' > $@

src/content/.well-known/security.txt: \
		src/content/public.asc.txt src/bin/security-txt
	security-txt > $@



test-files = \
	aux/checks/shellcheck.sh \
	aux/checks/todos.sh      \

aux/checks/shellcheck.sh: src/lib/generated.conf

$(test-files): ALWAYS
	sh $@

check: $(test-files)
dev: all check

run: all
	serve -d public/

upload: public
	rsync \
		--rsync-path='sudo -u deployer rsync' \
		-avzP \
		--delete \
		--exclude 's/*' \
		public/ $(DOMAIN):/srv/www/

ALWAYS: