diff options
author | Case Duckworth | 2022-05-19 11:49:53 -0500 |
---|---|---|
committer | Case Duckworth | 2022-05-19 11:49:53 -0500 |
commit | af52a71c9b2d6d66ff00fb39386d8d7a5330b2b0 (patch) | |
tree | d5cfca7f6ce469b45bf4c38e4d53ae22d7bfff0a /Makefile | |
download | hat-trick-af52a71c9b2d6d66ff00fb39386d8d7a5330b2b0.tar.gz hat-trick-af52a71c9b2d6d66ff00fb39386d8d7a5330b2b0.zip |
Initial commit
I'm doing content + generation in this ... who knows if it's smart, lol.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 88 |
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 | |||
4 | UPLOAD_TARGET = hetzner:/var/www/acdw.casa/ | ||
5 | |||
6 | SITE_TITLE = acdw.casa | ||
7 | |||
8 | INPUT = src | ||
9 | BUILD = build | ||
10 | LASTB = .last_build | ||
11 | |||
12 | HTAWK = ./ht.awk | ||
13 | HTSH = ./ht.sh | ||
14 | HTMK = ht.mk | ||
15 | HT = ${HTAWK} ${HTSH} ${HTMK} | ||
16 | |||
17 | T = .tmp | ||
18 | TMK = $T/mk | ||
19 | TPG = $T/ps | ||
20 | |||
21 | PTMPL = tmpl.page.htm | ||
22 | PTMPC = \ | ||
23 | <title>$$(title)</title> \ | ||
24 | $$(body) | ||
25 | PTMPR = \ | ||
26 | $$hb: $$ht ; \ | ||
27 | ${HTAWK} < '$$ht' | \ | ||
28 | env HTTMP='$T' HTENV='$T/\$$<.env' HTOUT='\$$@' \ | ||
29 | ${HTSH} '${PTMPL}' > '\$$@' | ||
30 | |||
31 | ITMPL = tmpl.index.htm | ||
32 | ITMPC = \ | ||
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> | ||
40 | ITMPR = \ | ||
41 | index.html: ${ITMPL} $$(cat ${TPG}); \ | ||
42 | env HTTMP='$T' HTOUT='\$$@' \ | ||
43 | ${HTSH} "${ITMPL}" < /dev/null > '\$$@' | ||
44 | |||
45 | TMPL = ${PTMPL} ${ITMPL} | ||
46 | BUILD_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 | ||
75 | clean: ; -rm -rf ${BUILD} ${HTMK} $T ${LASTB} | ||
76 | clean-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 | ||
83 | nuke: clean ; -rm ${TMPL} | ||
84 | |||
85 | .PHONY: publish | ||
86 | publish: build clean-build | ||
87 | scp -r ${BUILD}/* '${UPLOAD_TARGET}'; \ | ||
88 | |||