path:
/Makefile
2.29 KB | 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
.ONESHELL:
templates=head.html header.html footer.html
pages=index.html privacy.html 404.html
deploy-path=lighttpd@saikrupagas.com:/srv/www/saikrupagas.com/
# Explicit allowlist of what actually belongs on the live site -- NOT
# `git ls-files`, which would ship every tracked file in the repo
# (internal tooling, dev configs, build scripts, anything else that
# happens to be checked in) straight to production. head.json and
# html/components/*.html are deliberately excluded -- they're only ever
# pulled in via m4 include() at build time, never fetched at runtime.
# This same list drives both `deploy-src` (scp to production) and `dist`
# (a local servable folder) -- one source of truth for "what's the site".
deploy-files=$(pages) css js robots.txt sitemap.xml favicon.ico \
gl4xcy2rrdndf2uq9crpfq2oelee7w.html styles vendor
HOST_PORT=8000
LIVESIDE_PORT=8001
DIST=dist
dev-all: M4FLAGS = -D LIVERELOAD=1 -D LIVESIDE_PORT=$(LIVESIDE_PORT)
dev-all: $(pages)
# m4's include() resolves bare names (`header.html`, not `html/header.html`
# -- that's how every .html.in under html/ writes it) against m4's own
# current directory, not the including file's directory. So rather than
# rewrite every include() path, just run m4 with html/ as its cwd and
# send the output back up to the repo root, where it's served from.
html/head.html: html/head.html.in
cd html && m4 $(M4FLAGS) head.html.in > head.html
%.html: html/%.html.in $(addprefix html/,$(templates))
cd html && m4 $(M4FLAGS) $*.html.in > ../$*.html
all: $(pages)
autorefresh:
darkhttpd . --port $(HOST_PORT) &
liveside -d . -p $(LIVESIDE_PORT) -c "make dev-all"
host:
darkhttpd . --port $(HOST_PORT)
refresh: all
liveside -d . -p $(LIVESIDE_PORT) -c "make dev-all"
deploy-src: clean all
scp -Cr $(deploy-files) $(deploy-path)
deploy-assets:
scp -Cr assets $(deploy-path)
deploy: deploy-src deploy-assets
clean:
-rm html/head.html $(foreach page,$(pages),$(page))
# A single self-contained, servable folder -- everything deploy-src/
# deploy-assets would ship to production, gathered in one place instead.
# Point any static server at it: `darkhttpd $(DIST) --port 8000`.
dist: clean all
rm -rf $(DIST)
mkdir -p $(DIST)
cp -R $(deploy-files) $(DIST)/
cp -R assets $(DIST)/
.PHONY: all dev-all autorefresh host refresh deploy-src deploy-assets deploy clean dist