-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
64 lines (51 loc) · 1.64 KB
/
Makefile
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
# Static site generator using Make and m4
#
# Workflow -> .md -> .mdhtml/.m4f -> .html
#
# The intermediary step provides an opportunity to use m4 to _generate_
# markdown before converting it to HTML and then uses m4 again to insert the
# new HTML into the site template. The frozen m4 files cache metadata to avoid
# needing to reprocess the whole file.
.PHONY: init printline deploy
.SUFFIXES: .m4f .mdhtml .md .rst .html
.PRECIOUS: %.mdhtml
SRC = $(filter-out 20%/index.md, $(wildcard 20*/*.md))
INT = $(SRC:%.md=%.mdhtml)
MTA = $(SRC:%.md=%.m4f)
DST = $(SRC:%.md=%.html)
IDX = index.html categories.html $(addsuffix /index.html, $(wildcard 20*))
all: init $(DST) _metadata_cache $(IDX) rss.xml
%.html: %.mdhtml %.m4f _template.html
m4 -R "$(F).m4f" _template.m4 "$(F).mdhtml" > "$@"
%.mdhtml %.m4f: %.md
m4 -P _macros.m4 "$^" -F "$(F).m4f" \
| multimarkdown > "$(F).mdhtml"
%.m4f: %.mdhtml
%.html %.mdhtml %.m4f: F = $(basename $@)
_metadata_cache: $(MTA)
rm -f $@
for file in $^; do \
m4 -R $$file _metadata_cache.m4 >> _metadata_cache; \
done
$(IDX): _metadata_cache
rss.xml: _metadata_cache _make_rss.sh
./_make_rss.sh | m4 -P _macros.m4 - > $@
deploy: all
mkdir -p public
cp -r base.css categories.html index.html rss.xml 20* public
git checkout --orphan glpages glpages-init
git add public
git commit -m "Add site build"
git checkout master
git push -f gitlab glpages
git branch -D glpages
init:
@command -v m4 > /dev/null 2>&1 \
|| (echo 'Missing m4' && exit 1)
clean:
rm -f $(DST) $(INT) $(MTA) \
$(IDX) $(IDX:%.html=%.m4f) $(IDX:%.html=%.mdhtml) \
_metadata_cache rss.xml
rm -rf public
printline:
@echo $(INT)