summaryrefslogtreecommitdiff
path: root/Makefile
blob: 37b1b1654fab6fd797b587a3e08e4ac17f92d3e1 (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
# BENZIN Makefile

HEADER=templates/header.html
PANDOC_ARGS=--from=gfm+emoji --to=html --section-divs
RSS=out/blog/index.xml

BLOG_SOURCES=$(wildcard src/blog/*.md)
SOURCES=$(wildcard src/*.md) $(BLOG_SOURCES)

TMP_HTML=$(patsubst src/%.md, tmp/%.content.html, $(SOURCES))
HTML=$(patsubst src/%.md, out/%.html, $(SOURCES))

BLOG_XML=$(patsubst src/%.md, tmp/%.xml, $(BLOG_SOURCES))

.PHONY: clean all
.SECONDARY: $(TMP_HTML)

all: $(HTML) $(RSS)

out/%.html: $(HEADER) tmp/%.content.html
	@mkdir -p $(@D)
	cat $^ > $@

tmp/%.content.html: src/%.md
	@mkdir -p $(@D)
	pandoc $(PANDOC_ARGS) $< > $@

$(RSS): $(BLOG_XML)
	@echo $@
	@echo '<rss version="2.0"><channel>' > $@
	@echo "<title>TODO</title><link>TODO</link><description>TODO</description>" >> $@
	@echo "<lastBuildDate>$$(date --rfc-email)</lastBuildDate>" >> $@
	cat $^ >> $@
	@echo '</channel></rss>' >> $@

tmp/%.xml: tmp/%.content.html
	@echo '<item>' > $@
	@echo "  <link>TODO</link>" >> $@
	@echo "  <pubDate>TODO</pubDate>" >> $@
	@echo "  <title>TODO</title>" >> $@
	@echo "  <description><![CDATA[" >> $@
	cat $< >> $@
	@echo "  ]]></description>" >> $@
	@echo '</item>' >> $@

clean:
	rm -rf tmp out