blob: 39fe7cbfe670e1755c3075a57ce9d2ab2eabab5a (
plain)
1 CCOPTS = --std=gnu99 -Wall -Werror -O2
2 .PHONY: src
3
4 all:
5 $(error Must specify a target (adoc, rst, or src))
6
7 validate:
8 ifndef SRC
9 $(error Variable SRC must be defined)
10 endif
11 ifndef DEST
12 $(error Variable DEST must be defined)
13 endif
14
15 adoc: validate
16 printf '<h1>%s</h1>\n' "$(shell head -n1 $(SRC))" > "$(DEST)"
17 asciidoc -s \
18 -a sectlinks \
19 -b html5 \
20 -o - "$(SRC)" >> "$(DEST)"
21
22 rst: validate
23 rst2html5.py \
24 --initial-header-level=2 \
25 --cloak-email-addresses \
26 --template "res/rst_template.txt" "$(SRC)" "$(DEST)"
27 printf '<div class="paragraph datelastedit"><p>Last edited: %s</p></div>\n' \
28 "$(shell date '+%F %T %Z')" >> "$(DEST)"
29
30 md: validate
31 cmark --to html "$(SRC)" > "$(DEST)"
32 printf '<div class="paragraph datelastedit"><p>Last edited: %s</p></div>\n' \
33 "$(shell date '+%F %T %Z')" >> "$(DEST)"
34
35 src:
36 if [ ! -d obj ]; then mkdir obj; fi
37 cc $(CCOPTS) src/common.c -c -o obj/common.o
38 cc $(CCOPTS) src/cgi.c -c -o obj/cgi.o
39 cc $(CCOPTS) src/j2.c -c -o obj/j2.o
40 cc $(CCOPTS) src/main.c obj/*.o -o index
41
42 test: src
43 if [ ! -d tests/obj ]; then mkdir tests/obj; fi
44 cc $(CCOPTS) tests/assert.c -c -o tests/obj/assert.o
45 cc $(CCOPTS) obj/*.o tests/obj/*.o tests/main.c -o tests/runtests
46 tests/runtests
47
48 clean:
49 if [ -d obj ]; then rm -r obj/*; fi
50 rm -f index
|