Some of these variables are still hardcoded into `transform.xslt`, so
it’s not enough to just change them in the `GNUmakefile`. However, they
should be much easier to adjust now.
BASEIRI = http://example.com
DATETIME = $(shell date -Iseconds)
FEED_EXT = .atom
BASEIRI = http://example.com
DATETIME = $(shell date -Iseconds)
FEED_EXT = .atom
+FOOTER_SUFFIX = -footer.xml
+HEADER_SUFFIX = -header.xml
+OUTPUT_DIR = public
+SOURCE_DIR = sources
TRANSFORM = transform.xslt
XSLT = xsltproc
XSLTOPTS =
YIELD = cat
YIELD_DEPENDENCIES =
TRANSFORM = transform.xslt
XSLT = xsltproc
XSLTOPTS =
YIELD = cat
YIELD_DEPENDENCIES =
-headers := $(wildcard *-header.xml)
-footers := $(wildcard *-footer.xml)
-override prerequisites := $(YIELD_DEPENDENCIES) template.xml $(TRANSFORM) $(headers) $(footers)
+headers := $(wildcard *$(HEADER_SUFFIX))
+footers := $(wildcard *$(FOOTER_SUFFIX))
+override prerequisites := $(YIELD_DEPENDENCIES) $(TEMPLATE) $(TRANSFORM) $(headers) $(footers)
-override indexsources := $(wildcard sources/index$(SOURCE_EXT) sources/index-*$(SOURCE_EXT))
-override indices := $(patsubst sources/%$(SOURCE_EXT),public/%.html,$(indexsources))
+override indexsources := $(wildcard $(SOURCE_DIR)/index$(SOURCE_EXT) $(SOURCE_DIR)/index-*$(SOURCE_EXT))
+override indices := $(patsubst $(SOURCE_DIR)/%$(SOURCE_EXT),$(OUTPUT_DIR)/%.html,$(indexsources))
-override pagesources := $(filter-out $(indexsources),$(wildcard sources/*$(SOURCE_EXT) sources/*/*$(SOURCE_EXT)))
-override pages := $(patsubst sources/%$(SOURCE_EXT),public/%/index.html,$(pagesources))
+override pagesources := $(filter-out $(indexsources),$(wildcard $(SOURCE_DIR)/*$(SOURCE_EXT) $(SOURCE_DIR)/*/*$(SOURCE_EXT)))
+override pages := $(patsubst $(SOURCE_DIR)/%$(SOURCE_EXT),$(OUTPUT_DIR)/%/index.html,$(pagesources))
override resourcesources := $(wildcard $(addsuffix /*,$(basename $(pagesources))))
override resourcesources := $(wildcard $(addsuffix /*,$(basename $(pagesources))))
-override resources := $(patsubst sources/%,public/%,$(resourcesources))
+override resources := $(patsubst $(SOURCE_DIR)/%,$(OUTPUT_DIR)/%,$(resourcesources))
-override feedsources := $(filter-out $(resourcesources),$(wildcard sources/*$(FEED_EXT) sources/*/*$(FEED_EXT)))
-override feeds := $(patsubst sources/%$(FEED_EXT),public/%.atom,$(feedsources))
+override feedsources := $(filter-out $(resourcesources),$(wildcard $(SOURCE_DIR)/*$(FEED_EXT) $(SOURCE_DIR)/*/*$(FEED_EXT)))
+override feeds := $(patsubst $(SOURCE_DIR)/%$(FEED_EXT),$(OUTPUT_DIR)/%.atom,$(feedsources))
override content := $(indices) $(pages)
# This function does the following :—
#
override content := $(indices) $(pages)
# This function does the following :—
#
-# • Calls `transform.xslt` with the `$(1)`, providing `$(BASEIRI)` and `$(DATETIME) as params and providing `$(2)` (minus the initial `public/`) as the param `OUTPUTPATH`.
+# • `$(YIELD)`s `$(1)`.
+#
+# • Calls `$(XSLT)` using `$(TRANSFORM)` with the result, providing `$(BASEIRI)` and `$(DATETIME) as params and providing `$(2)` (minus the initial `$(OUTPUT_DIR)/`) as the param `OUTPUTPATH`.
#
# • Removes any `xmlns` prefix declarations from output to `.html` files (with `sed`).
#
#
# • Removes any `xmlns` prefix declarations from output to `.html` files (with `sed`).
#
#
# • Saves the output to `$(2)`.
override makexslt = $(YIELD) $(1)\
#
# • Saves the output to `$(2)`.
override makexslt = $(YIELD) $(1)\
- | $(XSLT) --nonet --novalid $(XSLTOPTS) --stringparam BASEIRI "$(BASEIRI)" --stringparam DATETIME "$(DATETIME)" --stringparam OUTPUTPATH "$(patsubst public/%,/%,$(2))" transform.xslt -\
+ | $(XSLT) --nonet --novalid $(XSLTOPTS) --stringparam BASEIRI "$(BASEIRI)" --stringparam DATETIME "$(DATETIME)" --stringparam OUTPUTPATH "$(patsubst $(OUTPUT_DIR)/%,/%,$(2))" $(TRANSFORM) -\
$(if $(filter %.html,$(2)),| sed 's/ xmlns:[0-9A-Za-z_-]*="[^"]*"//g',)\
| grep -v '^<!DOCTYPE \([^h]\|.[^t]\|..[^m]\|...[^l]\|....[^ >]\)'\
> $(2)
all: $(content) $(resources) $(feeds);
$(if $(filter %.html,$(2)),| sed 's/ xmlns:[0-9A-Za-z_-]*="[^"]*"//g',)\
| grep -v '^<!DOCTYPE \([^h]\|.[^t]\|..[^m]\|...[^l]\|....[^ >]\)'\
> $(2)
all: $(content) $(resources) $(feeds);
-$(indices): public/%.html: sources/%$(SOURCE_EXT) $(prerequisites)
+$(indices): $(OUTPUT_DIR)/%.html: $(SOURCE_DIR)/%$(SOURCE_EXT) $(prerequisites)
@echo "Generating $@…"
@mkdir -p $(dir $@)
@$(call makexslt,$<,$@)
@echo "Generating $@…"
@mkdir -p $(dir $@)
@$(call makexslt,$<,$@)
-$(pages): public/%/index.html: sources/%$(SOURCE_EXT) $(prerequisites)
+$(pages): $(OUTPUT_DIR)/%/index.html: $(SOURCE_DIR)/%$(SOURCE_EXT) $(prerequisites)
@echo "Generating $@…"
@mkdir -p $(dir $@)
@$(call makexslt,$<,$@)
@echo "Generating $@…"
@mkdir -p $(dir $@)
@$(call makexslt,$<,$@)
-$(resources): public/%: sources/%
+$(resources): $(OUTPUT_DIR)/%: $(SOURCE_DIR)/%
@echo "Copying over $@…"
@mkdir -p $(dir $@)
@cp $< $@
@echo "Copying over $@…"
@mkdir -p $(dir $@)
@cp $< $@
-$(feeds): public/%.atom: sources/%$(FEED_EXT) $(TRANSFORM)
+$(feeds): $(OUTPUT_DIR)/%.atom: $(SOURCE_DIR)/%$(FEED_EXT) $(TRANSFORM)
@echo "Generating $@…"
@mkdir -p $(dir $@)
@$(call makexslt,$<,$@)
@echo "Generating $@…"
@mkdir -p $(dir $@)
@$(call makexslt,$<,$@)