X-Git-Url: https://git.ladys.computer/Shushe/blobdiff_plain/cb45fc856ed6f9e7eaf6db12a93372026decd080..61599492d0451c48f963a13a78a11a59415eb6f0:/GNUmakefile?ds=sidebyside diff --git a/GNUmakefile b/GNUmakefile index 7765095..2c77723 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -222,6 +222,9 @@ endif # Generates archive files from parse results. MODE := urn:fdc:ladys.computer:20231231:Shu1She4:mode:default +# Set to a non·empty value to silence informative messages. +QUIET := + # Set to a non·empty value to print all commands as they run. VERBOSE := @@ -250,9 +253,6 @@ override comma := , # (callable) Quote the given string for use within shell calls. override quote = '$(subst ','"'"',$1)' -# Outputs an `@´ to silence rules, unless `VERBOSE´ is nonempty. -override silent := $(if $(VERBOSE),,@) - # (callable) Get the modified time of the provided file. # # Only the date·time information available via `ls -l´ is supported; that is, only minute precision for files newer than six months, and only day precision for files which are older. @@ -269,6 +269,12 @@ override modtime = $(shell { $(DATE) -u '+%Y-%m'; LC_TIME=POSIX TZ=UTC0 ls -q -A # ─ ¶ Recipe Variable Definitions ───────────────────────────────────── +# Outputs an `@´ to silence rules, unless `VERBOSE´ is non·empty. +override silent := $(if $(VERBOSE),,@) + +# (callable) Only perform the rule if `QUIET` is not set. +override inform = $(if $(QUIET),,@$1) + # (callable) Check to see if the given directory exists and create it if not. override ensuredirectory = if $(TEST) ! -d $(call quote,$1); then $(MKDIR) -p $(call quote,$1); fi @@ -507,7 +513,7 @@ list : # Lists out the destinations of all resulting files (relative to `DESTDIR´). listout : - @$(PRINTF) '⛩️📰 书社 Output: %s\n' $(call quote,$(foreach file,$(sort $(sourcefiles)),$(call destination,$(file)))) + @$(PRINTF) '%s\n' $(call quote,$(foreach file,$(sort $(sourcefiles)),$(call destination,$(file)))) # Destroy installed files. uninstall : @@ -515,7 +521,7 @@ uninstall : # Raise an error when attempting to build any files with recursive dependencies. $(call built,$(recursivefiles)) : - @$(PRINTF) '%b\n' $(call quote,\0033[93;41mError:\0033[39;49m `$(call unbuilt,$@)´ has recursive dependencies:\n$(subst |, ,$(subst $(space),$(newline),$(foreach recursive,$(call recursives,$(call unbuilt,$@)),•|$(recursive))))) && false + @$(PRINTF) '%b\n' $(call quote,\0033[93;41mError:\0033[39;49m `$(call unbuilt,$@)´ has recursive dependencies:\n$(subst |, ,$(subst $(space),$(newline),$(foreach recursive,$(call recursives,$(call unbuilt,$@)),•|$(recursive))))) >&2 && false # Add as a prerequisite to treat the target as tho it were phony. FORCE : ; @@ -542,10 +548,10 @@ ifneq ($(typeupdates)$(wildcard $(BUILDDIR)/dependencies)$(wildcard $(BUILDDIR)/ $(THISDIR)/GNUmakefile :: $(BUILDDIR)/dependencies $(BUILDDIR)/destinations $(silent)$(TOUCH) $(THISDIR)/GNUmakefile ifeq ($(typeupdates),) - @if $(TEST) ! -f $(call quote,$(BUILDDIR)/.update-types); then $(PRINTF) '%b\n' '\0033[1mDependency graph and output destinations updated. Restarting…\0033[22m'; fi + $(call inform,if $(TEST) ! -f $(call quote,$(BUILDDIR)/.update-types); then $(PRINTF) '%b\n' '\0033[1mDependency graph and output destinations updated. Restarting…\0033[22m' >&2; fi) else $(silent)$(RM) $(call quote,$(BUILDDIR)/.update-types) - @$(PRINTF) '%b\n' '\0033[1mDependency graph and output destinations updated. Restarting…\0033[22m' + $(call inform,$(PRINTF) '%b\n' '\0033[1mDependency graph and output destinations updated. Restarting…\0033[22m' >&2) endif endif @@ -558,7 +564,7 @@ ifeq ($(typeupdates),) $(THISDIR)/GNUmakefile :: $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt $(silent)$(TOUCH) $(THISDIR)/GNUmakefile $(silent)$(RM) -f $(call quote,$(BUILDDIR)/dependencies) $(call quote,$(BUILDDIR)/destinations) - @$(PRINTF) '%b\n' '\0033[1mMagic file or parsers have updated. Restarting…\0033[22m' + $(call inform,$(PRINTF) '%b\n' '\0033[1mMagic file or parsers have updated. Restarting…\0033[22m' >&2) $(silent)$(SLEEP) 1 $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types) endif @@ -575,18 +581,18 @@ $(call magicfile,$(MAGIC)) : $(BUILDDIR)/magic/% : $$(call magicsource,$$@) # It must be updated if any of the files in the magic directory change. $(BUILDDIR)/magic.mgc : $(call diffprereqs,magic,$(sort $(call magicfile,$(MAGIC)))) $(foreach outdated,$(filter-out $^,$(wildcard $(BUILDDIR)/magic/*)),$(silent)$(RM) $(call quote,$(outdated))$(newline)) - @$(PRINTF) '%s\n' 'Compiling new magic…' + $(call inform,$(PRINTF) '%s\n' 'Compiling new magic…' >&2) $(silent)$(call ensuredirectory,$(dir $@)) $(silent)cd $(call quote,$(BUILDDIR)) && $(FILE) -C -m $(call quote,$(realpath $(BUILDDIR)/magic)) $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types) # Generate the main parser. $(BUILDDIR)/parser.catalog : $(call diffprereqs,parsers,$(sort $(PARSERS))) - @$(PRINTF) '%s\n' 'Generating catalog of parsers…' + $(call inform,$(PRINTF) '%s\n' 'Generating catalog of parsers…' >&2) $(silent)$(XMLCATALOG) --create --noout $(call quote,$@) $(foreach parser,$(PARSERS),$(silent){ $(call id,$(parser)); $(PRINTF) '%s\n' $(call quote,$(call fileuri,$(parser))) '--noout' $(call quote,$@); } | $(xargsmultiquote) | $(XARGS) -E '' $(XMLCATALOG) --add uri$(newline)) $(BUILDDIR)/parser.xslt : $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2parser.xslt - @$(PRINTF) '%s\n' 'Generating main parser…' + $(call inform,$(PRINTF) '%s\n' 'Generating main parser…' >&2) $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) $(call quote,$(THISDIR)/lib/catalog2parser.xslt) $(call quote,$<) $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types) @@ -595,7 +601,7 @@ $(BUILDDIR)/parser.xslt : $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2pars # Even plain X·M·L files are parsed, because they may contain X·H·T·M·L `