Files
jakstys.lt/scripts/Makefile.static

34 lines
657 B
Makefile

SRCS = $(wildcard *.html *.xml *.txt *.css *.map *.pdf)
ZSTD = $(patsubst %,%.zst,$(SRCS))
BR = $(patsubst %,%.br,$(SRCS))
GZ = $(patsubst %,%.gz,$(SRCS))
.PHONY: all
all: $(ZSTD) $(BR) $(GZ)
define MAKETARGET
$(1).br: $(1).xxhash
brotli -f $(1)
touch $(1).br
$(1).zst: $(1).xxhash
zstd -f -19 $(1)
touch $(1).zst
$(1).gz: $(1).xxhash
zopfli $(1)
touch $(1).gz
# https://github.com/gohugoio/hugo/issues/10842
$(1).xxhash: $(1)
current=$$$$(xxhsum $$< | cut -d' ' -f1); \
if [ ! -f $$< ] || [ "$$$$(cat $$@ 2>/dev/null)" != "$$$$current" ]; then \
echo "$$$$current" > $$@; \
fi
endef
$(foreach f,$(SRCS),$(eval $(call MAKETARGET,$(f))))