about summary refs log tree commit diff stats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile88
1 files changed, 88 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5b3cadd --- /dev/null +++ b/Makefile
@@ -0,0 +1,88 @@
1## HAT TRICK -*- tab-width: 8; -*-
2# (C) 2022 C. Duckworth
3
4UPLOAD_TARGET = hetzner:/var/www/acdw.casa/
5
6SITE_TITLE = acdw.casa
7
8INPUT = src
9BUILD = build
10LASTB = .last_build
11
12HTAWK = ./ht.awk
13HTSH = ./ht.sh
14HTMK = ht.mk
15HT = ${HTAWK} ${HTSH} ${HTMK}
16
17T = .tmp
18TMK = $T/mk
19TPG = $T/ps
20
21PTMPL = tmpl.page.htm
22PTMPC = \
23 <title>$$(title)</title> \
24 $$(body)
25PTMPR = \
26 $$hb: $$ht ; \
27 ${HTAWK} < '$$ht' | \
28 env HTTMP='$T' HTENV='$T/\$$<.env' HTOUT='\$$@' \
29 ${HTSH} '${PTMPL}' > '\$$@'
30
31ITMPL = tmpl.index.htm
32ITMPC = \
33 <title>${SITE_TITLE}</title> \
34 <ul id="idx"> \
35 $$(for p in "$T"/*.env; do \
36 . "$$p"; \
37 print "<li><a href=\"$$HTOUT\">$$(title)</a></li>"; \
38 done) \
39 </ul>
40ITMPR = \
41 index.html: ${ITMPL} $$(cat ${TPG}); \
42 env HTTMP='$T' HTOUT='\$$@' \
43 ${HTSH} "${ITMPL}" < /dev/null > '\$$@'
44
45TMPL = ${PTMPL} ${ITMPL}
46BUILD_INPUTS = ${INPUT}/* ${TMPL} ${HT}
47
48${BUILD}: ${BUILD_INPUTS}
49 @touch ${LASTB}
50 @mkdir -p ${BUILD}
51 cp -a ${BUILD_INPUTS} $@
52 ${MAKE} -C $@ -f ${HTMK} build
53
54${HTMK}: Makefile ${INPUT}/*.ht $T
55 @printf '%s' 'Generating "$@"...'
56 @: > '$@'
57 @: > '${TPG}'
58
59 @for ht in $$(find ${INPUT} -type f -name '*.ht'); do \
60 ht="$$(echo "$$ht" | sed 's#${INPUT}/##')"; \
61 hb="$${ht}ml"; \
62 printf '%s ' "$$hb" >> "${TPG}"; \
63 printf '%s\n' "${PTMPR}"; \
64 done >> '$@'
65
66 @printf '%s\n' "${ITMPR}" >> '$@'
67 @printf "build: $$(cat ${TPG}) index.html" >> '$@'
68 @printf '%s\n' 'done'
69
70$T: ; mkdir -p "$@"
71${PTMPL}: ; printf '${PTMPC}' > '$@'
72${ITMPL}: ; printf '${ITMPC}' > '$@'
73
74.PHONY: clean clean-build nuke
75clean: ; -rm -rf ${BUILD} ${HTMK} $T ${LASTB}
76clean-build:
77 rm -rf '${BUILD}/$T'
78 for file in ${BUILD}/*; do \
79 case "$$file" in \
80 *.ht|*.sh|*.htm|*.mk|*.awk) rm -rf "$$file" ;; \
81 esac \
82 done
83nuke: clean ; -rm ${TMPL}
84
85.PHONY: publish
86publish: build clean-build
87 scp -r ${BUILD}/* '${UPLOAD_TARGET}'; \
88