summaryrefslogtreecommitdiff
path: root/Makefile
blob: 1c5468db77f7eb1d483e698fd057d64ffe3aa497 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
MAKEFLAGS += -R -r
HTML_MINIFIER_FLAGS += \
	--collapse-boolean-attributes \
	--collapse-whitespace \
	--decode-entities \
	--minify-css \
	--minify-js '{"mangle": {"eval": true}}' \
	--remove-attribute-quotes \
	--remove-comments \
	--remove-optional-tags \
	--remove-redundant-attributes \
	--sort-attributes \
	--sort-class-name \
	--ignore-custom-fragments 'clamp([^;]*);' \
	--trim-custom-fragments

WFS ?= ~/wfs/wfs.py
WFS_FLAGS += \
	--desubroutinize \
	--layout-scripts=latn \
	--layout-features-=frac,locl \
	--name-IDs= \
	--drop-tables+=gasp,prep

deployhosts := pink red blue

fonts := resume/EBGaramond-Italic.otf resume/EBGaramond-Regular.otf resume/EBGaramond-Medium.otf
fontssubset := $(fonts:.otf=.subset.woff2)

staticall := $(patsubst static/%,out/%,$(shell find static))
staticdirs := $(sort $(dir $(staticall)))
staticfiles := $(filter-out $(staticdirs),$(staticall))

tocomp := $(filter %.txt %.html %.js %.css,$(staticfiles)) out/resume/index.html

all: $(staticall) out/resume $(tocomp:=.br) $(tocomp:=.gz)

out/%: static/%
	install -Dpm644 $< $@

%.br: %
	brotli -Zc $< > $@

%.gz: %
	zopfli -c $< > $@

$(staticdirs) out/resume &:
	mkdir -p $@

out/%.html: static/%.html | $(@D)
	html-minifier $(HTML_MINIFIER_FLAGS) $< -o $@

out/resume/index.html: resume/resume.html resume/resume.js resume/resume.css $(fontssubset) | out/resume
	./inliner.py $< | html-minifier $(HTML_MINIFIER_FLAGS) > $@

$(fontssubset) &: resume/resume.html $(fonts)
	cd $(<D) && $(WFS) \
		--font 'EBGaramond-Italic.otf:EB Garamond:400:italic' \
		--font 'EBGaramond-Regular.otf:EB Garamond:400:normal' \
		--font 'EBGaramond-Medium.otf:EB Garamond:500:normal' \
		$(WFS_FLAGS) $(<F)

deploy: $(patsubst %,deploy-%,$(deployhosts))

deploy-%:
	rsync -e 'ssh -oVisualHostKey=no' -av --delete out/ $*.alxu.ca:public_html/

define check
check-$(subst :,_,$(1)):
	curl -sS --compressed --resolve www.alxu.ca:443:$(1) https://www.alxu.ca/resume/ | cmp - out/resume/index.html
check: check-$(subst :,_,$(1))
endef

$(foreach ip,$(shell getent ahosts www.alxu.ca | awk '/STREAM/{print $$1}'),$(eval $(call check,$(ip))))

clean:
	rm -rf out
	rm -f $(fontssubset)

.DELETE_ON_ERROR:
.PHONY: all clean deploy