X-Git-Url: https://git.ladys.computer/Shushe/blobdiff_plain/c569812a7a7d6239cd1c41855d4f1fc5fa5f15a4..0aeeb8d8b0d68101369950808d206f02e9367607:/GNUmakefile?ds=sidebyside diff --git a/GNUmakefile b/GNUmakefile index 1603aef..ab8e828 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -10,7 +10,7 @@ override define makefileinfo ║│ Requires G·N·U Make, at least version 3.81, a version of │║ ║│ uuencode with base64 support, and the various programs │║ ║│ offered by libxml2 and libxslt. Beyond this, only programs │║ -║│ required by Posix are used, altho there is a chance of │║ +║│ required by Posix are required, altho there is a chance of │║ ║│ version incompatibilities. The full list of program │║ ║│ requirements is as follows :— │║ ║│ │║ @@ -21,6 +21,7 @@ override define makefileinfo ║│ • echo │║ ║│ • file │║ ║│ • find │║ +║│ • git (optional) │║ ║│ • mkdir (requires support for `-p´) │║ ║│ • mv │║ ║│ • od (requires support for `-t x1´) │║ @@ -89,6 +90,7 @@ DATE := date ECHO := echo FILE := file FIND := find +GIT := git MKDIR := mkdir MV := mv OD := od @@ -229,6 +231,20 @@ sourceincludes := $(shell $(FIND) $(FINDOPTS) $(INCLUDEDIR) -type f '(' $(FINDRU # source directory, removing any which are also includes. sourcefiles := $(filter-out $(sourceincludes),$(shell $(FIND) $(FINDOPTS) $(SRCDIR) -type f '(' $(FINDRULES) ')')) +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) +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) +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') @@ -453,7 +469,7 @@ $(BUILDDIR)/parser.xslt: $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2parse $(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,) > $(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(CAT) $(call quote,$<)) | $(XSLTPROC) -o $(call quote,$@) $(call quote,$(BUILDDIR)/parser.xslt) -) + $(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,) > $(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) -) # Generate a catalog of all parsed files, for use when processing # includes. This does not depend on actually transforming the files. @@ -487,7 +503,7 @@ $(BUILDDIR)/transform.xslt: $(BUILDDIR)/transform.catalog $(THISDIR)/lib/catalog $(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,/$*) $(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 $(thisrev), --stringparam VERSION $(call quote,$(thisrev)),)$(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 $@))