# List of types which should be treated as X·M·L.
XMLTYPES := application/xml text/xml
+# The name of the generator program.
+GENERATOR := ⛩️📰 书社
+
+ifdef GIT
+ifneq ($(wildcard $(THISDIR)/.git),)
+# A description of the current git revision of ⛩️📰 书社.
+VERSION := $(shell cd $(THISDIR); $(GIT) describe 2> /dev/null || $(GIT) rev-parse HEAD 2> /dev/null || true)
+endif
+
+ifneq ($(wildcard .git),)
+# A description of the current git revision of the working directory.
+SRCREV := $(shell $(GIT) describe 2> /dev/null || $(GIT) rev-parse HEAD 2> /dev/null || true)
+endif
+endif
+
# Set to a non·empty value to print all commands as they run.
VERBOSE :=
# (overridable) Collect all of the applicable source files from the source directory, removing any which are also includes.
sourcefiles := $(filter-out $(sourceincludes),$(shell $(FIND) $(foreach dir,$(SRCDIR),$(call quote,$(dir))) '(' $(FINDRULES) ')' -a -type f))
-ifdef GIT
-ifneq ($(wildcard $(THISDIR)/.git),)
-# (overridable) The name of the current revision of ⛩️📰 书社, or its hash if the current revision is not a tag.
-thisrev = $(shell cd $(THISDIR); $(GIT) describe 2> /dev/null || $(GIT) rev-parse HEAD 2> /dev/null || true)
-endif
-
-ifneq ($(wildcard .git),)
-# (overridable) The name of the current revision of the working directory, or its hash if the current revision is not a tag.
-srcrev = $(shell $(GIT) describe 2> /dev/null || $(GIT) rev-parse HEAD 2> /dev/null || true)
-endif
-endif
-
# Figure out the file type of each source file and source include.
ifneq ($(wildcard $(BUILDDIR)/magic.mgc),)
override types := $(shell $(SED) 's/^ *//;s/ *$$//;s/ {2,}/ /g' <<< $(call quote,$(sourcefiles) $(sourceincludes)) | $(TR) ' ' '\n' | $(FILE) -m $(call quote,$(BUILDDIR)/magic.mgc) --mime-type --separator '|' --files-from - | $(SED) 's/| */|/g')
$(call parsed,$(sourcefiles) $(sourceincludes)) : % : $$(call unparsed,$$@) $(typeupdates)
@$(PRINTF) '%s\n' $(call quote,Processing `$<´…)
$(silent)$(call ensuredirectory,$(dir $@))
- $(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,<object xmlns="http://www.w3.org/1999/xhtml" type="$(call typeoffile,$<)" data="$(call datauri,$<)"/>) > $(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(CAT) $(call quote,$<)) | $(XSLTPROC) -o $(call quote,$@) --stringparam BUILDTIME '$(shell TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ')' --stringparam SRCTIME '$(shell TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call unparsed,$@)))'$(if $(thisrev), --stringparam VERSION $(call quote,$(thisrev)),)$(if $(srcrev), --stringparam SRCREV $(call quote,$(srcrev)),) $(call quote,$(BUILDDIR)/parser.xslt) -)
+ $(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,<object xmlns="http://www.w3.org/1999/xhtml" type="$(call typeoffile,$<)" data="$(call datauri,$<)"/>) > $(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(CAT) $(call quote,$<)) | $(XSLTPROC) -o $(call quote,$@) --stringparam BUILDTIME '$(shell TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ')' --stringparam SRCTIME '$(shell TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call unparsed,$@)))'$(if $(GENERATOR), --stringparam GENERATOR $(call quote,$(GENERATOR)))$(if $(VERSION), --stringparam VERSION $(call quote,$(VERSION)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/parser.xslt) -)
# Generate a catalog of all parsed files, for use when processing includes.
#
$(call compiled,$(compilablefiles)) : $(BUILDDIR)/public/% : $$(call parsed,$$(call uncompiled,$$@)) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@)))
$(silent)$(call ensuredirectory,$(dir $@))
@$(PRINTF) '%s\n' $(call quote,Compiling </$*>…)
- $(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam CATALOG 'catalog' --stringparam BUILDTIME '$(shell TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ')' --stringparam SRCTIME '$(shell TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call uncompiled,$@)))' --stringparam PATH $(call quote,/$*)$(if $(thisrev), --stringparam VERSION $(call quote,$(thisrev)),)$(if $(srcrev), --stringparam SRCREV $(call quote,$(srcrev)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
+ $(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam CATALOG 'catalog' --stringparam BUILDTIME '$(shell TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ')' --stringparam SRCTIME '$(shell TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call uncompiled,$@)))' --stringparam PATH $(call quote,/$*)$(if $(GENERATOR), --stringparam GENERATOR $(call quote,$(GENERATOR)))$(if $(VERSION), --stringparam VERSION $(call quote,$(VERSION)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
$(call compiled,$(filter $(assetfiles),$(sourcefiles))) : $(BUILDDIR)/public/% : $$(call uncompiled,$$@)
@$(PRINTF) '%s\n' $(call quote,Compiling </$*>…)
$(silent)$(call ensuredirectory,$(dir $@))
A white·space‐separated list of media types to consider X·M·L
(default: `application/xml text/xml`).
+- **`GENERATOR`:**
+ The name of the generator program (default: `⛩️📰 书社`).
+
+- **`VERSION`:**
+ The current version of `GENERATOR` (default: derived from the current
+ git tag/branch/commit).
+
+- **`SRCREV`:**
+ The current version of the source files (default: derived from the
+ current git tag/branch/commit).
+
- **`VERBOSE`:**
If this variable has a value, every recipe instruction will be
printed when it runs (default: empty).
- **`BUILDTIME`:**
The current time.
+- **`GENERATOR`:**
+ The value of the `GENERATOR` variable (if present).
+
- **`SRCREV`:**
- The tag or hash of the current commit in the working directory (if
- `GIT` is defined and `./.git` exists).
+ The value of the `SRCREV` variable (if present).
- **`SRCTIME`:**
The time at which the source file was last modified.
- **`VERSION`:**
- The tag or hash of the current commit in `THISDIR` (if `GIT` is
- defined and `$(THISDIR)/.git` exists).
+ The value of the `VERSION` variable (if present).
The following params are only available in transforms :—
<xslt:transform exclude-result-prefixes="catalog exsl exslstr" version="1.0">
<xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
<xslt:param name="CATALOG" select="'catalog'"/>
- <xslt:param name="SRCTIME" select="'1972-12-31T00:00:00Z'"/>
+ <xslt:param name="GENERATOR" select="false"/>
<xslt:param name="PATH" select="'/unknown'"/>
- <xslt:param name="VERSION" select="false"/>
<xslt:param name="SRCREV" select="false"/>
+ <xslt:param name="SRCTIME" select="'1972-12-31T00:00:00Z'"/>
+ <xslt:param name="VERSION" select="false"/>
<xslt:variable name="书社:expansion">
<xslt:apply-templates select="/" mode="书社:expand"/>
</xslt:variable>
</xslt:for-each>
</html:title>
<xslt:copy-of select="exsl:node-set($metadata)/node()[not(self::*) or not(self::html:title)]"/>
- <xslt:if test="not(exsl:node-set($metadata)/html:meta[@name='generator'])">
+ <xslt:if test="$GENERATOR and not(exsl:node-set($metadata)/html:meta[@name='generator'])">
<html:meta name="generator">
<xslt:attribute name="content">
- <xslt:text>⛩️📰 书社</xslt:text>
+ <xslt:value-of select="$GENERATOR"/>
<xslt:if test="$VERSION">
<xslt:text> (</xslt:text>
<xslt:value-of select="$VERSION"/>