summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-08-10 11:22:38 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-08-10 11:22:38 -0400
commitf22246a490fcb1e8d60f8ae0759b3f1daca7c061 (patch)
tree6ddfb70728fbc2a4920da544c5d4971958bea900 /build-aux
parent1cfeca882ebbd2de350a62e97e7ace35d3a57644 (diff)
fix build system
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/Makefile.each.head/00-files.mk13
-rw-r--r--build-aux/Makefile.each.head/zz-mod.mk1
-rw-r--r--build-aux/Makefile.each.tail/00-dist.mk1
-rw-r--r--build-aux/Makefile.each.tail/00-mod.mk41
-rw-r--r--build-aux/Makefile.each.tail/10-nested.mk3
-rw-r--r--build-aux/Makefile.each.tail/60-am.mk16
-rw-r--r--build-aux/Makefile.head.mk14
-rw-r--r--build-aux/Makefile.once.head/10-dist.mk4
-rw-r--r--build-aux/Makefile.once.head/10-files.mk5
-rw-r--r--build-aux/Makefile.once.head/10-lt.mk8
-rw-r--r--build-aux/Makefile.once.head/10-write-ifchanged.mk3
-rw-r--r--build-aux/Makefile.once.head/20-sd.mk16
-rw-r--r--build-aux/Makefile.once.head/30-am.mk22
-rw-r--r--build-aux/Makefile.once.head/zz-mod.mk32
-rw-r--r--build-aux/Makefile.once.tail/00-dist.mk2
-rw-r--r--build-aux/Makefile.once.tail/00-mod.mk32
-rw-r--r--build-aux/Makefile.once.tail/00-noop.mk2
-rw-r--r--build-aux/Makefile.tail.mk2
18 files changed, 141 insertions, 76 deletions
diff --git a/build-aux/Makefile.each.head/00-files.mk b/build-aux/Makefile.each.head/00-files.mk
index c9a94e11a8..c4820cfb1f 100644
--- a/build-aux/Makefile.each.head/00-files.mk
+++ b/build-aux/Makefile.each.head/00-files.mk
@@ -17,13 +17,16 @@ files.src.src ?=
files.src.int ?=
files.src.cfg ?=
files.src.gen ?=
-files.src = $(sort $(foreach _files.v,$(filter files.src.%,$(.VARIABLES)),$($(_files.v))))
files.out.slow ?=
files.out.int ?=
files.out.cfg ?=
-$(eval $(foreach t,$(files.groups),files.out.$t ?=$(at.nl)))
-files.out = $(sort $(foreach _files.v,$(filter files.out.%,$(.VARIABLES)),$($(_files.v))))
-$(eval $(foreach t,$(files.groups),files.sys.$t ?=$(at.nl)))
-files.sys = $(sort $(foreach _files.v,$(filter files.sys.%,$(.VARIABLES)),$($(_files.v))))
+# define files.out.$(group) files.sys.$(group) for every files.group
+$(eval $(foreach t,$(files.groups),files.out.$t ?=$(at.nl)files.sys.$t ?=$(at.nl)))
+
+# define files.src, files.out, and files.sys aggregates
+$(eval \
+ files.src = $$(sort $(foreach _files.v,$(filter files.src.%,$(.VARIABLES)),$$($(_files.v))))$(at.nl)\
+ files.out = $$(sort $(foreach _files.v,$(filter files.out.%,$(.VARIABLES)),$$($(_files.v))))$(at.nl)\
+ files.sys = $$(sort $(foreach _files.v,$(filter files.sys.%,$(.VARIABLES)),$$($(_files.v)))))
diff --git a/build-aux/Makefile.each.head/zz-mod.mk b/build-aux/Makefile.each.head/zz-mod.mk
deleted file mode 100644
index b83c2235a2..0000000000
--- a/build-aux/Makefile.each.head/zz-mod.mk
+++ /dev/null
@@ -1 +0,0 @@
-_mod.each := $(sort $(_mod.each) $(filter-out $(_mod.once),$(_mod.vars)))
diff --git a/build-aux/Makefile.each.tail/00-dist.mk b/build-aux/Makefile.each.tail/00-dist.mk
new file mode 100644
index 0000000000..df363b54df
--- /dev/null
+++ b/build-aux/Makefile.each.tail/00-dist.mk
@@ -0,0 +1 @@
+_dist.files := $(strip $(_dist.files) $(_files.src))
diff --git a/build-aux/Makefile.each.tail/00-mod.mk b/build-aux/Makefile.each.tail/00-mod.mk
new file mode 100644
index 0000000000..6346173b8c
--- /dev/null
+++ b/build-aux/Makefile.each.tail/00-mod.mk
@@ -0,0 +1,41 @@
+# Copyright (C) 2016 Luke Shumaker
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+$(outdir)/at-variables $(outdir)/at-variables-local: _mod.VARIABLES := $(filter-out $(call _mod.quote-pattern,$(_at.VARIABLES)),$(.VARIABLES))
+$(outdir)/at-variables-global:
+ @printf '%s\n' $(call _mod.quote-shell-each,$(sort $(.VARIABLES)))
+$(outdir)/at-variables-local:
+ @printf '%s\n' $(call _mod.quote-shell-each,$(sort $(_mod.VARIABLES)))
+$(outdir)/at-variables $(outdir)/at-values:
+ @printf '%s\n' $(call _mod.quote-shell-each,$(sort $(.VARIABLES),$(_mod.VARIABLES)))
+$(outdir)/at-variables/%:
+ @printf '%s\n' $(call _mod.quote-shell,$($*))
+$(outdir)/at-values/%:
+ @printf '%s\n' $(call _mod.quote-shell,$(value $*))
+.PHONY: $(addprefix $(outdir)/, at-variables-global at-variables-local at-variables at-values)
+at.targets += $(addprefix $(outdir)/, at-variables-global at-variables-local at-variables at-values at-variables/% at-values/%)
+
+$(outdir)/at-modules:
+ @printf 'Autothing modules used in this project:\n'
+ @printf ' - %s\n' $(foreach _mod.tmp,$(_mod.modules),$(call _mod.quote-shell,$(_mod.tmp) $(mod.$(_mod.tmp).description)))|column -t -s $$'\t'
+$(addprefix $(outdir)/at-modules/,$(_mod.modules)): $(outdir)/at-modules/%:
+ @printf 'Name : %s\n' $(call _mod.quote-shell,$*)
+ @printf 'Description : %s\n' $(call _mod.quote-shell,$(mod.$*.description))
+ @echo 'Contains Files :' $(call _mod.quote-shell-each,$(call at.relto,$(topsrcdir),$(sort $(mod.$*.files) $(wildcard $(topsrcdir)/build-aux/Makefile.*/??-$*.mk))))
+ @echo 'Depends on :' $(mod.$*.depends)
+
+$(outdir)/at-noop:
+.PHONY: $(outdir)/at-noop
+at.targets += $(outdir)/at-noop
diff --git a/build-aux/Makefile.each.tail/10-nested.mk b/build-aux/Makefile.each.tail/10-nested.mk
index e9d02ca5b0..5e5a40b921 100644
--- a/build-aux/Makefile.each.tail/10-nested.mk
+++ b/build-aux/Makefile.each.tail/10-nested.mk
@@ -13,7 +13,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-$(addprefix $(outdir)/,$(nested.targets)): $(outdir)/%: $(addsuffix /%,$(call at.addprefix,$(outdir),$(nested.subdirs)))
+$(eval $(foreach _tmp.nested,$(nested.targets),\
+ $$(outdir)/$(_tmp.nested): $$(addsuffix /$(_tmp.nested),$$(call at.addprefix,$$(outdir),$$(nested.subdirs)))$(at.nl)))
.PHONY: $(addprefix $(outdir)/,$(nested.targets))
at.subdirs += $(nested.subdirs)
diff --git a/build-aux/Makefile.each.tail/60-am.mk b/build-aux/Makefile.each.tail/60-am.mk
index 2c0e59212a..ff3230776b 100644
--- a/build-aux/Makefile.each.tail/60-am.mk
+++ b/build-aux/Makefile.each.tail/60-am.mk
@@ -7,6 +7,22 @@ $(eval \
$(foreach f,$(am.LTLIBRARIES),$(call _am.per_LTLIBRARY,$f,$(call am.file2var,$f))$(at.nl))\
$(foreach d,$(am.inst2dirs) ,$(call _am.per_directory,$d)$(at.nl)))
+$(DESTDIR)$(includedir)/%.h: $(srcdir)/include/%.h
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(sysusersdir)/%.conf: $(srcdir)/%.sysusers
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(sysusersdir)/%.conf: $(outdir)/%.sysusers
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(sysctldir)/%.conf: $(srcdir)/%.sysctl
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(sysctldir)/%.conf: $(outdir)/%.sysctl
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+
at.subdirs += $(am.subdirs)
files.sys.all += $(foreach p,$(am.primaries),$(am.inst_$p))
files.out.all += $(foreach p,$(am.primaries),$(am.noinst_$p))
diff --git a/build-aux/Makefile.head.mk b/build-aux/Makefile.head.mk
index 105432c77a..c2ce3075b2 100644
--- a/build-aux/Makefile.head.mk
+++ b/build-aux/Makefile.head.mk
@@ -24,13 +24,13 @@ ifeq ($(origin _at.NO_ONCE),undefined)
# These 4 functions are all $(call _at.func,parent,child)
_at.is_strict_subdir = $(filter $(abspath $1)/%,$(abspath $2))
_at.is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.)
-_at.relbase = $(strip \
- $(if $(call _at.is_subdir,$1,$2), \
- $(patsubst $(abspath $1)/%,%,$(abspath $2)/.), \
+_at.relbase = $(strip \
+ $(if $(call _at.is_subdir,$1,$2), \
+ $(patsubst %/.,$(patsubst $(abspath $1)/%,%,$(abspath $2)/.)), \
$(abspath $2)))
-_at.relto = $(strip \
- $(if $(call _at.is_subdir,$1,$2), \
- $(patsubst $(abspath $1)/%,%,$(abspath $2)/.), \
+_at.relto = $(strip \
+ $(if $(call _at.is_subdir,$1,$2), \
+ $(patsubst %/.,%,$(patsubst $(abspath $1)/%,%,$(abspath $2)/.)), \
../$(call _at.relto,$(dir $1),$2)))
# These 3 functions only take one operand; we define public multi-operand
@@ -51,6 +51,8 @@ _at.target_variable = $(_at.target_variable.$(flavor $2))
_at.target_variable.recursive = $1: private $2 = $(subst $(at.nl),$$(at.nl),$(value $2))
_at.target_variable.simple = $1: private $2 := $$($2)
+_at.quote-pattern = $(subst %,\%,$(subst \,\\,$1))
+
# Sanity checking ######################################################
ifeq ($(filter undefine,$(.FEATURES)),)
$(error Autothing: We need a version of Make that supports 'undefine')
diff --git a/build-aux/Makefile.once.head/10-dist.mk b/build-aux/Makefile.once.head/10-dist.mk
index 0e13ea2e28..e139096576 100644
--- a/build-aux/Makefile.once.head/10-dist.mk
+++ b/build-aux/Makefile.once.head/10-dist.mk
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-mod.dist.description = Make distribution tarballs
+mod.dist.description = `dist` target for distribution tarballs
# Developer configuration
@@ -28,6 +28,8 @@ ifeq ($(dist.version),)
$(error Autothing module: dist: dist.version must be set)
endif
+_dist.files =
+
# User configuration
CP ?= cp
diff --git a/build-aux/Makefile.once.head/10-files.mk b/build-aux/Makefile.once.head/10-files.mk
index 2af7bf8f20..54417356ee 100644
--- a/build-aux/Makefile.once.head/10-files.mk
+++ b/build-aux/Makefile.once.head/10-files.mk
@@ -24,7 +24,10 @@ files.generate ?= files.generate
.DEFAULT_GOAL = $(files.default)
# Standard creative PHONY targets
-nested.targets += $(foreach g,$(files.groups), $g install-$g install-$gdirs)
+nested.targets += $(files.generate)
+nested.targets += install installdirs
+nested.targets += $(foreach g,$(files.groups),$g)
+nested.targets += $(foreach g,$(filter-out $(files.default),$(files.groups)),install-$g install-$gdirs)
# Standard destructive PHONY targets
nested.targets += uninstall mostlyclean clean distclean maintainer-clean
diff --git a/build-aux/Makefile.once.head/10-lt.mk b/build-aux/Makefile.once.head/10-lt.mk
index c8410d4e38..b014a0f2a4 100644
--- a/build-aux/Makefile.once.head/10-lt.mk
+++ b/build-aux/Makefile.once.head/10-lt.mk
@@ -1,12 +1,12 @@
-mod.lt.description = Easy handling of libtool dependencies
+mod.lt.description = (systemd) Easy handling of libtool dependencies
mod.lt.deps += files
_lt.dups = $(sort $(foreach l,$1,$(if $(filter-out 1,$(words $(filter $l,$1))),$l)))
-_lt.patsubst-all = $(if $1,$(call _sd.patsubst-all,$(wordlist 2,$(words $1),$1),$2,$(patsubst $(firstword $1),$2,$3)),$3)
-_lt.unLIBPATTERNS = $(foreach _lt.tmp,$1,$(if $(filter $(.LIBPATTERNS),$(_lt.tmp)),$(call _lt.patsubst-all,$(.LIBPATTERNS),-l%,$(_lt.tmp)),$(_lt.tmp)))
+_lt.patsubst-all = $(if $1,$(call _lt.patsubst-all,$(wordlist 2,$(words $1),$1),$2,$(patsubst $(firstword $1),$2,$3)),$3)
+_lt.unLIBPATTERNS = $(foreach _lt.tmp,$1,$(if $(filter $(.LIBPATTERNS),$(notdir $(_lt.tmp))),$(call _lt.patsubst-all,$(.LIBPATTERNS),-l%,$(notdir $(_lt.tmp))),$(_lt.tmp)))
# The semantics for the de-dup bit are a bit weird. My head hurts thinking
# about them. TODO: clarify/simplify/something
lt.rpath = $(dir $(patsubst $(DESTDIR)%,%,$(filter %/$(@F),$(files.sys))))
-_lt.link_files = $(filter %.o %.lo %.la -l%,$(call _lt.unLIBPATTERNS$,$^))
+_lt.link_files = $(filter %.o %.lo %.la -l%,$(call _lt.unLIBPATTERNS,$^))
lt.link_files = $(filter-out $(call _lt.dups,$(_lt.link_files)),$(_lt.link_files))
diff --git a/build-aux/Makefile.once.head/10-write-ifchanged.mk b/build-aux/Makefile.once.head/10-write-ifchanged.mk
index 7917201159..b0a5ac478f 100644
--- a/build-aux/Makefile.once.head/10-write-ifchanged.mk
+++ b/build-aux/Makefile.once.head/10-write-ifchanged.mk
@@ -1,3 +1,4 @@
-mod.write-ifchanged.description = build-aux/write-ifchanged helper script
+mod.write-ifchanged.description = `write-ifchanged` auxiliary build script
+mod.write-ifchanged.files += $(topsrcdir)/build-aux/write-ifchanged
WRITE_IFCHANGED ?= $(topsrcdir)/build-aux/write-ifchanged
diff --git a/build-aux/Makefile.once.head/20-sd.mk b/build-aux/Makefile.once.head/20-sd.mk
index 6c943978e3..6b8dd580cc 100644
--- a/build-aux/Makefile.once.head/20-sd.mk
+++ b/build-aux/Makefile.once.head/20-sd.mk
@@ -21,7 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-mod.sd.description = systemd build rules
+mod.sd.description = (systemd) shared build rules
mod.sd.depends += am
TESTS ?=
@@ -47,10 +47,11 @@ sd.COMPILE = $(CC) $(sd.ALL_CPPFLAGS) $(sd.ALL_CFLAGS)
sd.LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(sd.ALL_LIBTOOLFLAGS) --mode=compile $(CC) $(sd.ALL_CPPFLAGS) $(sd.ALL_CFLAGS)
sd.LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(sd.ALL_LIBTOOLFLAGS) --mode=link $(CCLD) $(sd.ALL_CFLAGS) $(sd.ALL_LDFLAGS) -o $@
-am.INSTALL_PROGRAM = $(AM_V_PROG)$(LIBTOOL) $(AM_V_lt) --tag=CC $(sd.ALL_LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $< $@
-am.INSTALL_SCRIPT = $(AM_V_SCRIPT)$(INSTALL_SCRIPT) $< $@
-am.INSTALL_LTLIBRARY = $(AM_V_LIB)$(LIBTOOL) $(AM_V_lt) --tag=CC $(sd.ALL_LIBTOOLFLAGS) --mode=install $(INSTALL) $< $@
-am.INSTALL_DATA = $(AM_V_DATA)$(INSTALL_DATA) $< $@
+am.INSTALL_PROGRAMS = $(AM_V_PROG)$(LIBTOOL) $(AM_V_lt) --tag=CC $(sd.ALL_LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $< $@
+am.INSTALL_SCRIPTS = $(AM_V_SCRIPT)$(INSTALL_SCRIPT) $< $@
+am.INSTALL_LTLIBRARIES = $(AM_V_LIB)$(LIBTOOL) $(AM_V_lt) --tag=CC $(sd.ALL_LIBTOOLFLAGS) --mode=install $(INSTALL) $< $@
+am.INSTALL_DATA = $(AM_V_DATA)$(INSTALL_DATA) $< $@
+am.INSTALL_HEADERS = $(AM_V_HEADER)$(INSTALL_DATA) $< $@
CC ?= c99
CCLD ?= c99
@@ -133,6 +134,11 @@ AM_V_LIB_ ?= $(AM_V_LIB_$(AM_DEFAULT_VERBOSITY))
AM_V_LIB_0 ?= @echo " LIB " $@;
AM_V_LIB_1 ?=
+AM_V_HEADER ?= $(AM_V_HEADER_$(V))
+AM_V_HEADER_ ?= $(AM_V_HEADER_$(AM_DEFAULT_VERBOSITY))
+AM_V_HEADER_0 ?= @echo " HEADER " $@;
+AM_V_HEADER_1 ?=
+
AM_V_at ?= $(AM_V_at_$(V))
AM_V_at_ ?= $(AM_V_at_$(AM_DEFAULT_VERBOSITY))
AM_V_at_0 ?= @
diff --git a/build-aux/Makefile.once.head/30-am.mk b/build-aux/Makefile.once.head/30-am.mk
index 52504c6dcb..65cbc33ed0 100644
--- a/build-aux/Makefile.once.head/30-am.mk
+++ b/build-aux/Makefile.once.head/30-am.mk
@@ -1,10 +1,12 @@
-mod.am.description = Support for Automake variables (systemd specific)
+mod.am.description = (systemd) Automake-to-Autothing magic
mod.am.depends += gnuconf
am.inst2noinst_DATA = $(notdir \
$(patsubst $(sysusersdir)/%.conf,%.sysusers,\
$(patsubst $(sysctldir)/%.conf,%.sysctl,\
$1)))
+am.inst2noinst_HEADERS = $(abspath $(addprefix $(srcdir)/include/,$(notdir $1)))
+
am.var_PROGRAMS = $1_SOURCES nodist_$1_SOURCES $1_CFLAGS $1_CPPFLAGS $1_LDFLAGS $1_LDADD
am.var_LTLIBRARIES = $1_SOURCES nodist_$1_SOURCES $1_CFLAGS $1_CPPFLAGS $1_LDFLAGS $1_LIBADD
@@ -21,7 +23,7 @@ $(eval $(foreach p,$(am.primaries),am.inst2noinst_$p ?= $$(notdir $$1)$(at.nl)))
am.primary2dirs = $(filter $(patsubst %dir,%,$(filter %dir,$(.VARIABLES))),\
$(patsubst %_$1,%,$(filter %_$1,$(.VARIABLES))))
-am.inst2dirs = $(sort $(dir $(foreach p,$(am.primaries),$(am.inst_$p))))
+am.inst2dirs = $(sort $(patsubst %/,%,$(dir $(foreach p,$(am.primaries),$(am.inst_$p)))))
am.file2var = $(subst -,_,$(subst .,_,$1))
am.file2sources = $(addprefix $(srcdir)/,$(notdir $($(am.file2var)_SOURCES)))
@@ -35,13 +37,11 @@ define _am.per_primary
noinst_$1 ?=
check_$1 ?=
-am.inst_$1 := $$(foreach d,$$(call am.primary2dirs,$1),$$($$d_$1))
+am.inst_$1 := $$(foreach d,$$(call am.primary2dirs,$1),$$(addprefix $$($$ddir)/,$$(notdir $$($$d_$1))))
am.noinst_$1 := $$(noinst_$1)
am.check_$1 := $$(check_$1)
$(foreach d,$(call am.primary2dirs,$1) noinst check,undefine $d_$1$(at.nl))
-ifneq ($$(am.inst_$1),)
-$$(am.inst_$1): private am.INSTALL = $$(am.INSTALL_$1)
-endif
+$$(addprefix $$(DESTDIR),$$(am.inst_$1)): private am.INSTALL = $$(am.INSTALL_$1)
am.$1 = $$(am.check_$1) $$(am.noinst_$1) $$(call am.inst2noinst_$1,$$(am.inst_$1))
endef
########################################################################
@@ -89,4 +89,12 @@ $$(DESTDIR)$1/%: $$(srcdir)/%
@$$(NORMAL_INSTALL)
$$(am.INSTALL)
endef
-
+########################################################################
+define _am.per_include_directory
+$$(DESTDIR)$1/%: $$(outdir)/include/%
+ @$$(NORMAL_INSTALL)
+ $$(am.INSTALL)
+$$(DESTDIR)$1/%: $$(srcdir)/include/%
+ @$$(NORMAL_INSTALL)
+ $$(am.INSTALL)
+endef
diff --git a/build-aux/Makefile.once.head/zz-mod.mk b/build-aux/Makefile.once.head/zz-mod.mk
index 7e526063c3..438f01e2ae 100644
--- a/build-aux/Makefile.once.head/zz-mod.mk
+++ b/build-aux/Makefile.once.head/zz-mod.mk
@@ -13,14 +13,30 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-mod.mod.description = Print information about Autothing modules
+mod.mod.description = Display information about Autothing modules
-_mod.target = at-mod-info
-_mod.modules := $(sort $(patsubst %.mk,%,$(filter %.mk,$(subst -, ,$(notdir $(wildcard $(topsrcdir)/build-aux/Makefile.*/??-*.mk))))))
-_mod.quote = '$(subst ','\'',$1)'
+# The trickery that is _mod.empty/_mod.space is from ยง6.2 of the GNU Make
+# manual, "The Two Flavors of Variables".
+_mod.empty :=
+_mod.space := $(_mod.empty) #
+undefine _mod.empty
+# _mod.rest is equivalent to GMSL rest.
+_mod.rest = $(wordlist 2,$(words $1),$1)
-$(eval $(foreach _mod.tmp,$(_mod.modules),mod.$(_mod.tmp).description ?=$(at.nl)mod.$(_mod.tmp).depends ?=$(at.nl)))
+_mod.file2mod = $(foreach _mod.tmp,$(patsubst %.mk,%,$(notdir $1)),$(subst $(_mod.space),-,$(call _mod.rest,$(subst -, ,$(_mod.tmp)))))
-_mod.vars = $(filter $(addsuffix .%,$(_mod.modules)),$(.VARIABLES))
-_mod.once := $(_mod.vars)
-_mod.each :=
+_mod.modules := $(sort $(call _mod.file2mod,$(wildcard $(topsrcdir)/build-aux/Makefile.*/??-*.mk)))
+undefine _mod.rest
+undefine _mod.file2mod
+
+$(eval $(foreach _mod.tmp,$(_mod.modules),\
+ mod.$(_mod.tmp).description ?=$(at.nl)\
+ mod.$(_mod.tmp).depends ?=$(at.nl)\
+ mod.$(_mod.tmp).files ?=$(at.nl)))
+
+_mod.quote-pattern = $(subst %,\%,$(subst \,\\,$1))
+_mod.quote-shell-each = $(foreach _mod.tmp,$1,$(call _mod.quote-shell,$(_mod.tmp)))
+
+# I put this as the last line in the file because it confuses Emacs syntax
+# highlighting and makes the remainder of the file difficult to edit.
+_mod.quote-shell = $(subst $(at.nl),'$$'\n'','$(subst ','\'',$1)')
diff --git a/build-aux/Makefile.once.tail/00-dist.mk b/build-aux/Makefile.once.tail/00-dist.mk
index 6c6aaedbce..3fbe0c4012 100644
--- a/build-aux/Makefile.once.tail/00-dist.mk
+++ b/build-aux/Makefile.once.tail/00-dist.mk
@@ -15,7 +15,7 @@
_dist.copyfile = $(MKDIR_P) $(dir $2) && $(CP) -T $1 $2
_dist.addfile = $(call _dist.copyfile,$3,$2/$(call at.relto,$1,$3))
-$(topoutdir)/$(dist.pkgname)-$(dist.version): $(foreach v,$(filter std.src_files/% std.gen_files/%,$(.VARIABLES)),$($v))
+$(topoutdir)/$(dist.pkgname)-$(dist.version): $(_dist.files)
$(RM) -r $@ $(@D)/.tmp.$(@F)
$(MKDIR) $(@D)/.tmp.$(@F)
$(foreach f,$^,$(call _dist.addfile,$(topsrcdir),$(@D)/.tmp.$(@F),$f)$(at.nl))
diff --git a/build-aux/Makefile.once.tail/00-mod.mk b/build-aux/Makefile.once.tail/00-mod.mk
deleted file mode 100644
index 68350f09ea..0000000000
--- a/build-aux/Makefile.once.tail/00-mod.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2016 Luke Shumaker
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-$(_mod.target):
- @printf 'Autothing modules used in this project:\n'
- @printf ' - %s\n' $(foreach _mod.tmp,$(_mod.modules),$(call _mod.quote,$(_mod.tmp)))
-$(addprefix $(_mod.target)/,$(_mod.modules)): $(_mod.target)/%:
- @printf 'Module : %s ' $(call _mod.quote,$*)
- @$(if $(at.mod.$*.description),printf ' - %s' $(call _mod.quote,mod.$*.description))
- @echo
- @echo Depends on : $(mod.$*.depends)
- @echo User configuration:
- @egrep '^\s*[^:#]+\s*\?=' $(topsrcdir)/build-aux/Makefile.once.head/??-$*.mk 2>/dev/null | sed 's|^\s*||;s|?=|:' | grep -v -e ^'_' -e ^'$*' | column -t -s: |sed 's|^| |'
- @echo Developer global inputs:
- @egrep '^\s*[^:#]+\s*\?=' $(topsrcdir)/build-aux/Makefile.once.head/??-$*.mk 2>/dev/null | sed 's|^\s*||;s|?=|:' | grep ^'$*\.' | column -t -s: |sed 's|^| |'
- @echo Developer per-directory inputs:
- @egrep '^\s*[^:#]+\s*\?=' $(topsrcdir)/build-aux/Makefile.each.head/??-$*.mk 2>/dev/null | sed 's|^\s*||;s|?=|:' | grep ^'$*\.' | column -t -s: |sed 's|^| |'
- @echo Developer outputs:
- @egrep '^\s*[^:#]+\s*(|:|::)=' $(topsrcdir)/build-aux/Makefile.once.head/??-$*.mk 2>/dev/null | sed 's|^\s*||;s|?=|:' | grep ^'$*\.' | column -t -s: |sed 's|^| |'
-.PHONY: $(addprefix mod/,$(_mod.modules))
diff --git a/build-aux/Makefile.once.tail/00-noop.mk b/build-aux/Makefile.once.tail/00-noop.mk
deleted file mode 100644
index bac2ec11dd..0000000000
--- a/build-aux/Makefile.once.tail/00-noop.mk
+++ /dev/null
@@ -1,2 +0,0 @@
-noop:
-.PHONY: noop
diff --git a/build-aux/Makefile.tail.mk b/build-aux/Makefile.tail.mk
index aeba2d1b09..2e4adc611b 100644
--- a/build-aux/Makefile.tail.mk
+++ b/build-aux/Makefile.tail.mk
@@ -22,7 +22,7 @@ _at.tmp_subdirs := $(call at.addprefix,$(outdir),$(at.subdirs))
# Clean the environment
$(eval \
- $(foreach _at.tmp_variable,$(filter-out _at.tmp_variable $(_at.VARIABLES),$(.VARIABLES)),\
+ $(foreach _at.tmp_variable,$(filter-out $(call _at.quote-pattern,_at.tmp_variable $(_at.VARIABLES)),$(.VARIABLES)),\
$(call _at.target_variable,$(_at.tmp_targets),$(_at.tmp_variable))$(at.nl)\
undefine $(_at.tmp_variable)$(at.nl)))