summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-10-03 15:03:42 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-10-03 15:03:42 -0400
commit7dccf6e8684f767b6e377d627b36ccf493947f1e (patch)
tree4859d4e1a24ea2028de1366bc59cd28e6782a6d1 /Makefile
downloadalxu.ca-7dccf6e8684f767b6e377d627b36ccf493947f1e.tar.xz
alxu.ca-7dccf6e8684f767b6e377d627b36ccf493947f1e.zip
Initial commit
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile82
1 files changed, 82 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e813d30
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,82 @@
+MAKEFLAGS += -R -r
+HTML_MINIFIER_FLAGS := \
+ --collapse-boolean-attributes \
+ --collapse-whitespace \
+ --decode-entities \
+ --minify-css \
+ --minify-js \
+ --remove-attribute-quotes \
+ --remove-comments \
+ --remove-optional-tags \
+ --remove-redundant-attributes \
+ --remove-tag-whitespace \
+ --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
+
+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
+
+fonts := resume/EBGaramond-Italic.otf resume/EBGaramond-Regular.otf resume/EBGaramond-Medium.otf
+fontssubset := $(fonts:.otf=.subset.woff2)
+
+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