+# (callable) Percent‐encode the given strings.
+#
+# This singly‐encodes u·r·i characters and doubly‐encodes other
+# characters, then calls `perdec´ to decode back to a single encoding.
+# The encoding assumes the input is a “u·r·i component”; e·g that the
+# resulting string should only contain `pchar´ (but can contain any
+# `sub-delim´).
+override perenc = $(foreach unencoded,$1,$(call perdec,$(shell $(PRINTF) '%s' $(call quote,$(unencoded)) | $(OD) -t x1 | $(SED) 's/^[0-9]*//;s/2[146-9A-Ea-e]/%&/g;s/3[0-9AaBbDd]/%&/g;s/40/%&/g;s/[46][1-9A-Fa-f]/%&/g;s/[57][0-9Aa]/%&/g;s/7[Ee]/%&/g;s/[ ][0-9A-Fa-f]\{2\}/%25&/g' | $(TR) -d ' \n' | $(TR) 'abcdef' 'ABCDEF')))
+
+# (callable) Percent‐encode each component in the given paths.
+override pathenc = $(foreach path,$1,$(subst $(space),/,$(call perenc,$(subst /, ,$(path)))))
+
+# (overridable) Collect all of the applicable includes from the
+# includes directory.
+sourceincludes := $(shell $(FIND) $(FINDOPTS) $(foreach dir,$(INCLUDEDIR),$(call quote,$(dir))) -type f '(' $(FINDRULES) ')')
+
+# (overridable) Collect all of the applicable source files from the
+# source directory, removing any which are also includes.
+sourcefiles := $(filter-out $(sourceincludes),$(shell $(FIND) $(FINDOPTS) $(foreach dir,$(SRCDIR),$(call quote,$(dir))) -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