Files
libre-liberec-web/Makefile

63 lines
1.6 KiB
Makefile

EMIT_ASSETS := index.html 404.html info.html \
styles.css icons.css \
countdown.js theme.js theme.js \
stallman.webp stallman_2024.webp
SEARCH_REPLACE := lib/search_and_replace/target/release/search_and_replace
COMPONENTS := head.html header.html nav.html footer.html
.PHONY: build
build: $(EMIT_ASSETS:%=dst/cz/%) $(EMIT_ASSETS:%=dst/en/%) dst/favicon.ico
.PHONY: clean
clean:
rm -rf dst
$(SEARCH_REPLACE): $(shell find lib/search_and_replace/src)
cd lib/search_and_replace && cargo build --release
define make_page
cat $(1) | \
$(SEARCH_REPLACE) \
'<!--#include virtual="components/head.html" -->' "$$(cat components/$(3)/head.html)" \
'<!--#include virtual="components/header.html" -->' "$$(cat components/$(3)/header.html)" \
'<!--#include virtual="components/nav.html" -->' "$$(cat components/$(3)/nav.html)" \
'<!--#include virtual="components/footer.html" -->' "$$(cat components/$(3)/footer.html)" \
> $(2)
endef
dst/cz/%.html: cz_%.html $(SEARCH_REPLACE) $(COMPONENTS:%=components/cz/%)
@mkdir -p $(@D)
$(call make_page,$<,$@,cz)
dst/cz/%.css: %.css
@mkdir -p $(@D)
ln -f $< $@
dst/cz/%.js: js/%.js
@mkdir -p $(@D)
ln -f $< $@
dst/cz/%.webp: images/%.jpg
@mkdir -p $(@D)
magick $< $@
dst/en/%.html: en_%.html $(SEARCH_REPLACE) $(COMPONENTS:%=components/en/%)
@mkdir -p $(@D)
$(call make_page,$<,$@,en)
dst/en/%.css: %.css
@mkdir -p $(@D)
ln -f $< $@
dst/en/%.js: js/%.js
@mkdir -p $(@D)
ln -f $< $@
dst/en/%.webp: images/%.jpg
@mkdir -p $(@D)
magick $< $@
dst/favicon.ico: images/favicon.ico
@mkdir -p $(@D)
ln -f $< $@