X-Git-Url: https://git.ladys.computer/Shushe/blobdiff_plain/88823523127972944771746f48bc2838e0317d31..409666e0452f0f38cdf419a5fcb2690256b43878:/GNUmakefile diff --git a/GNUmakefile b/GNUmakefile index 4979bfb..0ed0e90 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ SHELL = /bin/sh # ━ § BASIC INFORMATION ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ override define makefileinfo ╭────────────────────────────╮ -╔╡ ⁌ ⛩️📰 书社 ∷ GNUmakefile ╞════════════════════════════════╗ +╔╡ ⁌ ⛩️📰 书社 ∷ GNUmakefile ╞═════════════════════════════════╗ ║╰────────────────────────────╯ ║ ╟┬ ¶ Prerequisites ───────────────────────────────────────────┬╢ ║│ │║ @@ -46,13 +46,14 @@ override define makefileinfo ║╰────────────────────────────────────────────────────────────╯║ ╟┬ ¶ Usage ───────────────────────────────────────────────────┬╢ ║│ │║ -║│ • `make all´: Compile, but do not install, all files. │║ +║│ • `make all´ (default): Compile, but do not install, all │║ +║│ files. │║ ║│ │║ ║│ • `make clean´: Remove `BUILDDIR´. │║ ║│ │║ ║│ • `make gone´: Remove `BUILDDIR´ and installed files. │║ ║│ │║ -║│ • `make help´ (default): Print this message. │║ +║│ • `make help´: Print this message. │║ ║│ │║ ║│ • `make install´: Compile all files and install in │║ ║│ `DESTDIR´. │║ @@ -169,9 +170,7 @@ XMLTYPES := application/xml text/xml VERBOSE := # The default target for this makefile. -# -# Print help and exit. -.DEFAULT_GOAL := help +.DEFAULT_GOAL := all # ━ § BEGIN MAKE·FILE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -301,7 +300,7 @@ override unparsed = $(foreach file,$1,$(patsubst %|$(file),%,$(filter %|$(file), ifneq ($(wildcard $(BUILDDIR)/dependencies),) # Pair each file with a list of dependencies for it. -override dependenciesforfile := $(foreach file,$(sourcefiles),$(file)|$(subst $(space),|,$(shell $(CAT) $(call quote,$(BUILDDIR)/dependencies) | $(SED) $(call quote,/^$(call sedesc,$(call localuri,$(file)))$$/$(comma)/^[^ ]/!d;/^ /!d;s/^ //)))) +override dependenciesforfile := $(foreach file,$(filter-out $(assetfiles),$(sourcefiles) $(sourceincludes)),$(file)|$(subst $(space),|,$(shell $(CAT) $(call quote,$(BUILDDIR)/dependencies) | $(SED) $(call quote,/^$(call sedesc,$(call localuri,$(file)))$$/$(comma)/^[^ ]/!d;/^ /!d;s/^ //)))) # (callable) Get the list of dependency leiris for the given source files. # @@ -361,45 +360,45 @@ override wrapplaintext = $(PRINTF) '%s\n' "$$($(PRINTF) '%b' ',) )) | $(TR) ' |' '\n ' -# Destroy build directory and installed files. -uninstall: +# Destroy installed files. +uninstall : $(foreach file,$(installablefiles),$(if $(wildcard $(call installed,$(file))),$(silent)$(PRINTF) '%s\n' $(call quote,Removing …)$(newline)$(silent)$(RM) -f $(call quote,$(call installed,$(file)))$(newline),)) # Raise an error when attempting to build any files with recursive dependencies. -$(call compiled,$(recursivefiles)): +$(call compiled,$(recursivefiles)) : @$(PRINTF) '%b\n' $(call quote,\0033[93;41mError:\0033[39;49m `$(call uncompiled,$@)´ has recursive dependencies:\n$(subst |, ,$(subst $(space),$(newline),$(foreach recursive,$(call recursives,$(call uncompiled,$@)),•|$(recursive))))) && false # ─ ¶ Special Targets ───────────────────────────────────────────────── # Perform secondary expansion; this enables pattern rules to determine their prerequisites based on the matched pattern. -.SECONDEXPANSION: ; +.SECONDEXPANSION : ; # Don’t use any implicit rules. -.SUFFIXES: ; +.SUFFIXES : ; # Phony rules; always consider these out·of·date. -.PHONY: all default clean gone info install list uninstall $(call compiled,$(recursivefiles)); +.PHONY : all default clean gone info install list uninstall $(call compiled,$(recursivefiles)) ; ifneq ($(wildcard $(BUILDDIR)/.update-types)$(wildcard $(BUILDDIR)/dependencies)$(wildcard $(BUILDDIR)/destinations),) # Reload this make·file if the dependency graph or output destinations have changed. @@ -407,7 +406,7 @@ ifneq ($(wildcard $(BUILDDIR)/.update-types)$(wildcard $(BUILDDIR)/dependencies) # The dependency graph and output destinations are used to set the values of variables in this make·file, so it’s important to ensure that they are actually up·to·date prior to executing any later rules. # # This recipe only exists after types have been updated or when the dependency graph or destinations file already exists. -$(THISDIR)/GNUmakefile:: $(BUILDDIR)/dependencies $(BUILDDIR)/destinations +$(THISDIR)/GNUmakefile :: $(BUILDDIR)/dependencies $(BUILDDIR)/destinations $(silent)$(TOUCH) $(THISDIR)/GNUmakefile $(silent)$(RM) -f $(BUILDDIR)/.update-types @$(PRINTF) '%b\n' '\0033[1mDependency graph and output destinations updated. Restarting…\0033[22m' @@ -419,7 +418,7 @@ ifeq ($(wildcard $(BUILDDIR)/.update-types),) # These are used to classify source files, so if they have changed then the make·file must be reloaded. # # This recipe sleeps for one second to ensure that files built after the restart have a more current time·stamp. -$(THISDIR)/GNUmakefile:: $(BUILDDIR)/magic.mgc $(BUILDDIR)/parser.xslt +$(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' @@ -431,7 +430,7 @@ endif # Create symbolic links from the build directory’s store of magic files # to their corresponding sources. -$(call magicfile,$(MAGIC)): $(BUILDDIR)/magic/%: $$(call magicsource,$$@) +$(call magicfile,$(MAGIC)) : $(BUILDDIR)/magic/%: $$(call magicsource,$$@) $(silent)$(call ensuredirectory,$(dir $@)) $(silent)$(LN) -sf $(call quote,$(realpath $<)) $(call quote,$@) @@ -439,14 +438,14 @@ $(call magicfile,$(MAGIC)): $(BUILDDIR)/magic/%: $$(call magicsource,$$@) # # It must be updated if any of the files in the magic directory change. # It ⁜also⁜ should be updated if any of the files in the magic directory are deleted, but this isn’t tracked presently. -$(BUILDDIR)/magic.mgc: $(call magicfile,$(MAGIC)) +$(BUILDDIR)/magic.mgc : $(call magicfile,$(MAGIC)) $(foreach outdated,$(filter-out $^,$(wildcard $(BUILDDIR)/magic/*)),$(silent)$(RM) $(call quote,$(outdated))$(newline)) @$(ECHO) "Compiling new magic…" $(silent)$(call ensuredirectory,$(dir $@)) $(silent)cd $(call quote,$(BUILDDIR)) && $(FILE) -C -m $(call quote,$(realpath $(BUILDDIR)/magic)) # Generate the main parser. -$(BUILDDIR)/parser.catalog: $(PARSERS) +$(BUILDDIR)/parser.catalog : $(PARSERS) @$(ECHO) "Generating catalog of parsers…" $(silent)$(XMLCATALOG) --create --noout $(call quote,$@) $(foreach parser,$(PARSERS),$(silent)$(XMLCATALOG) --add uri $(call quote,$(call id,$(parser),parser)) $(call quote,file:///$(call pathenc,$(abspath $(parser)))) --noout $(call quote,$@)$(newline)) @@ -458,7 +457,7 @@ $(BUILDDIR)/parser.xslt: $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2parse # # Even plain X·M·L files are parsed, because they may contain X·H·T·M·L `