]> Lady’s Gitweb - Caudex/blobdiff - GNUmakefile
Make repository REUSE‐compliant
[Caudex] / GNUmakefile
index a470b399c061894dec66c3db024483efbf995eb6..526170b60be282a608ddacaac614180636be664c 100644 (file)
@@ -1,3 +1,6 @@
+# SPDX-FileCopyrightText: 2024 Lady <https://www.ladys.computer/about/#lady>
+# SPDX-License-Identifier: MPL-2.0
+
 SHELL = /bin/sh
 
 # ━ § BASIC INFORMATION ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 SHELL = /bin/sh
 
 # ━ § BASIC INFORMATION ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -8,7 +11,7 @@ override define makefileinfo
 ╟┬ ¶ Prerequisites ───────────────────────────────────────────┬╢
 ║│                                                            │║
 ║│ Requires G·N·U Make, at least version 3.81, and all of the │║
 ╟┬ ¶ Prerequisites ───────────────────────────────────────────┬╢
 ║│                                                            │║
 ║│ Requires G·N·U Make, at least version 3.81, and all of the │║
-║│ requirements of ⛩📰 书社, which is included as a git      │║
+║│ requirements of ⛩📰 书社, which is included as a git      │║
 ║│ submodule. Run `make help-shushe´ for more information.    │║
 ║╰────────────────────────────────────────────────────────────╯║
 ╟┬ ¶ Usage ───────────────────────────────────────────────────┬╢
 ║│ submodule. Run `make help-shushe´ for more information.    │║
 ║╰────────────────────────────────────────────────────────────╯║
 ╟┬ ¶ Usage ───────────────────────────────────────────────────┬╢
@@ -44,7 +47,7 @@ override define makefileinfo
 ║╰────────────────────────────────────────────────────────────╯║
 ╟┬ ¶ Copyright & License ─────────────────────────────────────┬╢
 ║│                                                            │║
 ║╰────────────────────────────────────────────────────────────╯║
 ╟┬ ¶ Copyright & License ─────────────────────────────────────┬╢
 ║│                                                            │║
-║│ Copyright © 2024 Lady [@ Lady’s Computer].                 │║
+║│ Copyright © 2024 Lady [@ Ladys Computer].                  │║
 ║│                                                            │║
 ║│ This Source Code Form is subject to the terms of the       │║
 ║│ Mozilla Public License, v 2.0. If a copy of the M·P·L was  │║
 ║│                                                            │║
 ║│ This Source Code Form is subject to the terms of the       │║
 ║│ Mozilla Public License, v 2.0. If a copy of the M·P·L was  │║
@@ -60,10 +63,9 @@ endef
 #
 # If these are not installed on your computer, or you need to use a different implementation, you can override the appropriate variable.
 #
 #
 # If these are not installed on your computer, or you need to use a different implementation, you can override the appropriate variable.
 #
-# See also the documentation for ⛩📰 书社, which specifies additional programs.
+# See also the documentation for ⛩📰 书社, which specifies additional programs.
 AWK := awk
 CAT := cat
 AWK := awk
 CAT := cat
-ECHO := echo
 GIT := git
 MKDIR := mkdir
 OD := od
 GIT := git
 MKDIR := mkdir
 OD := od
@@ -90,38 +92,40 @@ BUILDDIR := build
 # The directory into which to output files on `make´.
 DESTDIR := public
 
 # The directory into which to output files on `make´.
 DESTDIR := public
 
-# The location of this Makefile (and related ⛩️📰 书社 files), relative to the current working directory.
+# The location of this Makefile, relative to the current working directory.
+#
+# It is expected that other files packaged as a part of 🪾📰 Caudex can also be found in this directory.
 #
 # By default, this is inferred from the variable `MAKEFILE_LIST´.
 THISDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 
 #
 # By default, this is inferred from the variable `MAKEFILE_LIST´.
 THISDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 
-# Extra magic files to forward to ⛩📰 书社.
+# Extra magic files to forward to ⛩📰 书社.
 #
 # Your computer probably has several already installed at `/usr/share/file/magic´.
 EXTRAMAGIC :=
 
 #
 # Your computer probably has several already installed at `/usr/share/file/magic´.
 EXTRAMAGIC :=
 
-# Extra parsers to forward to ⛩📰 书社.
+# Extra parsers to forward to ⛩📰 书社.
 #
 # Which parsers are provided will influence which kinds of files are recognized as plaintext.
 EXTRAPARSERS :=
 
 #
 # Which parsers are provided will influence which kinds of files are recognized as plaintext.
 EXTRAPARSERS :=
 
-# Extra transforms to forward to ⛩📰 书社.
+# Extra transforms to forward to ⛩📰 书社.
 EXTRATRANSFORMS :=
 
 EXTRATRANSFORMS :=
 
+# A description of the current git revision of 🪾📰 Caudex.
+THISREV := $(shell cd $(THISDIR); $(GIT) describe 2> /dev/null || $(GIT) rev-parse HEAD 2> /dev/null || true)
+
 # Variables to communicate to further calls to Make.
 #
 # By default, `MAKEOVERRIDES´ contains all variable overrides specified on the commandline.
 # However, some values are specific to 🪾📰 Caudex and may have different meaning in other make·files; filter these out.
 # Variables to communicate to further calls to Make.
 #
 # By default, `MAKEOVERRIDES´ contains all variable overrides specified on the commandline.
 # However, some values are specific to 🪾📰 Caudex and may have different meaning in other make·files; filter these out.
-MAKEOVERRIDES := $(filter-out SRCDIR=% ASSETDIR=% BUILDDIR=% DESTDIR=% THISDIR=% EXTRAMAGIC=% EXTRAPARSERS=% EXTRATRANSFORMS=%,$(MAKEOVERRIDES))
+MAKEOVERRIDES := $(filter-out SRCDIR=% ASSETDIR=% BUILDDIR=% DESTDIR=% THISDIR=% EXTRAMAGIC=% EXTRAPARSERS=% EXTRATRANSFORMS=% THISREV=%,$(MAKEOVERRIDES))
 
 
-# The location of ⛩️📰 书社.
-SHUSHE := $(THISDIR)/.⛩️📰
+# The location of 💄📝 Les·M·L.
+LESML := $(THISDIR)/.💄📝
 
 
-# The name of the generator program.
-GENERATOR := 🪾📰 Caudex
-
-# A description of the current git revision of 🪾📰 Caudex.
-VERSION := $(shell cd $(THISDIR); $(GIT) describe 2> /dev/null || $(GIT) rev-parse HEAD 2> /dev/null || true)
+# The location of ⛩📰 书社.
+SHUSHE := $(THISDIR)/.⛩📰
 
 # Set to a non·empty value to print all commands as they run.
 VERBOSE :=
 
 # Set to a non·empty value to print all commands as they run.
 VERBOSE :=
@@ -160,7 +164,7 @@ override entriesforcategory = $(sort $(foreach category,$1,$(wildcard $(SRCDIR)/
 override wrmg = $(foreach attempt,$(shell $(OD) -t u4 -N 4 /dev/random | $(SED) 's/^[0-9]* *//' | $(TR) -d ' \n' | $(AWK) 'BEGIN{chars="0123456789ABCDEFGHJKMNPQRSTVWXYZ&~@=U"}{d=32^5;r=$$0%(32^6);printf("%s",substr(chars,r%37,1));while(d>0){printf("%s", substr(chars,int(r/d),1));if(d==32^4)printf("%s", "-");r%=d;d=int(d/32)}}'),$(if $(wildcard $(SRCDIR)/*/($(attempt))*),$(call wrmg),$(attempt)))
 
 # (callable) Returns the identifiers of the provided entries.
 override wrmg = $(foreach attempt,$(shell $(OD) -t u4 -N 4 /dev/random | $(SED) 's/^[0-9]* *//' | $(TR) -d ' \n' | $(AWK) 'BEGIN{chars="0123456789ABCDEFGHJKMNPQRSTVWXYZ&~@=U"}{d=32^5;r=$$0%(32^6);printf("%s",substr(chars,r%37,1));while(d>0){printf("%s", substr(chars,int(r/d),1));if(d==32^4)printf("%s", "-");r%=d;d=int(d/32)}}'),$(if $(wildcard $(SRCDIR)/*/($(attempt))*),$(call wrmg),$(attempt)))
 
 # (callable) Returns the identifiers of the provided entries.
-override identifier = $(shell $(TR) ' ' '\n' <<< $(call quote,$1) | $(SED) 's/^\(.*[/]\)\{0,1\}\(.\{3\}-.\{4\}\)\(,[^/]*\)\{0,1\}$$/\2/')
+override identifier = $(shell $(PRINTF) '%s\n' $(call quote,$1) | $(TR) ' ' '\n' | $(SED) 's/^\(.*[/]\)\{0,1\}\(.\{3\}-.\{4\}\)\(,[^/]*\)\{0,1\}$$/\2/')
 
 # Output locations for compiled catalog files for categories.
 override categorycatalogs := $(patsubst %,$(BUILDDIR)/catalogs/categories/%/index,$(categories))
 
 # Output locations for compiled catalog files for categories.
 override categorycatalogs := $(patsubst %,$(BUILDDIR)/catalogs/categories/%/index,$(categories))
@@ -171,17 +175,19 @@ override entrycatalogs := $(foreach entry,$(call entriesforcategory,$(categories
 # Output locations for all compiled catalog files.
 override allcatalogs := $(BUILDDIR)/catalogs/indices/index $(BUILDDIR)/catalogs/indices/fullindex $(categorycatalogs) $(entrycatalogs)
 
 # Output locations for all compiled catalog files.
 override allcatalogs := $(BUILDDIR)/catalogs/indices/index $(BUILDDIR)/catalogs/indices/fullindex $(categorycatalogs) $(entrycatalogs)
 
-# (overridable) Options to pass to ⛩📰 书社.
-override shusheopts := SRCDIR=$(call quote,$(if $(wildcard $(ASSETDIR)),$(ASSETDIR),) $(if $(entrycatalogs),$(BUILDDIR)/catalogs/entries,) $(BUILDDIR)/catalogs/indices) BUILDDIR=$(call quote,$(BUILDDIR)/⛩️📰) INCLUDEDIR=$(call quote,$(SRCDIR) $(if $(wildcard $(ASSETINCLUDEDIR)),$(ASSETINCLUDEDIR),) $(if $(categorycatalogs),$(BUILDDIR)/catalogs/categories,)) DESTDIR=$(call quote,$(DESTDIR)) EXTRAMAGIC=$(call quote,$(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/magic/*)) $(EXTRAMAGIC))) EXTRAPARSERS=$(call quote,$(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/parsers/*.xslt)) $(EXTRAPARSERS))) EXTRATRANSFORMS=$(call quote,$(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/transforms/*.xslt)) $(EXTRATRANSFORMS))) GENERATOR=$(call quote,$(GENERATOR)) VERSION=$(call quote,$(VERSION))
+# (overridable) Options to pass to ⛩📰 书社.
+override shusheopts := SRCDIR=$(call quote,$(if $(wildcard $(ASSETDIR)),$(ASSETDIR),) $(if $(entrycatalogs),$(BUILDDIR)/catalogs/entries,) $(BUILDDIR)/catalogs/indices) BUILDDIR=$(call quote,$(BUILDDIR)/⛩📰) INCLUDEDIR=$(call quote,$(SRCDIR) $(if $(wildcard $(ASSETINCLUDEDIR)),$(ASSETINCLUDEDIR),) $(if $(categorycatalogs),$(BUILDDIR)/catalogs/categories,)) DESTDIR=$(call quote,$(DESTDIR)) EXTRAMAGIC=$(call quote,$(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/magic/*)) $(LESML)/magic $(EXTRAMAGIC))) EXTRAPARSERS=$(call quote,$(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/parsers/*.xslt)) $(LESML)/parser.xslt $(EXTRAPARSERS))) EXTRATRANSFORMS=$(call quote,$(sort $(patsubst ./%,%,$(wildcard $(THISDIR)/transforms/*.xslt)) $(EXTRATRANSFORMS)))
 
 # ─ ¶ Recipe Variable Definitions ─────────────────────────────────────
 
 # (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
 
 
 # ─ ¶ Recipe Variable Definitions ─────────────────────────────────────
 
 # (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
 
-# (callable) Test to see if the dependencies provided by the second argument matches the value in the file corresponding to the first argument in `$(BUILDDIR)/lastprereqs´.
-# If not, return the third argument, plus an additional rule to save the new prerequisites.
-override makeandsavedeps = $(if $(subst $(shell $(CAT) $(call quote,$(BUILDDIR)/lastdeps/$1) 2> /dev/null || true),,$2),$3$(newline)$(silent)$(call ensuredirectory,$(BUILDDIR)/lastdeps)$(newline)$(silent)$(PRINTF) '%s\n' $(call quote,$2) > $(BUILDDIR)/lastdeps/$1,)
+# (callable) Test to see if the file provided by the first argument exists and the dependencies provided by the third argument matches the value in the file corresponding to the second argument in `$(BUILDDIR)/lastprereqs´.
+# If not, return the fourth argument, plus an additional rule to save the new prerequisites.
+#
+# ※ If the third argument is empty, the fourth argument is always returned.
+override makeandsavedeps = $(if $(or $(if $3,,1),$(if $(wildcard $1),,1),$(subst $(shell $(CAT) $(call quote,$(BUILDDIR)/lastdeps/$2) 2> /dev/null || true),,$3)),$4$(newline)$(silent)$(call ensuredirectory,$(BUILDDIR)/lastdeps)$(newline)$(silent)$(PRINTF) '%s\n' $(call quote,$3) > $(call quote,$(BUILDDIR)/lastdeps/$2),)
 
 # (callable) Make the catalog for the provided category.
 override define makecategorycatalog
 
 # (callable) Make the catalog for the provided category.
 override define makecategorycatalog
@@ -204,14 +210,14 @@ $(silent)$(XMLCATALOG) --add uri '@' '@' --noout $(call quote,$(BUILDDIR)/catalo
 $(foreach category,$(categories),$(silent)$(XMLCATALOG) --add uri $(call quote,$(category)) $(call quote,$(category)/index) --noout $(call quote,$(BUILDDIR)/catalogs/indices/$(if $1,full,)index)$(newline))
 endef
 
 $(foreach category,$(categories),$(silent)$(XMLCATALOG) --add uri $(call quote,$(category)) $(call quote,$(category)/index) --noout $(call quote,$(BUILDDIR)/catalogs/indices/$(if $1,full,)index)$(newline))
 endef
 
-# ─ ¶ ⛩📰 书社 Targets ──────────────────────────────────────────────
+# ─ ¶ ⛩📰 书社 Targets ──────────────────────────────────────────────
 
 
-# Targets to forward to ⛩📰 书社.
+# Targets to forward to ⛩📰 书社.
 all install list uninstall : $(SHUSHE)/GNUmakefile catalogs
        $(silent)$(MAKE) -f $(call quote,$<) $(call quote,$@) $(shusheopts)
 %-shushe : $(SHUSHE)/GNUmakefile FORCE
        $(silent)$(MAKE) -f $(call quote,$<) $(call quote,$*) $(shusheopts)
 all install list uninstall : $(SHUSHE)/GNUmakefile catalogs
        $(silent)$(MAKE) -f $(call quote,$<) $(call quote,$@) $(shusheopts)
 %-shushe : $(SHUSHE)/GNUmakefile FORCE
        $(silent)$(MAKE) -f $(call quote,$<) $(call quote,$*) $(shusheopts)
-build/⛩📰/% : $(SHUSHE)/GNUmakefile catalogs FORCE
+build/⛩📰/% : $(SHUSHE)/GNUmakefile catalogs FORCE
        $(SILENT)$(MAKE) -f $(call quote,$<) $(call quote,$@) $(shusheopts)
 public/% : $(SHUSHE)/GNUmakefile catalogs FORCE
        $(SILENT)$(MAKE) -f $(call quote,$<) $(call quote,$@) $(shusheopts)
        $(SILENT)$(MAKE) -f $(call quote,$<) $(call quote,$@) $(shusheopts)
 public/% : $(SHUSHE)/GNUmakefile catalogs FORCE
        $(SILENT)$(MAKE) -f $(call quote,$<) $(call quote,$@) $(shusheopts)
@@ -241,13 +247,13 @@ listids :
 
 # Output a random unused identifier.
 wrmg :
 
 # Output a random unused identifier.
 wrmg :
-       @$(ECHO) $(wrmg)
+       @$(PRINTF) '%s\n' $(wrmg)
 
 # Create a new entry in the provided category and output its path.
 +% : FORCE
        $(silent)$(call ensuredirectory,$(SRCDIR)/$*)
        $(if $(wildcard $(SRCDIR)/$*/@),,$(silent)$(PRINTF) '%b' '%%\nCATEGORY : $*\n%%\n' > '$(SRCDIR)/$*/@')
 
 # Create a new entry in the provided category and output its path.
 +% : FORCE
        $(silent)$(call ensuredirectory,$(SRCDIR)/$*)
        $(if $(wildcard $(SRCDIR)/$*/@),,$(silent)$(PRINTF) '%b' '%%\nCATEGORY : $*\n%%\n' > '$(SRCDIR)/$*/@')
-       $(foreach identifier,$(wrmg),@$(PRINTF) '%b' '%%\nENTRY : $(identifier)\n%%\n\n' > '$(SRCDIR)/$*/$(identifier)'$(newline)@$(ECHO) '$(SRCDIR)/$*/$(identifier)')
+       $(foreach identifier,$(wrmg),@$(PRINTF) '%b' '\0043!lesml\nENTRY : $(identifier)\n%%\n\n' > '$(SRCDIR)/$*/$(identifier)'$(newline)@$(PRINTF) '%s\n' '$(SRCDIR)/$*/$(identifier)')
 
 # ─ ¶ Special Targets ─────────────────────────────────────────────────
 
 
 # ─ ¶ Special Targets ─────────────────────────────────────────────────
 
@@ -267,14 +273,19 @@ FORCE : ;
 
 # ─ ¶ Build Targets ───────────────────────────────────────────────────
 
 
 # ─ ¶ Build Targets ───────────────────────────────────────────────────
 
-# Initialize the ⛩️📰 书社 repository if it is empty.
+# Initialize the ⛩📰 书社 repository if it is empty.
+ifneq ($(filter $(THISDIR)/%,$(SHUSHE)),)
 $(SHUSHE)/GNUmakefile : $(THISDIR)/%/GNUmakefile :
        @$(PRINTF) '%s\n' $(call quote,Initializing git submodule at `$*´)
        $(silent)cd $(THISDIR) && $(GIT) submodule update --init $(call quote,$*)
 $(SHUSHE)/GNUmakefile : $(THISDIR)/%/GNUmakefile :
        @$(PRINTF) '%s\n' $(call quote,Initializing git submodule at `$*´)
        $(silent)cd $(THISDIR) && $(GIT) submodule update --init $(call quote,$*)
+endif
 
 
-# Touch parsers and transforms if the files in `lib/´ have changed.
-$(PARSERS) $(TRANSFORMS) : $(wildcard lib/*.xslt)
-       $(silent)$(TOUCH) $(call quote,$@)
+# Initialize the 💄📝 Les·M·L repository if it is empty.
+ifneq ($(filter $(THISDIR)/%,$(LESML)),)
+$(LESML)/parser.xslt : $(THISDIR)/%/parser.xslt :
+       @$(PRINTF) '%s\n' $(call quote,Initializing git submodule at `$*´)
+       $(silent)cd $(THISDIR) && $(GIT) submodule update --init $(call quote,$*)
+endif
 
 # Create an empty codex metadata file if none exists.
 $(SRCDIR)/@ :
 
 # Create an empty codex metadata file if none exists.
 $(SRCDIR)/@ :
@@ -282,7 +293,7 @@ $(SRCDIR)/@ :
 
 # Create category catalogs.
 $(categorycatalogs) : $(BUILDDIR)/catalogs/categories/%/index : FORCE
 
 # Create category catalogs.
 $(categorycatalogs) : $(BUILDDIR)/catalogs/categories/%/index : FORCE
-       $(call makeandsavedeps,$*,$(call entriesforcategory,$*),$(call makecategorycatalog,$*))
+       $(call makeandsavedeps,$@,$*,$(call entriesforcategory,$*),$(call makecategorycatalog,$*))
 
 # Create entry catalogs.
 $(entrycatalogs) : $(BUILDDIR)/catalogs/entries/% :
 
 # Create entry catalogs.
 $(entrycatalogs) : $(BUILDDIR)/catalogs/entries/% :
@@ -294,7 +305,7 @@ $(entrycatalogs) : $(BUILDDIR)/catalogs/entries/% :
        $(silent)$(XMLCATALOG) --add uri '@' $(call quote,$*) --noout $(call quote,$@)
 
 $(BUILDDIR)/catalogs/indices/index : FORCE | $(SRCDIR)/@
        $(silent)$(XMLCATALOG) --add uri '@' $(call quote,$*) --noout $(call quote,$@)
 
 $(BUILDDIR)/catalogs/indices/index : FORCE | $(SRCDIR)/@
-       $(call makeandsavedeps,index,$(categories),$(call makeindexcatalog,))
+       $(call makeandsavedeps,$@,index,$(categories),$(call makeindexcatalog,))
 
 $(BUILDDIR)/catalogs/indices/fullindex : FORCE | $(SRCDIR)/@
 
 $(BUILDDIR)/catalogs/indices/fullindex : FORCE | $(SRCDIR)/@
-       $(call makeandsavedeps,fullindex,$(categories),$(call makeindexcatalog,1))
+       $(call makeandsavedeps,$@,fullindex,$(categories),$(call makeindexcatalog,1))
This page took 0.028731 seconds and 4 git commands to generate.