X-Git-Url: https://git.ladys.computer/Shrine-XSLT/blobdiff_plain/e56ab0f26f35e32120971057b6db350175672c90..820a47bd00e3b7d5a28b5392e1f2a56584c4a38e:/GNUmakefile diff --git a/GNUmakefile b/GNUmakefile index a6b7b4a..fd272ee 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -14,32 +14,36 @@ SHELL = /bin/sh # # ___ # -# © 2022 Lady [@ Lady’s Computer] +# © 2022–2023 Lady [@ Lady’s Computer] # # This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. # If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. BASEIRI = http://example.com DATETIME = $(shell date -Iseconds) +FEED_EXT = .atom +SOURCE_EXT = .xml TRANSFORM = transform.xslt XSLT = xsltproc XSLTOPTS = +YIELD = cat +YIELD_DEPENDENCIES = headers := $(wildcard *-header.xml) footers := $(wildcard *-footer.xml) -override prerequisites := $(TRANSFORM) $(headers) $(footers) +override prerequisites := $(YIELD_DEPENDENCIES) template.xml $(TRANSFORM) $(headers) $(footers) -override indexsources := $(wildcard sources/index.xml sources/index-*.xml) -override indices := $(patsubst sources/%.xml,public/%.html,$(indexsources)) +override indexsources := $(wildcard sources/index$(SOURCE_EXT) sources/index-*$(SOURCE_EXT)) +override indices := $(patsubst sources/%$(SOURCE_EXT),public/%.html,$(indexsources)) -override pagesources := $(filter-out $(indexsources),$(wildcard sources/*.xml sources/*/*.xml)) -override pages := $(patsubst sources/%.xml,public/%/index.html,$(pagesources)) +override pagesources := $(filter-out $(indexsources),$(wildcard sources/*$(SOURCE_EXT) sources/*/*$(SOURCE_EXT))) +override pages := $(patsubst sources/%$(SOURCE_EXT),public/%/index.html,$(pagesources)) override resourcesources := $(wildcard $(addsuffix /*,$(basename $(pagesources)))) override resources := $(patsubst sources/%,public/%,$(resourcesources)) -override feedsources := $(filter-out $(resourcesources),$(wildcard sources/*.atom sources/*/*.atom)) -override feeds := $(patsubst sources/%.atom,public/%.atom,$(feedsources)) +override feedsources := $(filter-out $(resourcesources),$(wildcard sources/*$(FEED_EXT) sources/*/*$(FEED_EXT))) +override feeds := $(patsubst sources/%$(FEED_EXT),public/%.atom,$(feedsources)) override content := $(indices) $(pages) @@ -52,19 +56,20 @@ override content := $(indices) $(pages) # • Removes any doctype for root elements other than `html` (with `grep -v`). # # • Saves the output to `$(2)`. -override makexslt = $(XSLT) --nonet --novalid $(XSLTOPTS) --stringparam BASEIRI "$(BASEIRI)" --stringparam DATETIME "$(DATETIME)" --stringparam OUTPUTPATH "$(patsubst public/%,/%,$(2))" transform.xslt $(1)\ +override makexslt = $(YIELD) $(1)\ + | $(XSLT) --nonet --novalid $(XSLTOPTS) --stringparam BASEIRI "$(BASEIRI)" --stringparam DATETIME "$(DATETIME)" --stringparam OUTPUTPATH "$(patsubst public/%,/%,$(2))" transform.xslt -\ $(if $(filter %.html,$(2)),| sed 's/ xmlns:[0-9A-Za-z_-]*="[^"]*"//g',)\ | grep -v '^]\)'\ > $(2) all: $(content) $(resources) $(feeds); -$(indices): public/%.html: sources/%.xml $(prerequisites) +$(indices): public/%.html: sources/%$(SOURCE_EXT) $(prerequisites) @echo "Generating $@…" @mkdir -p $(dir $@) @$(call makexslt,$<,$@) -$(pages): public/%/index.html: sources/%.xml $(prerequisites) +$(pages): public/%/index.html: sources/%$(SOURCE_EXT) $(prerequisites) @echo "Generating $@…" @mkdir -p $(dir $@) @$(call makexslt,$<,$@) @@ -74,7 +79,7 @@ $(resources): public/%: sources/% @mkdir -p $(dir $@) @cp $< $@ -$(feeds): public/%.atom: sources/%.atom $(TRANSFORM) +$(feeds): public/%.atom: sources/%$(FEED_EXT) $(TRANSFORM) @echo "Generating $@…" @mkdir -p $(dir $@) @$(call makexslt,$<,$@)