ββ β’ touch ββ
ββ β’ tr (requires support for `-dΒ΄) ββ
ββ β’ uuencode (requires support for `-mΒ΄ and `-rΒ΄) ββ
+ββ β’ uudecode (requires support for `-mΒ΄ and `-rΒ΄) ββ
ββ β’ xargs (requires support for `-0Β΄) ββ
ββ β’ xmlcatalog (provided by libxml2) ββ
ββ β’ xmllint (provided by libxml2) ββ
TEST := test
TOUCH := touch
TR := tr
+UUDECODE := uudecode
UUENCODE := uuencode
XARGS := xargs
XMLCATALOG := xmlcatalog
override destination = $(foreach file,$1,$(patsubst $(file)|%,%,$(filter $(file)|%,$(sourcedestinationpair))))
# Pair each source file with its compiled location.
-override sourcecompiledpair := $(foreach file,$(sourcefiles),$(file)|$(BUILDDIR)/public/$(call destination,$(file)))
+override sourcecompiledpair := $(foreach file,$(sourcefiles),$(file)|$(BUILDDIR)/results/$(call destination,$(file)))
# (callable) Get the location of the transformed XΒ·MΒ·L files for the given source files.
override compiled = $(foreach file,$1,$(patsubst $(file)|%,%,$(filter $(file)|%,$(sourcecompiledpair))))
# (callable) Get the source files for the given compiled file.
override uncompiled = $(foreach file,$1,$(patsubst %|$(file),%,$(filter %|$(file),$(sourcecompiledpair))))
+# (callable) Get the location of the final built file for the given source files.
+override built = $(foreach file,$1,$(patsubst $(BUILDDIR)/results/%,$(BUILDDIR)/public/%,$(call compiled,$(file))))
+
# (callable) Get the installed locations for the given source files.
override installed = $(foreach file,$1,$(DESTDIR)/$(call destination,$(file)))
endif
# This isnβt a perfect substitution (it makes some assumptions about the format of the underlying XΒ·MΒ·L), but it should be workable for most sensible, welformed files.
override serializexml = $(SED) "$$($(PRINTF) '%b' '/<?xml[ \t]\\{1,\\}version=[\0042\0047]1.1/,$${ s/<?xml[^>]*?>/<!--<?xml version=\00421.1\0042?>-->/\n s/&\0043x0*[1-8BCEFbcef];/\0302\0221/g\n s/&\0043x0*1[0-9A-Fa-f];/\0302\0221/g\n s/&\00430*[1-8];/\0302\0221/g\n s/&\00430*1[124-9];/\0302\0221/g\n s/&\00430*2[0-9];/\0302\0221/g\n s/&\00430*3[01];/\0302\0221/g\n}')" < $(call quote,$1) | $(SED) "$$(PRINTF '%b' ':a\n/^\\n*$$/{ $$d\n N\n ba\n}')"
+# (callable) Test if the provided xpath expression matches the provided document.
+override xpath = $(XMLLINT) --xpath $(call quote,$1) $(call quote,$2) > /dev/null 2> /dev/null
+
+# (callable) Extract the value of the text nodes in the provided XΒ·MΒ·L document and print them to `stdoutΒ΄.
+override extracttext = $(PRINTF) '%s' '<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"><output method="text" encoding="UTF-8"/></transform>' | $(XSLTPROC) - $(call quote,$1)
+
# β ΒΆ Phony Targets βββββββββββββββββββββββββββββββββββββββββββββββββββ
# Compile all files, or error if any are recursive.
-all : $(call compiled,$(recursivefiles) $(compilablefiles)) ;
+all : $(call built,$(recursivefiles) $(compilablefiles)) ;
# Destroy buildfiles.
clean :
@$(ECHO) "Generating main transformβ¦"
$(silent)$(XSLTPROC) -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2transform.xslt) $(call quote,$<)
-# Generate the output files using the dependencies as necessary.
-$(call compiled,$(compilablefiles)) : $(BUILDDIR)/public/% : $$(call parsed,$$(call uncompiled,$$@)) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@)))
- $(silent)$(call ensuredirectory,$(dir $@))
+# Compile the result files using the dependencies as necessary.
+$(call compiled,$(compilablefiles)) : $(BUILDDIR)/results/% : $$(call parsed,$$(call uncompiled,$$@)) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@)))
@$(PRINTF) '%s\n' $(call quote,Compiling </$*>β¦)
+ $(silent)$(call ensuredirectory,$(dir $@))
$(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam CATALOG 'catalog' --stringparam BUILDTIME $$(TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME $$(TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(call uncompiled,$@))) --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*) --stringparam CKSUM $$($(CKSUM) $(call quote,$(call uncompiled,$@)) | $(SED) 's/[ ].*//')$(if $(THISREV), --stringparam THISREV $(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,$$@)
+$(call compiled,$(filter $(assetfiles),$(sourcefiles))) : $(BUILDDIR)/results/% : $$(call uncompiled,$$@)
@$(PRINTF) '%s\n' $(call quote,Compiling </$*>β¦)
$(silent)$(call ensuredirectory,$(dir $@))
$(silent)$(CP) $(call quote,$<) $(call quote,$@)
+# Create the final files from the compiled results (or error in the case of recursive ones).
+$(call built,$(compilablefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/%
+ @$(PRINTF) '%s\n' $(call quote,Building </$*>β¦)
+ $(silent)$(call ensuredirectory,$(dir $@))
+ $(silent)if $(call xpath,/*[local-name()="raw-text" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$<); then $(RM) -f $(call quote,$@); $(call extracttext,$<) > $(call quote,$@); elif $(call xpath,/*[local-name()="base64-binary" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$<); then $(RM) -f $(call quote,$@); $(call extracttext,$<) | $(TR) -d '\t\n\f\r ' | $(UUDECODE) -m -r > $(call quote,$@); else $(LN) -s -f $(call quote,$(subst $(space),,$(foreach component,$(subst /, ,$*),../))results/$*) $(call quote,$@); fi
+$(call built,$(filter $(assetfiles),$(sourcefiles)) $(recursivefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/%
+ @$(PRINTF) '%s\n' $(call quote,Building </$*>β¦)
+ $(silent)$(call ensuredirectory,$(dir $@))
+ $(silent)$(LN) -s -f $(call quote,../results/$*) $(call quote,$@)
+
# Install compiled files (or error in the case of recursive ones).
$(call installed,$(filter $(assetfiles),$(sourcefiles)) $(recursivefiles) $(compilablefiles)) : $(DESTDIR)/% : $(BUILDDIR)/public/%
@$(PRINTF) '%s\n' $(call quote,Installing </$*>β¦)