From: Lady Date: Sat, 22 Jun 2024 21:43:40 +0000 (-0400) Subject: Disable make·file prerequisites when not needed X-Git-Tag: 0.11.1^0 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/dfa704e1220e80795f3e47907a4f1d800a6897c5?hp=bc83928663f56508f210ce19a607aa9a52f32983 Disable make·file prerequisites when not needed 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. --- diff --git a/GNUmakefile b/GNUmakefile index 78f9a41..be4ec71 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 >,>,$(subst <,<,$(subst &,&,$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 ───────────────────────────────────────────────────