about summary refs log tree commit diff stats
path: root/Makefile
blob: 526c21dc3e6c04bbffbe21465faae850f1bde3ff (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
82
83
84
85
86
87
88
89
90
91
92
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
.DELETE_ON_ERROR:

brotli := @brotli --force --no-copy-stat
gzip := @gzip --best --keep --force
zstd := @zstd --force --no-pass-through -19 --quiet --stdout
pr   := @printf "%4s %s\n"

format: .formatstamp

.formatstamp:
	@echo "Formatting HTML..."
	@prettier --write --parser html --print-width 120 "public/**/*.html" > /dev/null
	@touch .formatstamp

clean:
	rm -rf ./public
	rm -rf ./.*stamp

to_compress := $(shell fd --hidden . public --type=file -e html -e xml -e xsl -e txt -e asc)
brotli_files := $(patsubst %, %.br, $(to_compress))
gzip_files := $(patsubst %, %.gz, $(to_compress))
zstd_files := $(patsubst %, %.zst, $(to_compress))

%.html.br: %.html
	@echo $@
	$(brotli) $<

%.xml.br: %.xml
	@echo $@
	$(brotli) $<

%.xsl.br: %.xsl
	@echo $@
	$(brotli) $<

%.txt.br: %.txt
	@echo $@
	$(brotli) $<

%.asc.br: %.asc
	@echo $@
	$(brotli) $<

%.html.gz: %.html
	@echo $@
	$(gzip) $<

%.xml.gz: %.xml
	@echo $@
	$(gzip) $<

%.xsl.gz: %.xsl
	@echo $@
	$(gzip) $<

%.txt.gz: %.txt
	@echo $@
	$(gzip) $<

%.asc.gz: %.asc
	@echo $@
	$(gzip) $<

%.html.zst: %.html
	@echo $@
	$(zstd) $< > $@

%.xml.zst: %.xml
	@echo $@
	$(zstd) $< > $@

%.xsl.zst: %.xsl
	@echo $@
	$(zstd) $< > $@

%.txt.zst: %.txt
	@echo $@
	$(zstd) $< > $@

%.asc.zst: %.asc
	@echo $@
	$(zstd) $< > $@

compress: .compressstamp

.compressstamp: .formatstamp $(brotli_files) $(gzip_files) $(zstd_files)
	@echo "Compressing output files..."
	@touch .compressstamp

.PHONY: all clean format compress