]> Lady’s Gitweb - Shushe/commitdiff
Disable make·file prerequisites when not needed 0.11.1
authorLady <redacted>
Sat, 22 Jun 2024 21:43:40 +0000 (17:43 -0400)
committerLady <redacted>
Thu, 11 Jul 2024 01:46:30 +0000 (21:46 -0400)
Specifically, the `help` and `clean` targets don’t require any
compilation of types, parsers, dependencies, or destinations. G·N·U
Make provides the `$(MAKECMDGOALS)` to check which targets were set as
goals on the commandline; when the only goals are `help` and `clean`,
excessive computation can be disabled.

GNUmakefile

index 78f9a41d4d1cd69fd09eef546ed32b3814453576..be4ec71c07629345a14b35dac016406c4d9182cf 100644 (file)
@@ -309,14 +309,19 @@ ifeq ($(MODE),urn:fdc:ladys.computer:20231231:Shu1She4:mode:default)
 
 # ─ ¶ Non‐Recipe Variable Definitions ─────────────────────────────────
 
+# Non·empty if `help´ or `clean´, and no targets other than `help´ or `clean´, were specified as goals on the commandline.
+override notbuilding := $(and $(filter help clean,$(MAKECMDGOALS)),$(call not,$(filter-out help clean,$(MAKECMDGOALS))))
+
 # (callable) Test to see if the prerequisites provided by the second argument matches the value in the file corresponding to the first argument in `$(BUILDDIR)/lastprereqs´.
 # If not, save the new value and then add FORCE.
 # Return them regardless.
 #
 # Calling this variable is useful when a given target should be updated whenever its list of prerequisites changes in addition to whenever there is a change to one of its prerequisites.
 #
+# If `$(notbuilding)´ is non·empty, this variable produces no result to avoid unnecessary work.
+#
 # ☡ This variable creates at least one subshell every time it is computed.
-override diffprereqs = $(if $(subst $(shell $(CAT) $(call quote,$(BUILDDIR)/lastprereqs/$1) 2>>/dev/null || :),,$2),$2 FORCE$(and $(shell $(call ensuredirectory,$(BUILDDIR)/lastprereqs) && $(PRINTF) '%s\n' $(call quote,$2) >|$(BUILDDIR)/lastprereqs/$1),),$2)
+override diffprereqs = $(if $(notbuilding),,$(if $(subst $(shell $(CAT) $(call quote,$(BUILDDIR)/lastprereqs/$1) 2>>/dev/null || :),,$2),$2 FORCE$(and $(shell $(call ensuredirectory,$(BUILDDIR)/lastprereqs) && $(PRINTF) '%s\n' $(call quote,$2) >|$(BUILDDIR)/lastprereqs/$1),),$2))
 
 # (callable) Escape special characters for use in X·M·L.
 override xmlesc = $(subst >,&gt;,$(subst <,&lt;,$(subst &,&amp;,$1)))
@@ -577,12 +582,14 @@ FORCE : ;
 # Phony rules; always consider these out·of·date.
 .PHONY : FORCE all default clean gone info install list listout uninstall $(call built,$(recursivefiles)) ;
 
+ifeq ($(notbuilding),)
 # Reload this make·file if the magic file, parser, dependencies, or destinations have changed.
 #
 # If the magic file or parser changed, then another restart will be required, as the dependencies and destinations will need to be regenerated.
 $(THISDIR)/GNUmakefile : $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt $(BUILDDIR)/dependencies $(BUILDDIR)/destinations
        $(silent)$(TOUCH) $(THISDIR)/GNUmakefile
        $(if $(filter $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt,$?),$(call inform,$(PRINTF) '%b\n' '\0033[1mMagic file or parsers have updated. Restarting…\0033[22m' >&2)$(newline)$(silent)$(SLEEP) 1,$(if $(typeupdates),$(silent)$(RM) $(call quote,$(BUILDDIR)/.update-types)$(newline),)$(call inform,$(PRINTF) '%b\n' '\0033[1mDependency graph and output destinations updated. Restarting…\0033[22m' >&2))
+endif
 
 # ─ ¶ Build Targets ───────────────────────────────────────────────────
 
This page took 0.025496 seconds and 4 git commands to generate.