]> Lady’s Gitweb - Shrine-XSLT/blob - GNUmakefile
Copy over data files from sources/
[Shrine-XSLT] / GNUmakefile
1 SHELL = /bin/sh
2
3 # This GNUmakefile searches the `sources/` directory for files with an extension of `.xml` and applies `transform.xslt` to them, outputting the result in one of two locations :—
4 #
5 # • For files with a location of `sources/index.xml` or `sources/index-*.xml`, the transformed file will be written to `public/%.html` (where `%` is the filename).
6 #
7 # • For all other files with a location of `sources/*.xml` or `sources/*/*.xml`, the transformed file will be written to `public/%/index.html` (where `%` is the filename and subdirectory if applicable).
8 # Other files in the corresponding directory (i·e without the `.xml`) are copied over verbatim.
9 # Only one level of subdirectory is supported.
10 #
11 # By default, running `make` will do this for all applicable source files.
12 #
13 # ___
14 #
15 # © 2022 Lady [@ Lady’s Computer]
16 #
17 # This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
18 # If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
19
20 XSLT = xsltproc
21 XSLTOPTS =
22
23 headers := $(wildcard *-header.xml)
24 footers := $(wildcard *-footer.xml)
25 override prerequisites := transform.xslt $(headers) $(footers)
26
27 override indexsources := $(wildcard sources/index.xml sources/index-*.xml)
28 override indices := $(patsubst sources/%.xml,public/%.html,$(indexsources))
29
30 override pagesources := $(filter-out $(indexsources),$(wildcard sources/*.xml sources/*/*.xml))
31 override pages := $(patsubst sources/%.xml,public/%/index.html,$(pagesources))
32
33 override resourcesources := $(wildcard $(addsuffix /*,$(basename $(pagesources))))
34 override resources := $(patsubst sources/%,public/%,$(resourcesources))
35
36 override content := $(indices) $(pages)
37
38 override makexslt = $(XSLT) --nonet --novalid $(XSLTOPTS) -o $(2) transform.xslt $(1)
39
40 all: $(content) $(resources);
41
42 $(indices): public/%.html: sources/%.xml $(prerequisites)
43 @echo "Generating $@…"
44 @$(call makexslt,$<,$@)
45
46 $(pages): public/%/index.html: sources/%.xml $(prerequisites)
47 @echo "Generating $@…"
48 @$(call makexslt,$<,$@)
49
50 $(resources): public/%: sources/%
51 @echo "Copying over $@…"
52 @mkdir -p $(dir $<)
53 @cp $< $@
54
55 .PHONY: all ;
This page took 0.120205 seconds and 5 git commands to generate.