summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/Makefile.README.mk20
-rw-r--r--build-aux/Makefile.README.old.txt35
-rw-r--r--build-aux/Makefile.README.txt447
-rw-r--r--build-aux/Makefile.each.head/00-am.mk3
-rw-r--r--build-aux/Makefile.each.head/00-dist.mk23
-rw-r--r--build-aux/Makefile.each.head/00-files.mk32
-rw-r--r--build-aux/Makefile.each.head/00-gitfiles.mk20
-rw-r--r--build-aux/Makefile.each.head/00-nested.mk16
-rw-r--r--build-aux/Makefile.each.head/00-sd.mk6
-rw-r--r--build-aux/Makefile.each.head/00-texinfo.mk16
-rw-r--r--build-aux/Makefile.each.tail/00-dist.mk1
-rw-r--r--build-aux/Makefile.each.tail/00-mod.mk44
-rw-r--r--build-aux/Makefile.each.tail/00-var.mk22
-rw-r--r--build-aux/Makefile.each.tail/10-files.mk57
-rw-r--r--build-aux/Makefile.each.tail/10-nested.mk21
-rw-r--r--build-aux/Makefile.each.tail/11-texinfo.mk38
-rw-r--r--build-aux/Makefile.each.tail/50-sd.mk87
-rw-r--r--build-aux/Makefile.each.tail/60-am.mk12
-rw-r--r--build-aux/Makefile.each.tail/70-sdcompletion.mk23
-rw-r--r--build-aux/Makefile.each.tail/70-sdman.mk113
-rw-r--r--build-aux/Makefile.head.mk116
-rw-r--r--build-aux/Makefile.once.head/00-quote.mk49
-rw-r--r--build-aux/Makefile.once.head/00-var.mk36
-rw-r--r--build-aux/Makefile.once.head/10-dist.mk85
-rw-r--r--build-aux/Makefile.once.head/10-files.mk100
-rw-r--r--build-aux/Makefile.once.head/10-gitfiles.mk75
-rw-r--r--build-aux/Makefile.once.head/10-gnuconf.mk205
-rw-r--r--build-aux/Makefile.once.head/10-lt.mk57
-rw-r--r--build-aux/Makefile.once.head/10-nested.mk46
-rw-r--r--build-aux/Makefile.once.head/10-texinfo.mk47
-rw-r--r--build-aux/Makefile.once.head/10-write-atomic.mk23
-rw-r--r--build-aux/Makefile.once.head/10-write-ifchanged.mk23
-rw-r--r--build-aux/Makefile.once.head/20-amcfg.mk84
-rw-r--r--build-aux/Makefile.once.head/20-sd.mk231
-rw-r--r--build-aux/Makefile.once.head/20-sdman.mk79
-rw-r--r--build-aux/Makefile.once.head/30-am.mk336
-rw-r--r--build-aux/Makefile.once.head/zz-mod.mk59
-rw-r--r--build-aux/Makefile.once.tail/00-dist.mk31
-rw-r--r--build-aux/Makefile.once.tail/10-sd.mk48
-rw-r--r--build-aux/Makefile.tail.mk40
-rwxr-xr-xbuild-aux/write-atomic21
41 files changed, 2612 insertions, 215 deletions
diff --git a/build-aux/Makefile.README.mk b/build-aux/Makefile.README.mk
new file mode 100644
index 0000000000..fe9010aafc
--- /dev/null
+++ b/build-aux/Makefile.README.mk
@@ -0,0 +1,20 @@
+# This Makefile is a minimal stub that exists to allow the
+# `at-modules` set of Make targets to print documentation for the
+# present Autothing modules.
+#
+# This file is part of the documentation for Autothing.
+#
+# Copyright (C) 2017 Luke Shumaker
+#
+# This documentation file is placed into the public domain. If that
+# is not possible in your legal system, I grant you permission to use
+# it in absolutely every way that I can legally grant to you.
+
+dist.pkgname = autothing
+dist.version = 1.0
+gnuconf.pkgname = autothing
+
+topoutdir ?= .
+topsrcdir ?= .
+include $(topsrcdir)/build-aux/Makefile.head.mk
+include $(topsrcdir)/build-aux/Makefile.tail.mk
diff --git a/build-aux/Makefile.README.old.txt b/build-aux/Makefile.README.old.txt
new file mode 100644
index 0000000000..b4ea562be4
--- /dev/null
+++ b/build-aux/Makefile.README.old.txt
@@ -0,0 +1,35 @@
+Obsolete
+========
+
+The following was written for previous versions of Autothing. I'm
+leaving it here for now because I'll likely canibalize it for other
+bits of documentation, either for Autothing itself, the `files`
+module, or the `dist` module.
+
+High-level overview
+-------------------
+
+It also makes it easy to follow the GNU standards for your makefiles:
+it takes care of this entire table of .PHONY targets for you:
+
+| this | and this | are aliases for this |
+|------+------------------+--------------------------------------------------------|
+| all | build | $(outdir)/build |
+| | install | $(outdir)/install |
+| | uninstall | $(outdir)/uninstall |
+| | mostlyclean | $(outdir)/mostlyclean |
+| | clean | $(outdir)/clean |
+| | distclean | $(outdir)/distclean |
+| | maintainer-clean | $(outdir)/maintainer-clean |
+| | check | $(outdir)/check (not implemented for you) |
+| | dist | $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz (not .PHONY) |
+
+(You are still responsible for implementing the `$(outdir)/check`
+target in each of your Makefiles.)
+
+----
+Copyright (C) 2016 Luke Shumaker
+
+This documentation file is placed into the public domain. If that is
+not possible in your legal system, I grant you permission to use it in
+absolutely every way that I can legally grant to you.
diff --git a/build-aux/Makefile.README.txt b/build-aux/Makefile.README.txt
new file mode 100644
index 0000000000..f67ede2a3d
--- /dev/null
+++ b/build-aux/Makefile.README.txt
@@ -0,0 +1,447 @@
+# -*- Mode: markdown -*-
+
+Autothing 3: The smart way to write GNU Makefiles
+=================================================
+
+Autothing is a thing that does things automatically.
+
+Ok, more helpfully: Autothing is a pair of .mk Makefile fragments
+(`Makefile.head.mk` and `Makefile.tail.mk`) that you can `include`
+from your Makefiles to make them easier to write; specifically, it
+makes it _easy_ to write non-recursive Makefiles--and ones that are
+similar to plain recursive Makefiles, at that!
+
+To many people, talking about GNU Make directly is a non-starter
+because it means giving up the many other features that things like
+GNU Automake provide. Other projects like GNU Automake were created
+to plaster over differences between make(1) implementations; however,
+this isn't all that Automake provides, it also makes it easy to do
+complex things that users want, or the GNU Coding Standards require.
+That's silly; the implementation of these features should be
+orthogonal to plastering over the differences between Make
+implementations. So, in addition to the Automake core, Automake is
+distributed with several "modules" that implement similar feature sets
+to what Automake provides.
+
+Autothing does depend on GNU Make; other make(1) implementations will
+not work. However, if you are open to adding GNU Make as a
+dependency, then Autothing should obviate the need for GNU Automake,
+while also making your Makefiles better.
+
+Non-recursive?
+--------------
+
+ (For those of you who aren't up on Makefile jargon)
+
+When you have a project that spans multiple directories, you'll
+probably want to split up the Makefile, having the appropriate parts
+in each sub-directory. There are a number of strategies you can use
+to approach this.
+
+One of the more prevelant strategies (so much so that GNU make
+includes special support for it) is to write "recursive Makefiles";
+that is, have Make rules that include commands like
+
+ other-directory/libfoo.so:
+ $(MAKE) -C other-directory libfoo.so
+
+or
+
+ other-directory/libfoo.so
+ cd other-directory && $(MAKE) libfoo.so
+
+This approach is popular because it is both very easy to implement,
+and is supported by a wide variety of Make implementations. But, it
+also introduces a wide variety of issues; so much so that a rather
+famous paper was written about it: "Recursive Make Considered Harmful"
+(Miller, 1997).
+
+For all of the arguments against it, and all of the alternative
+approaches, recusive Makefiles are hard to beat because they are just
+so easy to write, and the alternatives... aren't. UNTIL NOW!
+
+Instead of having rules that spawn a separate Make process in another
+directory for targets in that directory, Autothing lets you provide a
+list of directories that include targets that targets in this
+directory might depend on, and Autothing will automagically include
+the Makefile in that other directory into *this* instance of the Make
+program.
+
+ Peter Miller (1997) "Recursive Make Considered Harmful"
+ <http://aegis.sourceforge.net/auug97.pdf>
+
+An example Makefile / Introduction
+----------------------------------
+
+Write your Makefiles of the form:
+
+ # Initialize basic information about how your project is structured.
+ topsrcdir ?= ...
+ topoutdir ?= ...
+
+ # Include the Autothing entry point
+ include $(topsrcdir)/build-aux/Makefile.head.mk
+
+ # Now write your Makefile very similarly to how you normally
+ # would. Just make sure that outputs are relative to $(outdir)
+ # and inputs relative to $(srcdir).
+ $(outdir)/%.o: $(srcdir)/%.c:
+ $(CC) -c -o $@ $<
+ $(outdir)/hello: $(outdir)/hello.o
+
+ # If any of the dependencies of files here are outputs of a
+ # Makefile in another directory, list those directories here.
+ at.subdirs = ...
+
+ # This part is kind of a pain: define a list of ouput targets that
+ # this Makefile produces.
+ at.targets = $(outdir)/%.o $(outdir)/hello
+
+ # Include the Autothing exit point
+ include $(topsrcdir)/build-aux/Makefile.tail.mk
+
+This is similar to, but not quite, the comfortable way that you probably
+already write your Makefiles.
+
+It is recommended that Autothing lives inside of the "build-aux"
+directory in the top level of your project sources; "build-aux" is a
+standard directory for auxiliary build programs and tools.
+
+What does Autothing do for me?
+------------------------------
+
+There are two fundamental things that Autothing provides:
+
+ 1. Variable namespacing
+ 2. Tools for dealing with paths
+
+The first is important because globals are bad for composability.
+
+The second is important because GNU Make is too dumb to know that
+`foo/bar/../baz` == `foo/baz`.
+
+Then, there's something that maybe doesn't belong, but I didn't have the heart
+to cut it out:
+
+ 3. A module (plugin) system, which allows for modules to provide
+ additional feature sets.
+
+The module system is "important" because there are very often common bits that
+you want to be included in every Makefile, and this gives some structure to
+that.
+
+Let's step through each of those features.
+
+## Variable namespacing
+
+When you write a Makefile, you quite likely use (global) variables.
+When you have a project that uses multiple Makefiles, each Makefile
+might have the same variable names, but with different values
+(especially if converting from recursive Make).
+
+You could be very disciplined and carefully name your variables so
+that they don't conflict. This is difficult and error prone normally,
+but becomes neigh-on-impossible if you are converting a large-ish
+project from recursive Make.
+
+So, Autothing provides a solution. If you provide Autothing with a
+list of targets defined in your Makefile (via the `at.targets`
+variable), Autothing will make any variables you defined local to that
+Makefile; they will be present when making targets listed in
+`at.targets`, but will be hidden from other Makfiles that get
+included.
+
+Any variables defined before `Makefile.head.mk` is included are
+treated as truly global; all Makefiles included will have access to
+them.
+
+## Tools for dealing with paths
+
+As stated above, GNU Make is too dumb to realize that `foo/bar/../baz`
+== `foo/baz`; so one has to be reasonably careful about path
+normalization. For dealing with path normalization problems that
+arise because of the way Autothing inclusions work, several global
+functions are provided for dealing with paths.
+
+`$(call at.is_subdir,a,b)` returns whether `b` is a sub-directory of
+`a` (including `a` as a sub-directory of itself).
+`at.is_strict_subdir` does the same, but does not treat `a` as a
+sub-directory of itself. (These function names mimic the terms
+"subset" and "strict subset" in mathematics.) These use an empty
+string for "false" and a non-empty string for "true".
+
+`$(call at.path,files...)` is a generic path-normalization routine.
+The outputs of the other `at.*` functions are already normalized, and
+do not need to be passed through this. Files immediately inside of
+`$(srcdir)` or `$(outdir)` (without another directory name after the
+variable) are already normalized, and do not need to be passed through
+this function either. However, it is always safe to pass a path
+through this function, so if in doubt, call `at.path`.
+
+`$(call at.relbase,dir,files...)` and its cousin `at.relto` take a
+directory and a list of files, and transform each of the filenames to
+be relative to the directory, if the file is inside of the directory.
+Where they differ is that if the file is not inside of the directory;
+`at.relbase` transforms it into an absolute path, while `at.relto`
+prepends as many `../` segments as necessary to make it relative to
+the directory. (These function names mimic the `--relative-base` and
+`--relative-to` flags of the `realpath` utility that is part of GNU
+coreutils.)
+
+If `$(srcdir)` and `$(outdir)` are the same, then `$(call
+at.out2src,files...)` is a no-op, but otherwise it takes a (possibly
+relative) path in `$(outdir)`, and transforms it to the equivalent
+filename in `$(srcdir)`.
+
+`$(call at.addprefix,dir,files...)` takes a directory and a list of
+filenames, and looks at each filename; if it is an absolute path, it
+passes it through (well, "only" normalizes it); if the filename is a
+relative path, it is joined with the given base directory.
+
+## Modules to provide feature sets
+
+The module system serves two purposes
+
+ 1. Allow your developers to share logic between Makefiles in multiple
+ directories.
+ 2. Allow your developers to import "standard" modules implementing
+ common feature sets, so they don't have to.
+
+Distributed along with autothing are some "standard" modules that
+provide commonly desired functionality from Makefiles; tricky little
+things that your developers shouldn't have to implement themselves for
+every project; the things that GNU Automake would take care of if you
+used Automake (a piece of software that Autothing hopes to replace).
+
+The module system is conceptually quite simple: have 4 directories for
+`.mk` makefile snippets that get included at certain points:
+
+ Makefile.once.head/*.mk
+
+ Makefile.each.head/*.mk
+ a/Makefile
+ Makefile.each.tail/*.mk
+
+ Makefile.each.head/*.mk
+ b/Makefile
+ Makefile.each.tail/*.mk
+
+ Makefile.each.head/*.mk
+ c/Makefile
+ Makefile.each.tail/*.mk
+
+ Makefile.once.tail/*.mk
+
+Deciding which of the 4 directories to put your snippets in... you'll
+figure it out pretty quickly once you start playing with it.
+
+Beyond these 4 directories, Autothing itself imposes no structure, but
+there are some conventions that are followed by the distributed along
+with Autothing, and I recommend that your developers follow.
+
+Each of the `.mk` files is name `NN-MODULE.mk` where NN is a number
+(to affect the order that the module files are evaluated in, in case
+of dependencies between them), and MODULE is the module name. Each
+module has "public" variables prefixed with `MODULE.`, and "private"
+variables prefixed with `_MODULE.` (again, "MODULE" being the module
+name). For example, the "groups" parameter of the "files" module is
+configured via the `files.groups` variable. Within this convention,
+Autothing presents itself as a pseudo-module named "at"; that is,
+public Autothing variables are prefixed with `at.`.
+
+If you follow these conventions, then the "mod" module distributed
+along with Autothing can display information about the modules that a
+project uses, and documentation on each module. Running the command
+`make at-modules` (implemented by the "mod" module) will produce a
+list of the modules present in a project, and short descriptions of
+them:
+
+ $ make at-modules
+ Autothing modules used in this project:
+ - dist `dist` target for distribution tarballs (more)
+ - files Keeping track of groups of files (more)
+ - gitfiles Automatically populate files.src.src from git (more)
+ - gnuconf GNU standard configuration variables (more)
+ - mod Display information about Autothing modules (more)
+ - nested Easy nested .PHONY targets (more)
+ - quote Macros to quote tricky strings (more)
+ - texinfo The GNU documentation system (more)
+ - var Depend on the values of variables (more)
+ - write-atomic `write-atomic` auxiliary build script (more)
+ - write-ifchanged `write-ifchanged` auxiliary build script (more)
+
+The "(more)" at the end of a line indicates that there is further
+documentation for that module, which can be produced by running the
+command `make at-modules/MODULE_NAME`. See the output of `make
+at-modules/mod` for instructions on how to produce this further
+documentation for modules you develop.
+
+Besides the "mod" module, the set modules distributed along with
+Autothing primarily exists to provide the bits of (sometimes somewhat
+tricky) functionality required of Makefiles by the GNU Coding
+Standards. Run the `at-modules` commands above for documentation on
+each of them.
+
+Formal interface
+----------------
+
+System requirements:
+ - A version of GNU Make that supports `undefine` (ie, version 3.82
+ and above).
+
+ If the user attempts to use your Autothing-using Makefile with an
+ older version of GNU Make, `Makefile.head.mk` will print an error
+ message and refuse to proceed:
+
+ $ make-3.81
+ build-aux/Makefile.head.mk:58: *** Autothing: We need a version of Make that supports 'undefine'. Stop.
+
+Inputs:
+ - In each `Makefile`:
+ - Before `Makefile.head.mk`:
+ - Variable (mandatory) : `topoutdir`
+ - Variable (mandatory) : `topsrcdir` (must not be a subdirectory of `$(topoutdir)`)
+ - Variable (optional) : `at.Makefile` (Default: `Makefile`)
+ - Between `Makefile.head.mk` and `Makefile.tail.mk`:
+ - Variable: `at.targets` (Default: empty)
+ - Variable: `at.subdirs` (Default: empty)
+ - Files:
+ - `${topsrcdir}/build-aux/Makefile.{each,once}.{head,tail}/*.mk`
+
+ Unfortunately, a limitation of Autothing is that it does require a
+ designated "top" directory; it can't be used to have a sub-project
+ that can also be totally separate and built alone. In your
+ Makefiles, before you include `Makefile.head.mk`, you must tell
+ Autothing what the top directory is by setting `topoutdir` and
+ `topsrcdir`.
+
+ If you wish for your per-directory Makefiles to have a name other
+ than `Makefile` (such as `GNUmakefile` or `makefile`, which GNU Make
+ also looks for by default; or another name for project-specific
+ reasons), Autothing supports this by setting the `at.Makefile`
+ variable. Unfortunately, Autothing does not support having a list
+ of filenames to try; so one must be consistent about the filename
+ throughout the project.
+
+ In the body of each Makefile, you may set the `at.targets` variable
+ to list which targets should have access to the variables defined in
+ the body of that Makefile.
+
+ In the body of each Makefile, you may set the `at.subdirs` variable
+ to list of directories which have their own Makefile which produces
+ targets that targets in this directory depend on. Directories
+ listed in `at.subdirs` may be relative or absolute; if relative,
+ they are interpreted as relative to `$(outdir)`.
+
+Outputs:
+ - Global:
+ - Variable (function): `$(call at.is_subdir, parent, child)`
+ - Variable (function): `$(call at.is_strict_subdir, parent, child)`
+ - Variable (function): `$(call at.relbase, parent, children...)`
+ - Variable (function): `$(call at.relto, parent, children...)`
+ - Variable (function): `$(call at.path, paths...)`
+ - Variable (function): `$(call at.out2src, paths...)`
+ - Variable (function): `$(call at.addprefix, prefix, paths...)`
+ - Variable : `$(at.nl)` # a single newline
+ - Per-directory:
+ - Variable: `$(outdir)`
+ - Variable: `$(srcdir)`
+
+ For dealing with path normalization problems that arise because of
+ the way Autothing inclusions work, several global functions are
+ provided for dealing with paths; see the above "Tools for dealing
+ with paths" section for documentation on each of these functions.
+
+ For convenience, it also provides `$(at.nl)` which is a single
+ newline, as newlines are very difficult to type in Make variable
+ values.
+
+Tips, notes
+-----------
+
+If you use Autoconf (or similar), I recommend having a file at
+`$(topsrcdir)/config.mk.in` of the form
+
+ ifeq ($(origin topsrcdir),undefined)
+ topoutdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+ topsrcdir := $(topoutdir)/@top_srcdir@
+
+ # Any other global variables you might want to set
+
+ endif
+
+Then have `./configure` generate `$(topoutdir)/config.mk` from it by
+placing `AC_CONFIG_FILES([config.mk])` in your `configure.ac`. I
+recommend that you have `config.mk` be the _only_ Makefile edited by
+`./configure`; which will require manual support to have `./configure`
+link/copy the Makefiles unedited into `$(topoutdir)`; you can do this
+by placing something like this in your `configure.ac`:
+
+ AC_OUTPUT([], [], [
+ if test "$srcdir" != .; then
+ find "$srcdir" -name Makefile -printf '%P\n' \
+ | while read -r filename; do
+ mkdir -p "\$(dirname "\$filename")"
+ ln -srfT "$srcdir/\$filename" "\$filename"
+ done
+ fi
+ ])
+
+This will allow you to write your Makefiles in the form:
+
+ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
+ include $(topsrcdir)/build-aux/Makefile.head.mk
+
+ # your Makefile here
+
+ include $(topsrcdir)/build-aux/Makefile.tail.mk
+
+Where you only need to adjust the number of `../` segments in the
+first line based on how deep that directory is.
+
+Further development
+-------------------
+
+Most of the modules distributed along with Autothing have the goal of
+combining to provide the things that the GNU Coding Standards require.
+Between `gnuconf`, `dist`, `files`, and `texinfo`; the GNU Coding
+Standards for Makefiles are nearly entirely satisfied. However, there
+are a few targets that are required, but aren't implemented by a
+module (yet!):
+
+ - `install-strip`
+ - `TAGS`
+ - `check`
+ - `installcheck` (optional, but recommended)
+
+TODO
+----
+
+ - Write documentation on `srcdir`, `outdir`, and out-of-tree builds;
+ I don't think discussions involving the separate `srcdir` and
+ `outdir` make much sense without that context.
+
+Bugs/Limitations
+----------------
+
+ - This documentation file is almost three times as long as the code
+ that it documents.
+
+ - The "parse time" for projects with hundreds of sub-directories
+ (each having a Makefile) can be slow (ex: a project with 166
+ directories has a parse time of around 12 seconds on my box). I
+ blame GNU Make's garbage collector; I don't think it was ever
+ designed to deal with as much "garbage" as Autothing's variable
+ namespacing throws at it.
+
+ - Requires a designated "top" directory; see discussion above.
+
+ - Does not support varying per-directory Makefile names; see
+ discussion above.
+
+----
+Copyright (C) 2016-2017 Luke Shumaker
+
+This documentation file is placed into the public domain. If that is
+not possible in your legal system, I grant you permission to use it in
+absolutely every way that I can legally grant to you.
diff --git a/build-aux/Makefile.each.head/00-am.mk b/build-aux/Makefile.each.head/00-am.mk
new file mode 100644
index 0000000000..09a2d3c5ac
--- /dev/null
+++ b/build-aux/Makefile.each.head/00-am.mk
@@ -0,0 +1,3 @@
+am.CFLAGS ?=
+am.CPPFLAGS ?=
+am.subdirs ?=
diff --git a/build-aux/Makefile.each.head/00-dist.mk b/build-aux/Makefile.each.head/00-dist.mk
new file mode 100644
index 0000000000..924d79aa7c
--- /dev/null
+++ b/build-aux/Makefile.each.head/00-dist.mk
@@ -0,0 +1,23 @@
+# Copyright (C) 2015-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.dist.depends += files
+
+ifeq ($(outdir),$(topoutdir))
+files.out.int += $(addprefix $(dist.pkgname)-*,$(dist.exts) .tar /) .tmp.$(dist.pkgname)-*/
+endif
+
+$(outdir)/dist: $(addprefix $(topoutdir)/$(dist.pkgname)-$(dist.version),$(dist.exts))
+.PHONY: $(outdir)/dist
diff --git a/build-aux/Makefile.each.head/00-files.mk b/build-aux/Makefile.each.head/00-files.mk
new file mode 100644
index 0000000000..c4820cfb1f
--- /dev/null
+++ b/build-aux/Makefile.each.head/00-files.mk
@@ -0,0 +1,32 @@
+# Copyright (C) 2015-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/>.
+
+files.src.src ?=
+files.src.int ?=
+files.src.cfg ?=
+files.src.gen ?=
+
+files.out.slow ?=
+files.out.int ?=
+files.out.cfg ?=
+
+# 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/00-gitfiles.mk b/build-aux/Makefile.each.head/00-gitfiles.mk
new file mode 100644
index 0000000000..b872912015
--- /dev/null
+++ b/build-aux/Makefile.each.head/00-gitfiles.mk
@@ -0,0 +1,20 @@
+# 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/>.
+
+ifeq ($(abspath $(topsrcdir)),$(abspath $(srcdir)))
+files.src.gen += $(gitfiles.file)
+endif
+
+files.src.src += $(_gitfiles.dir.src)
diff --git a/build-aux/Makefile.each.head/00-nested.mk b/build-aux/Makefile.each.head/00-nested.mk
new file mode 100644
index 0000000000..4325825353
--- /dev/null
+++ b/build-aux/Makefile.each.head/00-nested.mk
@@ -0,0 +1,16 @@
+# 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/>.
+
+nested.subdirs ?=
diff --git a/build-aux/Makefile.each.head/00-sd.mk b/build-aux/Makefile.each.head/00-sd.mk
new file mode 100644
index 0000000000..43d1625245
--- /dev/null
+++ b/build-aux/Makefile.each.head/00-sd.mk
@@ -0,0 +1,6 @@
+sd.CFLAGS ?=
+sd.CPPFLAGS ?=
+sd.LDFLAGS ?=
+sd.LIBTOOLFLAGS ?=
+
+sd.sed_files ?=
diff --git a/build-aux/Makefile.each.head/00-texinfo.mk b/build-aux/Makefile.each.head/00-texinfo.mk
new file mode 100644
index 0000000000..88aaeb5262
--- /dev/null
+++ b/build-aux/Makefile.each.head/00-texinfo.mk
@@ -0,0 +1,16 @@
+# Copyright (C) 2016-2017 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/>.
+
+texinfo.docs ?=
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..b023e80235
--- /dev/null
+++ b/build-aux/Makefile.each.tail/00-dist.mk
@@ -0,0 +1 @@
+_dist.files := $(strip $(_dist.files) $(call at.addprefix,$(srcdir),$(filter-out $(files.src.int),$(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..d6514dd93a
--- /dev/null
+++ b/build-aux/Makefile.each.tail/00-mod.mk
@@ -0,0 +1,44 @@
+# 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 quote.pattern,$(_at.VARIABLES)),$(.VARIABLES))
+$(outdir)/at-variables-global:
+ @printf '%s\n' $(call quote.shell-each,$(sort $(.VARIABLES)))
+$(outdir)/at-variables-local:
+ @printf '%s\n' $(call quote.shell-each,$(sort $(_mod.VARIABLES)))
+$(outdir)/at-variables $(outdir)/at-values:
+ @printf '%s\n' $(call quote.shell-each,$(sort $(.VARIABLES),$(_mod.VARIABLES)))
+$(outdir)/at-variables/%:
+ @printf '%s\n' $(call quote.shell,$($*))
+$(outdir)/at-values/%:
+ @printf '%s\n' $(call 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 quote.shell,$(_mod.tmp) $(mod.$(_mod.tmp).description) $(if $(mod.$(_mod.tmp).doc),(more))))|column -t -s $$'\t'
+$(addprefix $(outdir)/at-modules/,$(_mod.modules)): $(outdir)/at-modules/%:
+ @printf 'Name : %s\n' $(call quote.shell,$*)
+ @printf 'Description : %s\n' $(call quote.shell,$(mod.$*.description))
+ @echo 'Depends on :' $(sort $(mod.$*.depends))
+ @echo 'Files :'
+ @printf ' %s\n' $(call quote.shell-each,$(call at.relto,$(topsrcdir),$(sort $(mod.$*.files) $(wildcard $(topsrcdir)/build-aux/Makefile.*/??-$*.mk))))
+ @echo 'Documentation :'
+ @printf '%s\n' $(call quote.shell,$(mod.$*.doc)) | sed -e 's/^# / /' -e 's/^#//'
+
+$(outdir)/at-noop:
+.PHONY: $(outdir)/at-noop
+at.targets += $(outdir)/at-noop
diff --git a/build-aux/Makefile.each.tail/00-var.mk b/build-aux/Makefile.each.tail/00-var.mk
new file mode 100644
index 0000000000..954defb2da
--- /dev/null
+++ b/build-aux/Makefile.each.tail/00-var.mk
@@ -0,0 +1,22 @@
+# Copyright (C) 2016-2017 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.var.depends += files quote write-ifchanged
+
+$(outdir)/.var.%: _var.FORCE
+ @printf '%s' $(call quote.shell,$($*)) | sed 's/^/#/' | $(WRITE_IFCHANGED) $@
+-include $(wildcard $(outdir)/.var.*)
+
+files.out.int += .var.*
diff --git a/build-aux/Makefile.each.tail/10-files.mk b/build-aux/Makefile.each.tail/10-files.mk
new file mode 100644
index 0000000000..e22b216c19
--- /dev/null
+++ b/build-aux/Makefile.each.tail/10-files.mk
@@ -0,0 +1,57 @@
+# Copyright (C) 2015-2017 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/>.
+# Add some more defaults to the *_files variables
+
+$(eval \
+ $(foreach _files.var,$(filter files.src files.src.%,$(.VARIABLES)),\
+ _$(_files.var) = $$(call at.addprefix,$$(srcdir),$$($(_files.var)))$(at.nl))\
+ $(foreach _files.var,$(filter files.out files.out.%,$(.VARIABLES)),\
+ _$(_files.var) = $$(call at.addprefix,$$(outdir),$$($(_files.var)))$(at.nl))\
+ $(foreach _files.var,$(filter files.sys files.sys.%,$(.VARIABLES)),\
+ _$(_files.var) = $$(addprefix $$(DESTDIR),$$($(_files.var)))$(at.nl)))
+
+_files.all = $(_files.src) $(_files.out) $(_files.sys)
+
+at.targets += $(subst *,%,$(_files.all))
+
+# Creative targets
+$(outdir)/$(files.generate): $(_files.src.gen) $(_files.src.cfg)
+$(outdir)/install: $(_files.sys.$(files.default))
+$(outdir)/installdirs: $(sort $(dir $(_files.sys)))
+$(eval \
+ $(foreach _files.g,$(files.groups),\
+ $$(outdir)/$(_files.g): $$(_files.out.$(_files.g))$(at.nl))\
+ $(foreach _files.g,$(filter-out $(files.default),$(files.groups)),\
+ $$(outdir)/install-$(_files.g): $$(_files.sys.$(_files.g))$(at.nl)))
+
+# Destructive targets
+#
+# We do our on $(srcdir) / $(outdir) prefixing here because
+# at.addprefix (while necessary for dependency lists) doesn't preserve
+# trailing slashes, which we care about here; while also not caring
+# about the path normalization that at.addprefix does.
+_files.uninstall = $(addprefix $(DESTDIR),$(files.sys))
+_files.mostlyclean = $(addprefix $(srcdir)/,$(filter-out $(files.out.slow) $(files.out.cfg),$(files.out)))
+_files.clean = $(addprefix $(srcdir)/,$(filter-out $(files.out.cfg),$(files.out)))
+_files.distclean = $(addprefix $(srcdir)/, $(files.out))
+_files.maintainer-clean = $(files.distclean) $(addprefix $(srcdir)/,$(filter-out $(files.src.cfg) $(files.src.src),$(files.src)))
+_files.$(files.vcsclean) = $(files.distclean) $(addprefix $(srcdir)/,$(filter-out $(files.src.src),$(files.src)))
+$(addprefix $(outdir)/,uninstall mostlyclean clean distclean maintainer-clean $(files.vcsclean)): %: %-hook
+ $(call _files.XARGS,$(RM) -- {}, $(sort $(filter-out %/,$(_files.$(@F)))) )
+ $(call _files.XARGS,$(RM) -r -- {}, $(sort $(filter %/,$(_files.$(@F)))) )
+ $(call _files.XARGS,$(RMDIR_P) -- {} 2>/dev/null || true,$(filter-out ./,$(sort $(dir $(_files.$(@F))))))
+$(addprefix $(outdir)/,maintainer-clean $(files.vcsclean)): _files.maintainer-clean-warning
+$(foreach t,uninstall mostlyclean clean distclean maintainer-clean $(files.vcsclean), $(outdir)/$t-hook)::
+.PHONY: $(foreach t,uninstall mostlyclean clean distclean maintainer-clean $(files.vcsclean), $(outdir)/$t-hook)
diff --git a/build-aux/Makefile.each.tail/10-nested.mk b/build-aux/Makefile.each.tail/10-nested.mk
new file mode 100644
index 0000000000..667ec6f901
--- /dev/null
+++ b/build-aux/Makefile.each.tail/10-nested.mk
@@ -0,0 +1,21 @@
+# Copyright (C) 2016-2017 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/>.
+
+$(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)
+at.targets += $(addprefix $(outdir)/,$(nested.targets))
diff --git a/build-aux/Makefile.each.tail/11-texinfo.mk b/build-aux/Makefile.each.tail/11-texinfo.mk
new file mode 100644
index 0000000000..1ee5843d69
--- /dev/null
+++ b/build-aux/Makefile.each.tail/11-texinfo.mk
@@ -0,0 +1,38 @@
+# 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)/info : $(addsuffix .info,$(texinfo.docs))
+files.src.gen += $(addsuffix .info,$(texinfo.docs))
+files.out.dvi += $(addsuffix .dvi ,$(texinfo.docs))
+files.out.html += $(addsuffix .html,$(texinfo.docs))
+files.out.pdf += $(addsuffix .pdf ,$(texinfo.docs))
+files.out.ps += $(addsuffix .ps ,$(texinfo.docs))
+
+files.sys.all += $(foreach f,$(texinfo.docs), $(infodir)/$f.info )
+files.sys.dvi += $(foreach f,$(texinfo.docs), $(dvidir)/$f.dvi )
+files.sys.html += $(foreach f,$(texinfo.docs), $(htmldir)/$f.html )
+files.sys.pdf += $(foreach f,$(texinfo.docs), $(pdfdir)/$f.pdf )
+files.sys.ps += $(foreach f,$(texinfo.docs), $(psdir)/$f.ps )
+
+$(outdir)/%.info: $(srcdir)/%.texi; $(MAKEINFO) -o $(@D) $<
+$(outdir)/%.info: $(outdir)/%.texi; $(MAKEINFO) -o $(@D) $<
+$(outdir)/%.dvi : $(srcdir)/%.texi; $(TEXI2DVI) -o $(@D) $<
+$(outdir)/%.dvi : $(outdir)/%.texi; $(TEXI2DVI) -o $(@D) $<
+$(outdir)/%.html: $(srcdir)/%.texi; $(TEXI2HTML) -o $(@D) $<
+$(outdir)/%.html: $(outdir)/%.texi; $(TEXI2HTML) -o $(@D) $<
+$(outdir)/%.pdf : $(srcdir)/%.texi; $(TEXI2PDF) -o $(@D) $<
+$(outdir)/%.pdf : $(outdir)/%.texi; $(TEXI2PDF) -o $(@D) $<
+$(outdir)/%.ps : $(srcdir)/%.texi; $(TEXI2PS) -o $(@D) $<
+$(outdir)/%.ps : $(outdir)/%.texi; $(TEXI2PS) -o $(@D) $<
diff --git a/build-aux/Makefile.each.tail/50-sd.mk b/build-aux/Makefile.each.tail/50-sd.mk
index c6c05cdff7..7927a31917 100644
--- a/build-aux/Makefile.each.tail/50-sd.mk
+++ b/build-aux/Makefile.each.tail/50-sd.mk
@@ -20,38 +20,75 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
-include $(topsrcdir)/build-aux/Makefile.head.mk
-%-from-name.gperf: %-list.txt
+mod.sd.depends += files am lt
+
+-include $(wildcard $(outdir)/$(DEPDIR)/*.P*)
+
+files.out.int += *.o *.lo *.so .deps/ .libs/
+files.out.int += *-list.txt
+files.out.int += *-from-name.gperf
+files.out.int += *-from-name.h
+files.out.int += *-to-name.h
+files.out.int += *-gperf.c
+
+$(outdir)/%.o : $(srcdir)/%.c $(topoutdir)/config.h | $(outdir)/$(DEPDIR); $(AM_V_CC)$(sd.COMPILE) -c -o $@ $<
+$(outdir)/%.o : $(outdir)/%.c $(topoutdir)/config.h | $(outdir)/$(DEPDIR); $(AM_V_CC)$(sd.COMPILE) -c -o $@ $<
+$(outdir)/%.lo: $(srcdir)/%.c $(topoutdir)/config.h | $(outdir)/$(DEPDIR); $(AM_V_CC)$(sd.LTCOMPILE) -c -o $@ $<
+$(outdir)/%.lo: $(outdir)/%.c $(topoutdir)/config.h | $(outdir)/$(DEPDIR); $(AM_V_CC)$(sd.LTCOMPILE) -c -o $@ $<
+
+$(outdir)/$(DEPDIR):
+ $(AM_V_at)$(MKDIR_P) $@
+
+$(outdir)/%.la:
+ @if test $(words $(lt.lib.files.all)) = 0; then echo 'Cannot link library with no dependencies: $@' >&2; exit 1; fi
+ @if test $(origin am.LDFLAGS) = undefined; then echo 'Cannot link library with undefined am.LDFLAGS: $@' >&2; exit 1; fi
+ $(AM_V_CCLD)$(sd.LINK) $(if $(lt.lib.rpath),-rpath $(lt.lib.rpath)) $(lt.lib.files.ld)
+ $(AM_V_at)$(lt.lib.post)
+$(addprefix $(outdir)/,$(am.out_PROGRAMS)): $(outdir)/%:
+ @if test $(words $(lt.exe.files.all)) = 0; then echo 'Cannot link executable with no dependencies: $@' >&2; exit 1; fi
+ @if test $(origin am.LDFLAGS) = undefined; then echo 'Cannot link executable with undefined am.LDFLAGS: $@' >&2; exit 1; fi
+ $(AM_V_CCLD)$(sd.LINK) $(lt.exe.files.ld)
+
+# Stupid test that everything purported to be exported really is
+$(outdir)/test-lib%-sym.c: $(srcdir)/lib%.sym
+ $(AM_V_GEN){\
+ printf '#include <stdio.h>\n' && \
+ printf '#include "%s"\n' $(notdir $(filter %.h, $^)) && \
+ printf 'void* functions[] = {\n' && \
+ sed -r -n 's/^ +([a-zA-Z0-9_]+);/\1,/p' $< && \
+ printf '};\nint main(void) {\n' && \
+ printf 'unsigned i; for (i=0;i<sizeof(functions)/sizeof(void*);i++) printf("%%p\\n", functions[i]);\n' && \
+ printf 'return 0; }\n' && \
+ :; } > $@
+
+_sd.files_in = $(foreach f,$(files.sys),$(if $(filter $1,$(patsubst %/,%,$(dir $f))),$(DESTDIR)$f))
+
+$(outdir)/%-from-name.gperf: $(outdir)/%-list.txt
$(AM_V_GEN)$(AWK) 'BEGIN{ print "struct $(notdir $*)_name { const char* name; int id; };"; print "%null-strings"; print "%%";} { printf "%s, %s\n", $$1, $$1 }' <$< >$@
-%-from-name.h: %-from-name.gperf
+$(outdir)/%-from-name.h: $(outdir)/%-from-name.gperf
$(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@
-$(outdir)/%: sysctl.d/%.in
- $(SED_PROCESS)
+ifeq ($(sd.sed_files),)
+EXTRA_DIST ?=
+sd.sed_files += $(notdir $(patsubst %.in,%,$(filter %.in,$(EXTRA_DIST))))
+endif
+ifneq ($(sd.sed_files),)
+$(addprefix $(outdir)/,$(sd.sed_files)): $(outdir)/%: $(srcdir)/%.in
+ $(sd.SED_PROCESS)
+endif
-%.sh: %.sh.in
- $(SED_PROCESS)
- $(AM_V_GEN)chmod +x $@
+#$(outdir)/%.sh: $(srcdir)/%.sh.in
+# $(SED_PROCESS)
+# $(AM_V_GEN)chmod +x $@
-$(outdir)/%.c: src/%.gperf
+$(outdir)/%.c: $(srcdir)/%.gperf
+ $(AM_V_GPERF)$(GPERF) < $< > $@
+$(outdir)/%.c: $(outdir)/%.gperf
$(AM_V_GPERF)$(GPERF) < $< > $@
-$(outdir)/%: src/%.m4 $(top_builddir)/config.status
+$(addprefix $(outdir)/,_bogus_m4 $(patsubst %.m4,%,$(filter %.m4,$(files.src)))): $(outdir)/%: $(srcdir)/%.m4 $(top_builddir)/config.status
+ $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
+$(addprefix $(outdir)/,_bogus_m4_in $(patsubst %.m4.in,%,$(filter %.m4.in,$(files.src)))): $(outdir)/%: $(outdir)/%.m4 $(top_builddir)/config.status
$(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
-
-# Stupid test that everything purported to be exported really is
-define generate-sym-test
- $(AM_V_at)printf '#include <stdio.h>\n' > $@
- $(AM_V_at)printf '#include "%s"\n' $(notdir $(filter %.h, $^)) >> $@
- $(AM_V_at)printf 'void* functions[] = {\n' >> $@
- $(AM_V_GEN)sed -r -n 's/^ +([a-zA-Z0-9_]+);/\1,/p' $< >> $@
- $(AM_V_at)printf '};\nint main(void) {\n' >> $@
- $(AM_V_at)printf 'unsigned i; for (i=0;i<sizeof(functions)/sizeof(void*);i++) printf("%%p\\n", functions[i]);\n' >> $@
- $(AM_V_at)printf 'return 0; }\n' >> $@
-endef
-
-
-include $(topsrcdir)/build-aux/Makefile.tail.mk
diff --git a/build-aux/Makefile.each.tail/60-am.mk b/build-aux/Makefile.each.tail/60-am.mk
new file mode 100644
index 0000000000..825e0b8c78
--- /dev/null
+++ b/build-aux/Makefile.each.tail/60-am.mk
@@ -0,0 +1,12 @@
+$(file >$(outdir)/.am.0.mk,$(_am.pass0))
+include $(outdir)/.am.0.mk
+$(file >$(outdir)/.am.1.mk,$(_am.pass1))
+include $(outdir)/.am.1.mk
+$(file >$(outdir)/.am.2.mk,$(_am.pass2))
+include $(outdir)/.am.2.mk
+$(file >$(outdir)/.am.3.mk,$(_am.pass3))
+include $(outdir)/.am.3.mk
+$(file >$(outdir)/.am.4.mk,$(_am.pass4))
+include $(outdir)/.am.4.mk
+$(file >$(outdir)/.am.5.mk,$(_am.pass5))
+include $(outdir)/.am.5.mk
diff --git a/build-aux/Makefile.each.tail/70-sdcompletion.mk b/build-aux/Makefile.each.tail/70-sdcompletion.mk
new file mode 100644
index 0000000000..99677c9407
--- /dev/null
+++ b/build-aux/Makefile.each.tail/70-sdcompletion.mk
@@ -0,0 +1,23 @@
+mod.sdcompletion.description = (systemd) shell completion
+mod.sdcompletion.depends += am
+define mod.sdcompletion.doc
+# Inputs:
+# - Directory variable : `rootbin_PROGRAMS`
+# - Directory variable : `bin_PROGRAMS`
+# - Directory variable : `dist_bin_SCRIPTS`
+# - Directory variable : `bashcompletion_DATA`
+# - Directory variable : `zshcompletion_DATA`
+# Outputs:
+# - Directory variable : `dist_bashcompletion_DATA`
+# - Directory variable : `dist_zshcompletion_DATA`
+endef
+mod.sdcompletion.doc := $(value mod.sdcompletion.doc)
+
+rootbin_PROGRAMS ?=
+bin_PROGRAMS ?=
+dist_bin_SCRIPTS ?=
+bashcompletion_DATA ?=
+zshcompletion_DATA ?=
+# We use `dist_` to trick `am` into not putting it in `am.out_DATA`
+dist_bashcompletion_DATA := $(sort $(bashcompletion_DATA) $(rootbin_PROGRAMS) $(bin_PROGRAMS) $(dist_bin_SCRIPTS))
+dist_zshcompletion_DATA := $(sort $(zshcompletion_DATA) $(addprefix _,$(notdir $(rootbin_PROGRAMS) $(bin_PROGRAMS) $(dist_bin_SCRIPTS))))
diff --git a/build-aux/Makefile.each.tail/70-sdman.mk b/build-aux/Makefile.each.tail/70-sdman.mk
index 2e7e0d4e39..ccbb1bd4e1 100644
--- a/build-aux/Makefile.each.tail/70-sdman.mk
+++ b/build-aux/Makefile.each.tail/70-sdman.mk
@@ -20,103 +20,54 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
-include $(topsrcdir)/build-aux/Makefile.head.mk
+_sdman.man_xml = $(foreach _sdman.tmp,$(filter %.xml,$(files.src.src)),$(if $(findstring /,$(_sdman.tmp)),,$(_sdman.tmp)))
-MANPAGES =
-MANPAGES_ALIAS =
+ifneq ($(_sdman.man_xml),)
-include Makefile-man.am
+$(srcdir)/Makefile-man.mk: $(topsrcdir)/tools/make-man-rules.py $(topsrcdir)/tools/xml_helper.py $(topsrcdir)/man/custom-entities.ent.in $(outdir)/.var._sdman.man_xml $(call at.addprefix,$(srcdir),$(_sdman.man_xml))
+ $(AM_V_GEN)$(PYTHON) $< $(filter %.xml,$^) | $(WRITE_ATOMIC) $@
+files.src.gen += Makefile-man.mk
-.PHONY: man update-man-list
-man: $(MANPAGES) $(MANPAGES_ALIAS) $(HTML_FILES) $(HTML_ALIAS)
+sdman.MANPAGES =
+sdman.MANPAGES_ALIAS =
+#-include $(srcdir)/Makefile-man.mk
-XML_FILES = \
- ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,${patsubst %.8,%.xml,$(MANPAGES)}}}}}
-HTML_FILES = \
- ${XML_FILES:.xml=.html}
-HTML_ALIAS = \
- ${patsubst %.1,%.html,${patsubst %.3,%.html,${patsubst %.5,%.html,${patsubst %.7,%.html,${patsubst %.8,%.html,$(MANPAGES_ALIAS)}}}}}
+_sdman.XML_FILES = \
+ ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,${patsubst %.8,%.xml,$(sdman.MANPAGES)}}}}}
+_sdman.HTML_FILES = \
+ ${_sdman.XML_FILES:.xml=.html}
+_sdman.HTML_ALIAS = \
+ ${patsubst %.1,%.html,${patsubst %.3,%.html,${patsubst %.5,%.html,${patsubst %.7,%.html,${patsubst %.8,%.html,$(sdman.MANPAGES_ALIAS)}}}}}
ifneq ($(ENABLE_MANPAGES),)
man_MANS = \
- $(MANPAGES) \
- $(MANPAGES_ALIAS)
+ $(sdman.MANPAGES) \
+ $(sdman.MANPAGES_ALIAS)
noinst_DATA += \
- $(HTML_FILES) \
- $(HTML_ALIAS) \
- docs/html/man
+ $(_sdman.HTML_FILES) \
+ $(_sdman.HTML_ALIAS)
endif # ENABLE_MANPAGES
-CLEANFILES += \
- $(man_MANS) \
- $(HTML_FILES) \
- $(HTML_ALIAS) \
- docs/html/man
+at.subdirs += $(abspath $(topoutdir)/man)
-$(outdir)/man:
- $(AM_V_LN)$(LN_S) -f ../../man $@
+$(outdir)/%.1: $(srcdir)/%.xml $(topsrcdir)/man/custom-man.xsl $(topoutdir)/man/custom-entities.ent
+ $(_sdman.XSLTPROC_PROCESS_MAN)
-$(outdir)/index.html: man/systemd.index.html
- $(AM_V_LN)$(LN_S) -f systemd.index.html $@
+$(outdir)/%.3: $(srcdir)/%.xml $(topsrcdir)/man/custom-man.xsl $(topoutdir)/man/custom-entities.ent
+ $(_sdman.XSLTPROC_PROCESS_MAN)
-ifneq ($(HAVE_PYTHON),)
-noinst_DATA += \
- man/index.html
-endif # HAVE_PYTHON
-
-CLEANFILES += \
- man/index.html
-
-XML_GLOB = $(wildcard $(top_srcdir)/man/*.xml)
-NON_INDEX_XML_FILES = $(filter-out man/systemd.index.xml,$(XML_FILES))
-SOURCE_XML_FILES = ${patsubst %,$(top_srcdir)/%,$(filter-out man/systemd.directives.xml,$(NON_INDEX_XML_FILES))}
-
-# This target should only be run manually. It recreates Makefile-man.am
-# file in the source directory based on all man/*.xml files. Run it after
-# adding, removing, or changing the conditional in a man page.
-update-man-list: $(top_srcdir)/tools/make-man-rules.py $(XML_GLOB) man/custom-entities.ent
- $(AM_V_GEN)$(PYTHON) $< $(XML_GLOB) > $(top_srcdir)/Makefile-man.tmp
- $(AM_V_at)mv $(top_srcdir)/Makefile-man.tmp $(top_srcdir)/Makefile-man.am
- @echo "Makefile-man.am has been regenerated"
-
-$(outdir)/systemd.index.xml: $(top_srcdir)/tools/make-man-index.py $(NON_INDEX_XML_FILES)
- $(AM_V_GEN)$(PYTHON) $< $@ $(filter-out $<,$^)
-
-$(outdir)/systemd.directives.xml: $(top_srcdir)/tools/make-directive-index.py man/custom-entities.ent $(SOURCE_XML_FILES)
- $(AM_V_GEN)$(PYTHON) $< $@ $(SOURCE_XML_FILES)
-
-CLEANFILES += \
- man/systemd.index.xml \
- man/systemd.directives.xml
-
-EXTRA_DIST += \
- $(filter-out man/systemd.directives.xml man/systemd.index.xml,$(XML_FILES)) \
- tools/make-man-index.py \
- tools/make-man-rules.py \
- tools/make-directive-index.py \
- tools/xml_helper.py \
- man/glib-event-glue.c
-
-$(outdir)/%.1: man/%.xml man/custom-man.xsl man/custom-entities.ent
- $(XSLTPROC_PROCESS_MAN)
-
-$(outdir)/%.3: man/%.xml man/custom-man.xsl man/custom-entities.ent
- $(XSLTPROC_PROCESS_MAN)
-
-$(outdir)/%.5: man/%.xml man/custom-man.xsl man/custom-entities.ent
- $(XSLTPROC_PROCESS_MAN)
-
-$(outdir)/%.7: man/%.xml man/custom-man.xsl man/custom-entities.ent
- $(XSLTPROC_PROCESS_MAN)
+$(outdir)/%.5: $(srcdir)/%.xml $(topsrcdir)/man/custom-man.xsl $(topoutdir)/man/custom-entities.ent
+ $(_sdman.XSLTPROC_PROCESS_MAN)
-$(outdir)/%.8: man/%.xml man/custom-man.xsl man/custom-entities.ent
- $(XSLTPROC_PROCESS_MAN)
+$(outdir)/%.7: $(srcdir)/%.xml $(topsrcdir)/man/custom-man.xsl $(topoutdir)/man/custom-entities.ent
+ $(_sdman.XSLTPROC_PROCESS_MAN)
-$(outdir)/%.html: man/%.xml man/custom-html.xsl man/custom-entities.ent
- $(XSLTPROC_PROCESS_HTML)
+$(outdir)/%.8: $(srcdir)/%.xml $(topsrcdir)/man/custom-man.xsl $(topoutdir)/man/custom-entities.ent
+ $(_sdman.XSLTPROC_PROCESS_MAN)
+$(outdir)/%.html: $(srcdir)/%.xml $(topsrcdir)/man/custom-html.xsl $(topoutdir)/man/custom-entities.ent
+ $(_sdman.XSLTPROC_PROCESS_HTML)
-include $(topsrcdir)/build-aux/Makefile.tail.mk
+endif # _sdman.man_xml
diff --git a/build-aux/Makefile.head.mk b/build-aux/Makefile.head.mk
new file mode 100644
index 0000000000..6ac3d49f9f
--- /dev/null
+++ b/build-aux/Makefile.head.mk
@@ -0,0 +1,116 @@
+# Copyright (C) 2015-2017 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/>.
+
+at.Makefile ?= Makefile
+_at.MAKEFILE_LIST ?=
+_at.MAKEFILE_LIST := $(strip $(_at.MAKEFILE_LIST) $(lastword $(filter %/$(at.Makefile),$(abspath $(MAKEFILE_LIST)))))
+
+# This bit only gets evaluated once, at the very beginning
+ifeq ($(origin _at.NO_ONCE),undefined)
+
+# Internal functions ###################################################
+
+# 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 %/.,%,$(patsubst $(abspath $1)/%,%,$(abspath $2)/.)), \
+ $(abspath $2)))
+_at.relto = $(strip \
+ $(if $(call _at.is_subdir,$1,$2), \
+ $(patsubst %/.,%,$(patsubst $(abspath $1)/%,%,$(abspath $2)/.)), \
+ ../$(call _at.relto,$(dir $(abspath $1)),$2)))
+
+# These 3 functions only take one operand; we define public multi-operand
+# versions below.
+_at.path = $(strip $(or \
+ $(if $(call _at.is_subdir, . ,$1), $(call _at.relto, . ,$1) ), \
+ $(if $(call _at.is_subdir,$(topoutdir),$1),$(patsubst %/.,%,$(topoutdir)/$(call _at.relto,$(topoutdir),$1))), \
+ $(if $(call _at.is_subdir,$(topsrcdir),$1),$(patsubst %/.,%,$(topsrcdir)/$(call _at.relto,$(topsrcdir),$1))), \
+ $(abspath $1)))
+_at.out2src = $(call _at.path,$(strip \
+ $(if $(call _at.is_subdir,$(topoutdir),$1), \
+ $(topsrcdir)/$(call _at.relto,$(topoutdir),$1), \
+ $1)))
+_at.addprefix = $(call _at.path,$(if $(filter-out /%,$2),$1/$2,$2))
+
+_at.rest = $(wordlist 2,$(words $1),$1)
+_at.reverse = $(if $1,$(call _at.reverse,$(_at.rest))) $(firstword $1)
+
+_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')
+endif
+ifeq ($(topsrcdir),)
+$(error Autothing: topsrcdir must be set (and non-empty) before including Makefile.head.mk)
+endif
+ifeq ($(topoutdir),)
+$(error Autothing: topoutdir must be set (and non-empty) before including Makefile.head.mk)
+endif
+ifneq ($(call _at.is_strict_subdir,$(topoutdir),$(topsrcdir)),)
+$(error Autothing: topsrcdir=$(topsrcdir) must not be a subdirectory of topoutdir=$(topoutdir))
+endif
+
+# External provisions ##################################################
+
+# These 4 functions are all $(call _at.func,parent,child)
+at.is_subdir = $(_at.is_subdir)
+at.is_strict_subdir = $(_at.is_strict_subdir)
+#at.relbase = $(if $2,$(shell realpath -sm --relative-base=$1 -- $2))
+at.relbase = $(foreach _at.tmp,$2,$(call _at.relbase,$1,$(_at.tmp)))
+#at.relto = $(if $2,$(shell realpath -sm --relative-to=$1 -- $2))
+at.relto = $(foreach _at.tmp,$2,$(call _at.relto,$1,$(_at.tmp)))
+
+at.path = $(foreach _at.tmp,$1,$(call _at.path,$(_at.tmp)))
+at.out2src = $(foreach _at.tmp,$1,$(call _at.out2src,$(_at.tmp)))
+at.addprefix = $(foreach _at.tmp,$2,$(call _at.addprefix,$1,$(_at.tmp)))
+
+define at.nl
+
+
+endef
+
+# Include modules ######################################################
+include $(sort $(wildcard $(topsrcdir)/build-aux/Makefile.once.head/*.mk))
+_at.tmp_targets =
+_at.tmp_subdirs =
+_at.VARIABLES =
+_at.VARIABLES := $(.VARIABLES)
+
+endif # _at.NO_ONCE
+
+# This bit gets evaluated for each Makefile
+
+outdir := $(call _at.path,$(dir $(lastword $(_at.MAKEFILE_LIST))))
+ifeq ($(call _at.is_subdir,$(topoutdir),$(outdir)),)
+$(error Autothing: not a subdirectory of topoutdir=$(topoutdir): $(outdir))
+endif
+
+srcdir := $(call _at.out2src,$(outdir))
+ifeq ($(call _at.is_subdir,$(topsrcdir),$(srcdir)),)
+$(error Autothing: not a subdirectory of topsrcdir=$(topsrcdir): $(srcdir))
+endif
+
+at.subdirs =
+at.targets =
+
+include $(sort $(wildcard $(topsrcdir)/build-aux/Makefile.each.head/*.mk))
diff --git a/build-aux/Makefile.once.head/00-quote.mk b/build-aux/Makefile.once.head/00-quote.mk
new file mode 100644
index 0000000000..94bc943b60
--- /dev/null
+++ b/build-aux/Makefile.once.head/00-quote.mk
@@ -0,0 +1,49 @@
+# 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.quote.description = Macros to quote tricky strings
+define mod.quote.doc
+# Inputs:
+# (none)
+# Outputs:
+# - Global variable: `quote.var` : GNU Make variables
+# - Global variable: `quote.pattern` : GNU Make patterns
+# - Global variable: `quote.ere` : POSIX Extended Regular Expressions
+# - Global variable: `quote.bre` : POSIX Basic Regular Expressions
+# - Global variable: `quote.shell` : POSIX sh(1) strings
+# - Global variable: `quote.shell-each`: POSIX sh(1) strings
+#
+# Escaping/quoting things is hard! This module provides a number of
+# functions to escape/quote strings for various contexts.
+#
+# `quote.shell-each` quotes each list-item separately (munging
+# whitespace), while `quote.shell` keeps them as one string (preserving
+# whitespace).
+endef
+mod.quote.doc := $(value mod.quote.doc)
+
+_quote.backslash = $(if $1,$(call _quote.backslash,$(wordlist 2,$(words $1),$1),$(subst $(firstword $1),\$(firstword $1),$2)),$2)
+
+quote.var = $(subst $(at.nl),\$(at.nl),$(subst $$,$$$$,$1))
+quote.pattern = $(call _quote.backslash, \ % ,$1)
+quote.ere = $(call _quote.backslash, \ ^ . [ $$ ( ) | * + ? { ,$1)
+quote.bre = $(call _quote.backslash, \ ^ . [ $$ * ,$1)
+
+quote.shell-each = $(foreach _quote.tmp,$1,$(call quote.shell,$(_quote.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.
+quote.shell = $(subst $(at.nl),'$$'\n'','$(subst ','\'',$1)')
diff --git a/build-aux/Makefile.once.head/00-var.mk b/build-aux/Makefile.once.head/00-var.mk
new file mode 100644
index 0000000000..7c9e6ffe55
--- /dev/null
+++ b/build-aux/Makefile.once.head/00-var.mk
@@ -0,0 +1,36 @@
+# Copyright (C) 2016-2017 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.var.description = Depend on the values of variables
+define mod.var.doc
+# Inputs:
+# (user-defined)
+# Outputs:
+# Target : `$(outdir)/.var.%`
+# Directory variable: `at.targets`
+# Directory variable: `var.`
+#
+# It's a well-known secret that many files generated by a Makefile vary with
+# the values of particular variables, but that GNU Make can't track these
+# dependencies. Well, with some cleverness, it actually can!
+#
+# With this module, to depend on the value of a variable, depend on
+# `$(outdir)/.var.VARNAME`, or `$(var.)VARNAME` for short.
+endef
+mod.var.doc := $(value mod.var.doc)
+
+var. = $(patsubst ./%,%,$(outdir)/.var.)
+
+.PHONY: _var.FORCE
diff --git a/build-aux/Makefile.once.head/10-dist.mk b/build-aux/Makefile.once.head/10-dist.mk
new file mode 100644
index 0000000000..3621195c0d
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-dist.mk
@@ -0,0 +1,85 @@
+# Copyright (C) 2015-2017 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.dist.description = `dist` target to create distribution tarballs
+define mod.dist.doc
+# User variables:
+# - `CP ?= cp`
+# - `GZIP ?= gzip`
+# - `MKDIR ?= mkdir`
+# - `MKDIR_P ?= mkdir -p`
+# - `MV ?= mv`
+# - `RM ?= rm -f`
+# - `TAR ?= tar`
+# - `GZIPFLAGS ?= $(GZIP_ENV)`
+# - `GZIP_ENV ?= --best` (only used via `GZIPFLAGS`, not directly)
+# Inputs:
+# - Global variable : `dist.exts` (Default: `.tar.gz`)
+# - Global variable : `dist.pkgname` (Default: first of PACKAGE_TARNAME PACKAGE PACKAGE_NAME)
+# - Global variable : `dist.version` (Default: first of PACKAGE_VERSION VERSION)
+# - Directory variable : `files.src`
+# Outputs:
+# - Directory variable : `files.out.int` (only in top dir)
+# - .PHONY Target : `$(outdir)/dist`
+# - Target : `$(topoutdir)/$(dist.pkgname)-$(dist.version)`
+# - Target : `$(topoutdir)/$(dist.pkgname)-$(dist.version).tar`
+# - Target : `$(topoutdir)/$(dist.pkgname)-$(dist.version).tar.gz`
+#
+# Provide the standard `dist` .PHONY target, based on the `files` module
+# information.
+#
+# You may change the default compression target easily via the
+# `dist.exts` variable, but you must define the rule for it manually.
+#
+# Bugs:
+#
+# The tarball isn't reproducible. It uses file-system ordering of
+# files, and includes timestamps.
+endef
+mod.dist.doc := $(value mod.dist.doc)
+
+PACKAGE_TARNAME ?=
+PACKAGE ?=
+PACKAGE_NAME ?=
+PACKAGE_VERSION ?=
+VERSION ?=
+
+# Developer configuration
+
+dist.exts ?= .tar.gz
+dist.pkgname ?= $(firstword $(PACKAGE_TARNAME) $(PACKAGE) $(PACKAGE_NAME))
+dist.version ?= $(firstword $(PACKAGE_VERSION) $(VERSION))
+
+ifeq ($(dist.pkgname),)
+$(error Autothing module: dist: dist.pkgname must be set)
+endif
+ifeq ($(dist.version),)
+$(error Autothing module: dist: dist.version must be set)
+endif
+
+_dist.files =
+
+# User configuration
+
+CP ?= cp
+GZIP ?= gzip
+MKDIR ?= mkdir
+MKDIR_P ?= mkdir -p
+MV ?= mv
+RM ?= rm -f
+TAR ?= tar
+
+GZIPFLAGS ?= $(GZIP_ENV)
+GZIP_ENV ?= --best
diff --git a/build-aux/Makefile.once.head/10-files.mk b/build-aux/Makefile.once.head/10-files.mk
new file mode 100644
index 0000000000..55c41cb9b9
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-files.mk
@@ -0,0 +1,100 @@
+# Copyright (C) 2015-2017 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.files.description = Keeping track of groups of files
+mod.files.depends += nested
+define mod.files.doc
+# User variables:
+# - `DESTDIR ?=`
+# - `RM ?= rm -f`
+# - `RMDIR_P ?= rmdir -p --ignore-fail-on-non-empty`
+# - `TRUE ?= true`
+# Inputs:
+# - Global variable : `files.groups ?= all`
+# - Global variable : `files.default ?= all`
+# - Global variable : `files.vcsclean ?= files.vcsclean`
+# - Global variable : `files.generate ?= files.generate`
+# - Directory variable : `files.src.src` # Sources
+# - Directory variable : `files.src.int` # Intermediates; deletable
+# - Directory variable : `files.src.cfg` # Outputs needed to run ./configure
+# - Directory variable : `files.src.gen` # Other outputs
+# - Directory variable : `files.out.slow` # Things to exclude from `make mostlyclean`
+# - Directory variable : `files.out.int` # Intermediates
+# - Directory variable : `files.out.cfg` # Outputs created by ./configure
+# - Directory variable : `files.out.$(group)` for `group` in `$(files.groups)`
+# - Directory variable : `files.sys.$(group)` for `group` in `$(files.groups)`
+# Outputs:
+# - Global variable : `nested.targets`
+# - Global variable : `at.targets`
+# - Global variable : `.DEFAULT_GOAL = $(files.default)`
+# - Directory variable : `files.src`
+# - Directory variable : `files.out`
+# - Directory variable : `files.sys`
+# - Creative .PHONY targets:
+# - `$(outdir)/$(files.generate)`
+# - `$(outdir)/$(group)` for `group` in `$(files.groups)`
+# - `$(outdir)/install`
+# - `$(outdir)/install-$(group)` for `group` in `$(filter-out $(files.default),$(files.groups))`
+# - `$(outdir)/installdirs`
+# - Destructive .PHONY targets:
+# - `$(outdir)/uninstall`
+# - `$(outdir)/mostlyclean`
+# - `$(outdir)/clean`
+# - `$(outdir)/distclean`
+# - `$(outdir)/maintainer-clean`
+# - `$(outdir)/$(files.vcsclean)`
+#
+# Basic `*` wildcards are supported. Use `*`, not `%`; it will automatically
+# substitute `*`->`%` where appropriate.
+#
+# Each of the destructive targets depends on `$(target)-hook`, which
+# is defined to be a "double-colon rule" allowing you to add your own
+# code.
+#
+# TODO: prose documentation
+endef
+mod.files.doc := $(value mod.files.doc)
+
+files.groups ?= all
+files.default ?= all
+files.vcsclean ?= files.vcsclean
+files.generate ?= files.generate
+
+.DEFAULT_GOAL = $(files.default)
+
+# Standard creative PHONY targets
+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 $(files.vcsclean)
+
+# User configuration
+
+DESTDIR ?=
+
+RM ?= rm -f
+RMDIR_P ?= rmdir -p --ignore-fail-on-non-empty
+TRUE ?= true
+
+# Utility functions
+
+_files.XARGS = $(if $(strip $2),$(subst {},$(strip $2),$1))
+
+_files.maintainer-clean-warning:
+ @echo 'This command is intended for maintainers to use; it'
+ @echo 'deletes files that may need special tools to rebuild.'
+.PHONY: _files.maintainer-clean-warning
diff --git a/build-aux/Makefile.once.head/10-gitfiles.mk b/build-aux/Makefile.once.head/10-gitfiles.mk
new file mode 100644
index 0000000000..8566a7f5e9
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-gitfiles.mk
@@ -0,0 +1,75 @@
+# Copyright (C) 2016-2017 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.gitfiles.description = Automatically populate files.src.src from git
+mod.gitfiles.depends += files nested write-ifchanged quote
+mod.gitfiles.files += $(topsrcdir)/$(gitfiles.file)
+define mod.gitfiles.doc
+# Inputs:
+# - Global variable : `gitfiles.file` (Default: gitfiles.mk)
+# - Directory variable : `nested.subdirs`
+# - External : git
+# Outputs:
+# - File : `$(topsrcdir)/$(gitfiles.file)`
+# - Directory variable : `files.src.src`
+# - Directory variable : `files.src.gen` (only in top dir)
+#
+# The `files` module has a variable (`files.src.src`) that you (the
+# developer) set to list "pure" source files; the type of files that you
+# would check into a version control system. Since you are a
+# responsible developer, you use a version control system. Since the
+# computer is already maintaining a list of these files *in the VCS*,
+# why should you--a filthy human--need to also maintain the list? Enter
+# gitfiles, which will talk to git to maintain `files.src.src`, but
+# won't require that the git repository be distributed to
+# installing-users.
+#
+# If `$(topsrcdir)/.git` exists, then it will generate
+# `$(topsrcdir)/$(gitfiles.file)`. Otherwise, it will assume that
+# `$(topsrcdir)/$(gitfiles.file)` already exists.
+#
+# It will use the information in `$(topsrcdir)/$(gitfiles.file)` to
+# append to `files.src.src` in each directory
+#
+# Finally, since the generated `$(topsrcdir)/$(gitfiles.file)` must be
+# distributed to users, it is added to $(topsrcdirs)'s `files.src.gen`.
+#
+# When setting `files.src.src`, it needs to know which files "belong" to
+# the current directory directly, and which "belong" to a further
+# subdirectory. To do this, it uses an expression involving
+# `$(nested.subdirs)`.
+#
+# While gitfiles sets `files.src.src` very early in `each.head`, because
+# `nested.subdirs` might not be set yet, it may or may not be safe to
+# use the value of `$(files.src.src)` in your Makefile, depending on how
+# you set `nested.subdirs`.
+endef
+mod.gitfiles.doc := $(value mod.gitfiles.doc)
+
+gitfiles.file ?= gitfiles.mk
+
+_gitfiles.all =
+-include $(topsrcdir)/$(gitfiles.file)
+
+ifneq ($(wildcard $(topsrcdir)/.git),)
+$(topsrcdir)/$(gitfiles.file): _gitfiles.FORCE
+ @(cd $(@D) && git ls-files --recurse-submodules -z) | sed -z -e 's/\$$/\$$$$/g' -e 's/\n/$$(at.nl)/g' | xargs -r0 printf '_gitfiles.all+=%s\n' | $(WRITE_IFCHANGED) $@
+.PHONY: _gitfiles.FORCE
+endif
+
+_gitfiles.dir = $(call at.relto,$(topsrcdir),$(srcdir))
+_gitfiles.pat = $(patsubst ./%,%,$(_gitfiles.dir)/%)
+_gitfiles.dir.all = $(patsubst $(_gitfiles.pat),%,$(filter $(_gitfiles.pat),$(_gitfiles.all)))
+_gitfiles.dir.src = $(filter-out $(addsuffix /%,$(nested.subdirs)),$(_gitfiles.dir.all))
diff --git a/build-aux/Makefile.once.head/10-gnuconf.mk b/build-aux/Makefile.once.head/10-gnuconf.mk
new file mode 100644
index 0000000000..87baa14a69
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-gnuconf.mk
@@ -0,0 +1,205 @@
+# Copyright (C) 2016-2017 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.gnuconf.description = GNU standard configuration variables
+define mod.gnuconf.doc
+# Inputs:
+# - Global variable: `gnuconf.pkgname`
+# (Default: `$(firstword $(PACKAGE_TARNAME) $(PACKAGE) $(PACKAGE_NAME))`)
+# Outputs:
+# (see below)
+#
+# This module defines default values (using `?=`) a huge list of
+# variables specified in the GNU Coding Standards that installing-users
+# expect to be able to set.
+#
+# This is based on §7.2 "Makefile Conventions" of the July 25, 2016
+# release of the GNU Coding Standards.
+endef
+mod.gnuconf.doc := $(value mod.gnuconf.doc)
+
+PACKAGE_TARNAME ?=
+PACKAGE ?=
+PACKAGE_NAME ?=
+gnuconf.pkgname ?= $(firstword $(PACKAGE_TARNAME) $(PACKAGE) $(PACKAGE_NAME))
+ifeq ($(gnuconf.pkgname),)
+$(error Autothing module: gnuconf: gnuconf.pkgname must be set)
+endif
+
+# 7.2.2: Utilities in Makefiles
+# -----------------------------
+
+# It's ok to hard-code these commands in rules, but who wants to
+# memorize the list of what's ok?
+AWK ?= awk
+CAT ?= cat
+CMP ?= cmp
+CP ?= cp
+DIFF ?= diff
+ECHO ?= echo
+EGREP ?= egrep
+EXPR ?= expr
+FALSE ?= false
+GREP ?= grep
+INSTALL_INFO ?= install-info
+LN ?= ln
+LS ?= ls
+MKDIR ?= mkdir
+MV ?= mv
+PRINTF ?= printf
+PWD ?= pwd
+RM ?= rm
+RMDIR ?= rmdir
+SED ?= sed
+SLEEP ?= sleep
+SORT ?= sort
+TAR ?= tar
+TEST ?= test
+TOUCH ?= touch
+TR ?= tr
+TRUE ?= true
+
+# 7.2.2: Utilities in Makefiles/7.2.3: Variables for Specifying Commands
+# ----------------------------------------------------------------------
+
+# Standard user-configurable programs.
+#
+# The list of programs here is specified in §7.2.2, but the associated FLAGS
+# variables are specified in §7.2.3. I found it cleaner to list them together.
+AR ?= ar
+ARFLAGS ?=
+BISON ?= bison
+BISONFLAGS ?=
+CC ?= cc
+CFLAGS ?= # CFLAGS instead of CCFLAGS
+FLEX ?= flex
+FLEXFLAGS ?=
+INSTALL ?= install
+# There is no INSTALLFLAGS[0]
+LD ?= ld
+LDFLAGS ?=
+LDCONFIG ?= ldconfig # TODO[1]
+LDCONFIGFLAGS ?=
+LEX ?= lex
+LFLAGS ?= # LFLAGS instead of LEXFLAGS
+#MAKE
+MAKEINFO ?= makeinfo
+MAKEINFOFLAGS ?=
+RANLIB ?= ranlib # TODO[1]
+RANLIBFLAGS ?=
+TEXI2DVI ?= texi2dvi
+TEXI2DVIFLAGS ?=
+YACC ?= yacc
+YFLAGS ?= # YFLAGS instead of YACCFLAGS
+
+CPPFLAGS ?=
+
+LN_S ?= ln -s # TODO[2]
+
+CHGRP ?= chgrp
+CHGRPFLAGS ?=
+CHMOD ?= chmod
+CHMODFLAGS ?=
+CHOWN ?= chown
+CHOWNFLAGS ?=
+MKNOD ?= mknod
+MKNODFLAGS ?=
+
+# [0]: There is no INSTALLFLAGS because it would be inconsistent with how the
+# standards otherwise recommend using $(INSTALL); with INSTALL_PROGRAM and
+# INSTALL_DATA; which are specified in a way precluding the use of
+# INSTALLFLAGS. To have the variable, but to ignore it in the common case
+# would be confusing.
+#
+# [1]: The RANLIB and LDCONFIG variables need some extra smarts; §7.2.2 says:
+#
+# > When you use ranlib or ldconfig, you should make sure nothing bad
+# > happens if the system does not have the program in question. Arrange
+# > to ignore an error from that command, and print a message before the
+# > command to tell the user that failure of this command does not mean a
+# > problem. (The Autoconf ‘AC_PROG_RANLIB’ macro can help with this.)
+#
+# [2]: The LN_S variable isn't standard, but we have it here as an (incomplete)
+# stub to help support this bit of §7.2.2:
+#
+# > If you use symbolic links, you should implement a fallback for
+# > systems that don’t have symbolic links.
+
+# 7.2.3: Variables for Specifying Commands
+# ----------------------------------------
+
+INSTALL_PROGRAM ?= $(INSTALL)
+INSTALL_DATA ?= ${INSTALL} -m 644
+
+# 7.2.5: Variables for Installation Directories
+# ---------------------------------------------
+
+# Root for the installation
+prefix ?= /usr/local
+exec_prefix ?= $(prefix)
+# Executable programs
+bindir ?= $(exec_prefix)/bin
+sbindir ?= $(exec_prefix)/sbin
+libexecdir ?= $(exec_prefix)/libexec
+# Data files
+datarootdir ?= $(prefix)/share
+datadir ?= $(datarootdir)
+sysconfdir ?= $(prefix)/etc
+sharedstatedir ?= $(prefix)/com
+localstatedir ?= $(prefix)/var
+runstatedir ?= $(localstatedir)/run
+# Specific types of files
+includedir ?= $(prefix)/include
+oldincludedir ?= /usr/include
+docdir ?= $(datarootdir)/doc/$(gnuconf.pkgname)
+infodir ?= $(datarootdir)/info
+htmldir ?= $(docdir)
+dvidir ?= $(docdir)
+pdfdir ?= $(docdir)
+psdir ?= $(docdir)
+libdir ?= $(exec_prefix)/lib
+lispdir ?= $(datarootdir)/emacs/site-lisp
+localedir ?= $(datarootdir)/locale
+
+mandir ?= $(datarootdir)/man
+man1dir ?= $(mandir)/man1
+man2dir ?= $(mandir)/man2
+man3dir ?= $(mandir)/man3
+man4dir ?= $(mandir)/man4
+man5dir ?= $(mandir)/man5
+man6dir ?= $(mandir)/man6
+man7dir ?= $(mandir)/man7
+man8dir ?= $(mandir)/man8
+
+manext ?= .1
+man1ext ?= .1
+man2ext ?= .2
+man3ext ?= .3
+man4ext ?= .4
+man5ext ?= .5
+man6ext ?= .6
+man7ext ?= .7
+man8ext ?= .8
+
+# 7.2.7: Install Command Categories
+# ---------------------------------
+
+PRE_INSTALL ?=
+POST_INSTALL ?=
+NORMAL_INSTALL ?=
+
+PRE_UNINSTALL ?=
+POST_UNINSTALL ?=
+NORMAL_UNINSTALL ?=
diff --git a/build-aux/Makefile.once.head/10-lt.mk b/build-aux/Makefile.once.head/10-lt.mk
new file mode 100644
index 0000000000..2ccfc2c459
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-lt.mk
@@ -0,0 +1,57 @@
+mod.lt.description = (systemd) Easy handling of libtool dependencies
+mod.lt.depends += files
+define mod.lt.doc
+# Inputs:
+# - Global variable : `$(.LIBPATTERNS)`
+# - Directory variable : `$(files.sys)`
+# - Target variable : `$@`
+# - Target variable : `$(@F)`
+# - Target variable : `$^`
+# Outputs:
+# - Target variable : `lt.lib.rpath` (`$(@D)`, `$(files.sys)`)
+# - Target variable : `lt.lib.files.all` (`$^`, `$(.LIBPATTERNS)`)
+# - Target variable : `lt.lib.files.ld` (`$(lt.lib.rpath)`, `$(lt.lib.files.all)`)
+# - Target variable : `lt.lib.post` (`$(lt.lib.rpath)`, `$(lt.lib.files.all)`)
+# - Target variable : `lt.exe.files.all` (`$^`, `$(.LIBPATTERNS)`)
+# - Target variable : `lt.exe.files.ld` (an alias for `lt.exe.files.all`)
+#
+# A set of variables to make interacting with libtool a little easier.
+#
+# libtool tries to abstract away the difference between static libraries
+# and dynamic libraries. But, it does a crappy job. If one library
+# depends on another library, you have to care about which of them are
+# static and which are dynamic, or you'll either end up with missing
+# symbols, or duplicate symbols. Either way, it will fail to link your
+# executable.
+#
+# So, our workaround: don't pass any .la libraries to libtool/ld when
+# linking a convenience library, but then run a post-libtool command to
+# insert them into the .la file's dependency_libs. This uses the
+# emptiness of lt.lib.rpath to determine if a library is a static
+# convenience library or not.
+endef
+mod.lt.doc := $(value mod.lt.doc)
+
+_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)))
+_lt.rest = $(wordlist 2,$(words $1),$1)
+# Usage: $(call _lt.dedup,ITEM1 ITEM2 ITEM3)
+# Removes duplicate items while keeping the order the same (the leftmost of a duplicate is used).
+_lt.dedup = $(if $1,$(if $(filter $(firstword $1),$(call _lt.rest,$1)),,$(firstword $1) )$(call _lt.dedup,$(call _lt.rest,$1)))
+# Usage: $(call _lt.dependency_libs,LIB1.la OBJ.lo LIB2.la)
+# => LIB1.la LIB1.la:dependency_libs OBJ.lo LIB2.la LIB2.la:dependency_libs
+# Insert a .la library's dependency_libs after the library itself in the list.
+_lt.dependency_libs = $(foreach _lt.tmp,$1,$(_lt.tmp)$(if $(filter %.la,$(_lt.tmp)), $(shell . $(_lt.tmp); echo $$dependency_libs)))
+
+ lt.lib.rpath = $(patsubst %/,%,$(dir $(filter %/$(@F),$(files.sys))))
+ lt.lib.files.all = $(filter %.lo %.la -l%,$(call _lt.unLIBPATTERNS,$^))
+ lt.lib.files.ld = $(strip $(if $(lt.lib.rpath),\
+ $(lt.lib.files.all),\
+ $(filter-out %.la,$(lt.lib.files.all))))
+_lt.lib.files.dep = $(strip $(call _lt.dedup,$(filter %.la -l%,$(call _lt.dependency_libs,$(lt.lib.files.all)))))
+ lt.lib.post = $(strip $(if $(lt.lib.rpath),\
+ true,\
+ sed -i 's|^dependency_libs=.*|dependency_libs='\''$(_lt.lib.files.dep)'\''|' $@))
+
+lt.exe.files.all = $(filter %.o %.la -l%,$(call _lt.unLIBPATTERNS,$^))
+lt.exe.files.ld = $(lt.exe.files.all)
diff --git a/build-aux/Makefile.once.head/10-nested.mk b/build-aux/Makefile.once.head/10-nested.mk
new file mode 100644
index 0000000000..d903d53cd4
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-nested.mk
@@ -0,0 +1,46 @@
+# Copyright (C) 2016-2017 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.nested.description = Easy nested .PHONY targets
+define mod.nested.doc
+# Inputs:
+# - Global variable : `nested.targets`
+# - Directory variable : `nested.subdirs`
+# Outputs:
+# - .PHONY Targets : `$(addprefix $(outdir)/,$(nested.targets))`
+# - Variable : `at.subdirs`
+# - Variable : `at.targets`
+#
+# The Autothing `at.subdirs` slates a subdirectory's Makefile for inclusion,
+# but doesn't help with recursive targets like `all`, `install`, or `clean`,
+# which one would expect to descend into subdirectories. Enter `nested`:
+# Define a global list of targets that are recursive/nested, and then in each
+# directory define a list of subdirectries that one would expect them to
+# recurse into.
+#
+# Directories added to `nested.subdirs` are automatically added to `at.subdirs`
+# during the each.tail phase.
+#
+# It may help to think of at.subdirs and nested.subdirs in terms of their
+# Automake conterparts:
+#
+# | Autothing | GNU Automake |
+# +----------------+--------------+
+# | at.subdirs | DIST_SUBDIRS |
+# | nested.subdirs | SUBDIRS |
+endef
+mod.nested.doc := $(value mod.nested.doc)
+
+nested.targets ?=
diff --git a/build-aux/Makefile.once.head/10-texinfo.mk b/build-aux/Makefile.once.head/10-texinfo.mk
new file mode 100644
index 0000000000..d24852d8eb
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-texinfo.mk
@@ -0,0 +1,47 @@
+# Copyright (C) 2016-2017 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.texinfo.description = The GNU documentation system
+mod.texinfo.depends += files nested gnuconf
+define mod.texinfo.doc
+# User variables (in addition to gnuconf):
+# - `TEXI2HTML ?= makeinfo --html`
+# - `TEXI2PDF ?= texi2pdf`
+# - `TEXI2PS ?= texi2dvi --ps`
+# Inputs:
+# - Directory variable : `texinfo.docs ?=`
+# Outputs:
+# - Global variable : `files.groups += html dvi pdf ps`
+# - Global variable : `nested.targets += info`
+# - Directory variable : `files.src.gen`
+# - Directory variable : `files.out.{dvi,html,pdf,ps}`
+# - Directory variable : `files.sys.{dvi,html,pdf,ps,all}`
+# - .PHONY target : `$(outdir)/info`
+# - Target : `$(outdir)/%.info`
+# - Target : `$(outdir)/%.dvi`
+# - target : `$(outdir)/%.html`
+# - target : `$(outdir)/%.pdf`
+# - Target : `$(outdir)/%.ps`
+#
+# TODO: prose documentation
+endef
+mod.texinfo.doc := $(value mod.texinfo.doc)
+
+TEXI2HTML ?= makeinfo --html
+TEXI2PDF ?= texi2pdf
+TEXI2PS ?= texi2dvi --ps
+
+files.groups += html dvi pdf ps
+nested.targets += info
diff --git a/build-aux/Makefile.once.head/10-write-atomic.mk b/build-aux/Makefile.once.head/10-write-atomic.mk
new file mode 100644
index 0000000000..c4aa808c61
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-write-atomic.mk
@@ -0,0 +1,23 @@
+mod.write-atomic.description = `write-atomic` auxiliary build script
+mod.write-atomic.files += $(topsrcdir)/build-aux/write-atomic
+define mod.write-atomic.doc
+# User variables:
+# - `WRITE_ATOMIC ?= $(topsrcdir)/build-aux/write-atomic`
+# Inputs:
+# (none)
+# Outputs:
+# (none)
+#
+# The $(WRITE_ATOMIC) program reads a file from stdin, and writes it to
+# the file named in argv[1], but does so atomically.
+#
+# That is, the following lines are almost equivalient:
+#
+# ... > $@
+# ... | $(WRITE_ATOMIC) $@
+#
+# The are only different in that one is atomic, while the other is not.
+endef
+mod.write-atomic.doc := $(value mod.write-atomic.doc)
+
+WRITE_ATOMIC ?= $(topsrcdir)/build-aux/write-atomic
diff --git a/build-aux/Makefile.once.head/10-write-ifchanged.mk b/build-aux/Makefile.once.head/10-write-ifchanged.mk
new file mode 100644
index 0000000000..649aab9c12
--- /dev/null
+++ b/build-aux/Makefile.once.head/10-write-ifchanged.mk
@@ -0,0 +1,23 @@
+mod.write-ifchanged.description = `write-ifchanged` auxiliary build script
+mod.write-ifchanged.files += $(topsrcdir)/build-aux/write-ifchanged
+define mod.write-ifchanged.doc
+# User variables:
+# - `WRITE_IFCHANGED ?= $(topsrcdir)/build-aux/write-ifchanged`
+# Inputs:
+# (none)
+# Outputs:
+# (none)
+#
+# The $(WRITE_IFCHANGED) program reads a file from stdin, and writes it to the
+# file named in argv[1], but does so atomically, but more importantly, does so
+# in a way that does not bump the file's ctime if the new content is the same
+# as the old content.
+#
+# That is, the following lines are almost equivalient:
+#
+# ... > $@
+# ... | $(WRITE_ATOMIC) $@
+endef
+mod.write-ifchanged.doc := $(value mod.write-ifchanged.doc)
+
+WRITE_IFCHANGED ?= $(topsrcdir)/build-aux/write-ifchanged
diff --git a/build-aux/Makefile.once.head/20-amcfg.mk b/build-aux/Makefile.once.head/20-amcfg.mk
new file mode 100644
index 0000000000..57d1561204
--- /dev/null
+++ b/build-aux/Makefile.once.head/20-amcfg.mk
@@ -0,0 +1,84 @@
+mod.amcfg.description = (systemd) Automake-to-Autothing configuration
+mod.amcfg.depends += am
+define mod.amcfg.doc
+# User variables:
+# - `V`
+# - `AM_V_*`
+# - `pamconfdir`
+# - `tmpfilesdir`
+# - `sysusersdir`
+# - `sysctldir`
+# - `bashcompletiondir`
+# - `zshcompletiondir`
+# - `LIBTOOL`
+# - `INSTALL_PROGRAM`
+# - `INSTALL_SCRIPT`
+# - `INSTALL_DATA`
+# Inputs:
+# - Global variable: `sd.ALL_LIBTOOLFLAGS`
+# Outputs:
+# - Global variable: `am.sys2out_*`
+# - Global variable: `am.INSTALL_*`
+endef
+mod.amcfg.doc := $(value mod.amcfg.doc)
+
+am.outpat_pamconf_DATA = %.pam
+
+am.outpat_tmpfiles_DATA = %.tmpfiles
+am.syspat_tmpfiles_DATA = %.conf
+
+am.outpat_sysusers_DATA = %.sysusers
+am.syspat_sysusers_DATA = %.conf
+
+am.outpat_sysctl_DATA = %.sysctl
+am.syspat_sysctl_DATA = %.conf
+
+am.outpat_bashcompletion_DATA = %.completion.bash
+
+am.outpat_zshcompletion_DATA = %.completion.zsh
+am.syspat_zshcompletion_DATA = _%
+
+am.outpat_xinitrc_SCRIPTS = %.xinitrc
+am.syspat_xinitrc_SCRIPTS = %.sh
+
+am.outpat_include_HEADERS = $(abspath $(srcdir)/include)/%.h
+am.syspat_include_HEADERS = %.h
+
+V ?=
+
+AM_V_PROG ?= $(AM_V_PROG_$(V))
+AM_V_PROG_ ?= $(AM_V_PROG_$(AM_DEFAULT_VERBOSITY))
+AM_V_PROG_0 ?= @echo " PROG " $@;
+AM_V_PROG_1 ?=
+
+AM_V_SCRIPT ?= $(AM_V_SCRIPT_$(V))
+AM_V_SCRIPT_ ?= $(AM_V_SCRIPT_$(AM_DEFAULT_VERBOSITY))
+AM_V_SCRIPT_0 ?= @echo " SCRIPT " $@;
+AM_V_SCRIPT_1 ?=
+
+AM_V_LIB ?= $(AM_V_LIB_$(V))
+AM_V_LIB_ ?= $(AM_V_LIB_$(AM_DEFAULT_VERBOSITY))
+AM_V_LIB_0 ?= @echo " LIB " $@;
+AM_V_LIB_1 ?=
+
+AM_V_DATA ?= $(AM_V_DATA_$(V))
+AM_V_DATA_ ?= $(AM_V_DATA_$(AM_DEFAULT_VERBOSITY))
+AM_V_DATA_0 ?= @echo " DATA " $@;
+AM_V_DATA_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_MAN ?= $(AM_V_MAN_$(V))
+AM_V_MAN_ ?= $(AM_V_MAN_$(AM_DEFAULT_VERBOSITY))
+AM_V_MAN_0 ?= @echo " MAN " $@;
+AM_V_MAN_1 ?=
+
+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) $< $@
+am.INSTALL_MANS = $(AM_V_MAN)$(INSTALL_DATA) $< $@
diff --git a/build-aux/Makefile.once.head/20-sd.mk b/build-aux/Makefile.once.head/20-sd.mk
index 134c2c0ef1..4e44d2f7b3 100644
--- a/build-aux/Makefile.once.head/20-sd.mk
+++ b/build-aux/Makefile.once.head/20-sd.mk
@@ -20,81 +20,173 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
-include $(topsrcdir)/build-aux/Makefile.head.mk
-ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-AM_MAKEFLAGS = --no-print-directory
-AUTOMAKE_OPTIONS = color-tests parallel-tests
+mod.sd.description = (systemd) shared build rules
+mod.sd.depends += am
+define mod.sd.doc
+# User variables:
+# (flags)
+# - `CFLAGS`
+# - `CPPFLAGS`
+# - `LDFLAGS`
+# - `LIBTOOLFLAGS`
+# (programs)
+# - `CC`
+# - `CCLD`
+# - `LIBTOOL`
+# - `MKDIR_P`
+# - `SED`
+# (verbosity)
+# - `V`
+# - `AM_V_*`
+# - `INTLTOOL_V_MERGE*`
+# (substitutions)$(foreach v,$(sort $(sd.substitution_keys)),$(at.nl)# - $v)
+# Inputs:
+# - Global variable : `DEPDIR`
+# - Global variable : `ENABLE_TESTS`
+# - Global variable : `ENABLE_UNSAFE_TESTS`
+# - Global variable : `OUR_CFLAGS`
+# - Global variable : `OUR_CPPFLAGS`
+# - Global variable : `OUR_LDFLAGS`
+# - Global variable : `OUR_LIBTOOLFLAGS`
+# (Makefiles)
+# - Directory variable : `sd.CFLAGS`
+# - Directory variable : `sd.CPPFLAGS`
+# - Directory variable : `sd.LDFLAGS`
+# - Directory variable : `sd.LIBTOOLFLAGS`
+# - Directory variable : `sd.sed_files` (default based on `EXTRA_DIST`)
+# (am)
+# - Directory variable : `EXTRA_DIST`
+# - Directory variable : `am.out_PROGRAMS`
+# - Directory variable : `am.CFLAGS`
+# - Directory variable : `am.CPPFLAGS`
+# - Target variable : `am.LDFLAGS`
+# Outputs:
+# - Global variable : `SHELL`
+# - Make setting : `.DELETE_ON_ERROR`
+# - Make setting : `.SECONDARY`
+# - Global variable : `sd.substitutions`
+# - Global variable : `sd.substitution_keys`
+# - Global variable : `sd.sed_process`
+# - Directory variable : `files.out.int`
+# - Target variable : `sd.ALL_CFLAGS`
+# - Target variable : `sd.ALL_CPPFLAGS`
+# - Target variable : `sd.ALL_LDFLAGS`
+# - Target variable : `sd.ALL_LIBTOLFLAGS`
+# - Target variable : `sd.COMPILE`
+# - Target variable : `sd.LTCOMPILE`
+# - Target variable : `sd.LINK`
+# - Target : `$$(outdir)/%.o`
+# - Target : `$$(outdir)/%.lo`
+# - Target : `$$(outdir)/$$(DEPDIR)`
+# - Target : `$$(outdir)/%.la`
+# - Target : `$$(addprefix $$(outdir)/,$$(am.out_PROGRAMS))`
+# - Target : `$$(outdir)/test-lib%-sym.c`
+# - Target : `$$(outdir)/%-from-name.gperf`
+# - Target : `$$(outdir)/%-from-name.h`
+# - Target : `$$(addprefix $$(outdir)/,$$(sd.sed_files))`
+# - Target : `$$(outdir)/%.c: $$(srcdir)/%.gperf`
+# - Target : `$$(outdir)/%: $$(srcdir)/%.m4`
+# ???:
+# - tests
+# - unsafe_tests
+# - TESTS
-GCC_COLORS ?= 'ooh, shiny!'
-export GCC_COLORS
+endef
-SUBDIRS = . po
+tests ?=
+unsafe_tests ?=
+TESTS = $(if $(ENABLE_TESTS),$(tests) \
+ $(if $(ENABLE_UNSAFE_TESTS),$(unsafe_tests)))
-# remove targets if the command fails
-.DELETE_ON_ERROR:
+# Make behavior
+SHELL = bash -o pipefail
-# keep intermediate files
+.DELETE_ON_ERROR:
.SECONDARY:
-# Keep the test-suite.log
-.PRECIOUS: $(TEST_SUITE_LOG) Makefile
+# Autoconf
+OUR_CPPFLAGS += -MT $@ -MD -MP -MF $(@D)/$(DEPDIR)/$(basename $(@F)).P$(patsubst .%,%,$(suffix $(@F)))
+OUR_CPPFLAGS += -include $(topoutdir)/config.h
+OUR_CPPFLAGS += $(sort -I$(@D) $(if $(<D),-I$(<D) -I$(call at.out2src,$(<D))))
+
+sd.ALL_CFLAGS = $(strip $(OUR_CFLAGS) $(am.CFLAGS) $(sd.CFLAGS) $(CFLAGS) )
+sd.ALL_CPPFLAGS = $(strip $(OUR_CPPFLAGS) $(am.CPPFLAGS) $(sd.CPPFLAGS) $(CPPFLAGS) )
+sd.ALL_LDFLAGS = $(strip $(OUR_LDFLAGS) $(am.LDFLAGS) $(sd.LDFLAGS) $(LDFLAGS) )
+sd.ALL_LIBTOOLFLAGS = $(strip $(OUR_LIBTOOLFLAGS) $(sd.LIBTOOLFLAGS) $(LIBTOOLFLAGS) )
+
+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 $@
+
+CC ?= c99
+CCLD ?= c99
+LIBTOOL ?= libtool
V ?=
-AM_V_M4 = $(AM_V_M4_$(V))
-AM_V_M4_ = $(AM_V_M4_$(AM_DEFAULT_VERBOSITY))
-AM_V_M4_0 = @echo " M4 " $@;
-AM_V_M4_1 =
-
-AM_V_GPERF = $(AM_V_GPERF_$(V))
-AM_V_GPERF_ = $(AM_V_GPERF_$(AM_DEFAULT_VERBOSITY))
-AM_V_GPERF_0 = @echo " GPERF " $@;
-AM_V_GPERF_1 =
-
-AM_V_RM = $(AM_V_RM_$(V))
-AM_V_RM_ = $(AM_V_RM_$(AM_DEFAULT_VERBOSITY))
-AM_V_RM_0 = @echo " RM " $@;
-AM_V_RM_1 =
-
-AM_V_CC = $(AM_V_CC_$(V))
-AM_V_CC_ = $(AM_V_CC_$(AM_DEFAULT_VERBOSITY))
-AM_V_CC_0 = @echo " CC " $@;
-AM_V_CC_1 =
-
-AM_V_CCLD = $(AM_V_CCLD_$(V))
-AM_V_CCLD_ = $(AM_V_CCLD_$(AM_DEFAULT_VERBOSITY))
-AM_V_CCLD_0 = @echo " CCLD " $@;
-AM_V_CCLD_1 =
-
-AM_V_P = $(AM_V_P_$(V))
-AM_V_P_ = $(AM_V_P_$(AM_DEFAULT_VERBOSITY))
-AM_V_P_0 = false
-AM_V_P_1 = :
-
-AM_V_GEN = $(AM_V_GEN_$(V))
-AM_V_GEN_ = $(AM_V_GEN_$(AM_DEFAULT_VERBOSITY))
-AM_V_GEN_0 = @echo " GEN " $@;
-AM_V_GEN_1 =
-
-AM_V_at = $(AM_V_at_$(V))
-AM_V_at_ = $(AM_V_at_$(AM_DEFAULT_VERBOSITY))
-AM_V_at_0 = @
-AM_V_at_1 =
-
-AM_V_lt = $(AM_V_lt_$(V))
-AM_V_lt_ = $(AM_V_lt_$(AM_DEFAULT_VERBOSITY))
-AM_V_lt_0 = --silent
-AM_V_lt_1 =
-
-INTLTOOL_V_MERGE = $(INTLTOOL_V_MERGE_$(V))
-INTLTOOL_V_MERGE_OPTIONS = $(intltool_v_merge_options_$(V))
-INTLTOOL_V_MERGE_ = $(INTLTOOL_V_MERGE_$(AM_DEFAULT_VERBOSITY))
-INTLTOOL_V_MERGE_0 = @echo " ITMRG " $@;
-INTLTOOL_V_MERGE_1 =
-
-substitutions = \
+AM_V_at ?= $(AM_V_at_$(V))
+AM_V_at_ ?= $(AM_V_at_$(AM_DEFAULT_VERBOSITY))
+AM_V_at_0 ?= @
+AM_V_at_1 ?=
+
+AM_V_M4 ?= $(AM_V_M4_$(V))
+AM_V_M4_ ?= $(AM_V_M4_$(AM_DEFAULT_VERBOSITY))
+AM_V_M4_0 ?= @echo " M4 " $@;
+AM_V_M4_1 ?=
+
+AM_V_GPERF ?= $(AM_V_GPERF_$(V))
+AM_V_GPERF_ ?= $(AM_V_GPERF_$(AM_DEFAULT_VERBOSITY))
+AM_V_GPERF_0 ?= @echo " GPERF " $@;
+AM_V_GPERF_1 ?=
+
+AM_V_RM ?= $(AM_V_RM_$(V))
+AM_V_RM_ ?= $(AM_V_RM_$(AM_DEFAULT_VERBOSITY))
+AM_V_RM_0 ?= @echo " RM " $@;
+AM_V_RM_1 ?=
+
+AM_V_CC ?= $(AM_V_CC_$(V))
+AM_V_CC_ ?= $(AM_V_CC_$(AM_DEFAULT_VERBOSITY))
+AM_V_CC_0 ?= @echo " CC " $@;
+AM_V_CC_1 ?=
+
+AM_V_CCLD ?= $(AM_V_CCLD_$(V))
+AM_V_CCLD_ ?= $(AM_V_CCLD_$(AM_DEFAULT_VERBOSITY))
+AM_V_CCLD_0 ?= @echo " CCLD " $@;
+AM_V_CCLD_1 ?=
+
+AM_V_EFI_CC ?= $(AM_V_EFI_CC_$(V))
+AM_V_EFI_CC_ ?= $(AM_V_EFI_CC_$(AM_DEFAULT_VERBOSITY))
+AM_V_EFI_CC_0 ?= @echo " EFI_CC " $@;
+AM_V_EFI_CC_1 ?=
+
+AM_V_EFI_CCLD ?= $(AM_V_EFI_CCLD_$(V))
+AM_V_EFI_CCLD_ ?= $(AM_V_EFI_CCLD_$(AM_DEFAULT_VERBOSITY))
+AM_V_EFI_CCLD_0 ?= @echo " EFI_CCLD" $@;
+AM_V_EFI_CCLD_1 ?=
+
+AM_V_P ?= $(AM_V_P_$(V))
+AM_V_P_ ?= $(AM_V_P_$(AM_DEFAULT_VERBOSITY))
+AM_V_P_0 ?= false
+AM_V_P_1 ?= :
+
+AM_V_GEN ?= $(AM_V_GEN_$(V))
+AM_V_GEN_ ?= $(AM_V_GEN_$(AM_DEFAULT_VERBOSITY))
+AM_V_GEN_0 ?= @echo " GEN " $@;
+AM_V_GEN_1 ?=
+
+AM_V_lt ?= $(AM_V_lt_$(V))
+AM_V_lt_ ?= $(AM_V_lt_$(AM_DEFAULT_VERBOSITY))
+AM_V_lt_0 ?= --silent
+AM_V_lt_1 ?=
+
+INTLTOOL_V_MERGE ?= $(INTLTOOL_V_MERGE_$(V))
+INTLTOOL_V_MERGE_OPTIONS ?= $(intltool_v_merge_options_$(V))
+INTLTOOL_V_MERGE_ ?= $(INTLTOOL_V_MERGE_$(AM_DEFAULT_VERBOSITY))
+INTLTOOL_V_MERGE_0 ?= @echo " ITMRG " $@;
+INTLTOOL_V_MERGE_1 ?=
+
+sd.substitutions = \
'|rootlibexecdir=$(rootlibexecdir)|' \
'|rootbindir=$(rootbindir)|' \
'|bindir=$(bindir)|' \
@@ -156,10 +248,9 @@ substitutions = \
'|binfmtdir=$(binfmtdir)|' \
'|modulesloaddir=$(modulesloaddir)|'
-SED_PROCESS = \
+sd.substitution_keys := $(subst |,,$(shell printf '%s\n' $(sd.substitutions) | cut -d= -f1))
+
+sd.SED_PROCESS = \
$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
- $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
+ $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(sd.substitutions)))) \
< $< > $@
-
-
-include $(topsrcdir)/build-aux/Makefile.tail.mk
diff --git a/build-aux/Makefile.once.head/20-sdman.mk b/build-aux/Makefile.once.head/20-sdman.mk
index 3fb076febe..558c60531d 100644
--- a/build-aux/Makefile.once.head/20-sdman.mk
+++ b/build-aux/Makefile.once.head/20-sdman.mk
@@ -20,20 +20,59 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
-include $(topsrcdir)/build-aux/Makefile.head.mk
-AM_V_XSLT = $(AM_V_XSLT_$(V))
-AM_V_XSLT_ = $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
-AM_V_XSLT_0 = @echo " XSLT " $@;
-AM_V_XSLT_1 =
+mod.sdman.description = (systemd) manpages
+mod.sdman.depends += am files write-atomic
+define mod.sdman.doc
+# User variables:
+# - `V`
+# - `AM_V_LN*`
+# - `AM_V_XSLT*`
+# - `LN_S`
+# - `XSLTPROC`
+# Inputs:
+# - Global variable : `ENABLE_MANPAGES`
+# - Global variable : `VERSION`
+# - Directory variable : `files.src.src`
+# Outputs:
+# - File : `$(srcdir)/Makefile-man.mk`
+# - Directory variable : `at.subdirs`
+# - Directory variable : `files.src.gen`
+# - Directory variable : `man_MANS`
+# - Directory variable : `noinst_DATA` (HTML)
+# - Target : `$(outdir)/%.1`
+# - Target : `$(outdir)/%.3`
+# - Target : `$(outdir)/%.5`
+# - Target : `$(outdir)/%.7`
+# - Target : `$(outdir)/%.8`
+# - Target : `$(outdir)/%.html`
+#
+# sdman -> Makefile-man.mk:
+# - Global variable : `sdman.html-alias`
+# Makefile-man.mk -> sdman:
+# - Directory variable : `sdman.MANPAGES`
+# - Directory variable : `sdman.MANPAGES_ALIAS`
+#
+# The `sdman.*` variables are the interface by which the module
+# communicates with the genrated Makefile-man.mk file. They should not
+# be used outside of the `sdman` module.
+endef
+mod.sdman.doc := $(value mod.sdman.doc)
+
+V ?=
+LN_S ?= ln -s
-AM_V_LN = $(AM_V_LN_$(V))
-AM_V_LN_ = $(AM_V_LN_$(AM_DEFAULT_VERBOSITY))
-AM_V_LN_0 = @echo " LN " $@;
-AM_V_LN_1 =
+AM_V_LN ?= $(AM_V_LN_$(V))
+AM_V_LN_ ?= $(AM_V_LN_$(AM_DEFAULT_VERBOSITY))
+AM_V_LN_0 ?= @echo " LN " $@;
+AM_V_LN_1 ?=
-XSLTPROC_FLAGS = \
+AM_V_XSLT ?= $(AM_V_XSLT_$(V))
+AM_V_XSLT_ ?= $(AM_V_XSLT_$(AM_DEFAULT_VERBOSITY))
+AM_V_XSLT_0 ?= @echo " XSLT " $@;
+AM_V_XSLT_1 ?=
+
+_sdman.XSLTPROC_FLAGS = \
--nonet \
--xinclude \
--stringparam man.output.quietly 1 \
@@ -41,18 +80,14 @@ XSLTPROC_FLAGS = \
--stringparam man.authors.section.enabled 0 \
--stringparam man.copyright.section.enabled 0 \
--stringparam systemd.version $(VERSION) \
- --path '$(builddir)/man:$(srcdir)/man'
+ --path '$(outdir):$(srcdir):$(topoutdir)/man:$(topsrcdir)/man'
-XSLT = $(if $(XSLTPROC), $(XSLTPROC), xsltproc)
-XSLTPROC_PROCESS_MAN = \
- $(AM_V_XSLT)$(XSLT) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
+_sdman.XSLT = $(if $(XSLTPROC), $(XSLTPROC), xsltproc)
+_sdman.XSLTPROC_PROCESS_MAN = \
+ $(AM_V_XSLT)$(_sdman.XSLT) -o $@ $(_sdman.XSLTPROC_FLAGS) $(srcdir)/man/custom-man.xsl $<
-XSLTPROC_PROCESS_HTML = \
- $(AM_V_XSLT)$(XSLT) -o $@ $(XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
+_sdman.XSLTPROC_PROCESS_HTML = \
+ $(AM_V_XSLT)$(_sdman.XSLT) -o $@ $(_sdman.XSLTPROC_FLAGS) $(srcdir)/man/custom-html.xsl $<
-define html-alias
+sdman.html-alias = \
$(AM_V_LN)$(LN_S) -f $(notdir $<) $@
-endef
-
-
-include $(topsrcdir)/build-aux/Makefile.tail.mk
diff --git a/build-aux/Makefile.once.head/30-am.mk b/build-aux/Makefile.once.head/30-am.mk
new file mode 100644
index 0000000000..9a27b86c82
--- /dev/null
+++ b/build-aux/Makefile.once.head/30-am.mk
@@ -0,0 +1,336 @@
+mod.am.description = (systemd) Automake-to-Autothing magic
+mod.am.depends += gnuconf
+define mod.am.doc
+# Because many of the inputs/outpus are repetative, they are defined
+# here in terms of $$(primary), which may be any of the supported
+# Automake primaries (see below for a table).
+#
+# | Automake 1.15 primaries |
+# +-------------------------+
+# | name | supported |
+# +-------------+-----------+
+# | PROGRAMS | yes |
+# | LIBRARIES | no |
+# | LTLIBRARIES | yes |
+# | LISP | no |
+# | PYTHON | no |
+# | JAVA | no |
+# | SCRIPTS | yes |
+# | DATA | yes |
+# | HEADERS | yes |
+# | MANS | yes |
+# | TEXINFOS | no |
+#
+# Further, there is also $$(dirname), which could be anything; and is
+# detected at runtime by inspecting $$(.VARIABLES) to find every possible
+# matching value. See `_am.primary2dirs` for how this is done.
+#
+# Some inputs are "erased" after the pass they are used in. This means
+# that they are `undefine`ed.
+#
+$(value _am.pass0.doc)
+#
+$(value _am.pass1.doc)
+#
+$(value _am.pass2.doc)
+#
+$(value _am.pass3.doc)
+#
+$(value _am.pass4.doc)
+#
+$(value _am.pass5.doc)
+endef
+
+_am.primaries =
+_am.primaries += PROGRAMS
+#_am.primaries += LIBRARIES
+_am.primaries += LTLIBRARIES
+#_am.primaries += LISP
+#_am.primaries += PYTHON
+#_am.primaries += JAVA
+_am.primaries += SCRIPTS
+_am.primaries += DATA
+_am.primaries += HEADERS
+_am.primaries += MANS
+#_am.primaries += TEXINFOS
+
+# Used by the PROGRAMS and LTLIBRARIES passes
+_am.file2var = $(subst -,_,$(subst .,_,$1))
+_am.file2sources = $(addprefix $(srcdir)/,$(notdir $($(_am.file2var)_SOURCES)))
+_am.file2sources += $(addprefix $(outdir)/,$(notdir $(nodist_$(_am.file2var)_SOURCES)))
+_am.file2.o = $(patsubst $(srcdir)/%,$(outdir)/%,$(patsubst %.c,%.o ,$(filter %.c,$(_am.file2sources))))
+_am.file2.lo = $(patsubst %.o,%.lo,$(_am.file2.o))
+_am.file2lib = $(foreach l, $($(_am.file2var)_$2),$(if $(filter lib%.la,$l), $($(l:.la=).DEPENDS) , $l ))
+_am.file2cpp = $(foreach l,$1 $($(_am.file2var)_$2),$(if $(filter lib%.la,$l), $($(l:.la=).CPPFLAGS) , ))
+
+define _am.pass0.doc
+# == Pass 0: man_MANS ==
+# Erased inputs:
+# - Directory variable: `man_MANS`
+# Outputs:
+# - Directory variable: `man$n_MANS` for $n in `{0..9} n l`
+#
+# Split man_MANS into man$n_MANS
+endef
+_am.pass0 = $(value _am.pass0_)
+define _am.pass0_
+# == Pass 0: man_MANS ==
+man_MANS ?=
+_am.man_MANS := $(man_MANS)
+undefine man_MANS
+man0_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .0,$(suffix $(_am.tmp))),$(_am.tmp)))
+man1_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .1,$(suffix $(_am.tmp))),$(_am.tmp)))
+man2_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .2,$(suffix $(_am.tmp))),$(_am.tmp)))
+man3_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .3,$(suffix $(_am.tmp))),$(_am.tmp)))
+man4_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .4,$(suffix $(_am.tmp))),$(_am.tmp)))
+man5_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .5,$(suffix $(_am.tmp))),$(_am.tmp)))
+man6_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .6,$(suffix $(_am.tmp))),$(_am.tmp)))
+man7_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .7,$(suffix $(_am.tmp))),$(_am.tmp)))
+man8_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .8,$(suffix $(_am.tmp))),$(_am.tmp)))
+man9_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .9,$(suffix $(_am.tmp))),$(_am.tmp)))
+manl_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .l,$(suffix $(_am.tmp))),$(_am.tmp)))
+mann_MANS += $(foreach _am.tmp,$(_am.man_MANS),$(if $(findstring .n,$(suffix $(_am.tmp))),$(_am.tmp)))
+endef
+
+define _am.pass1.doc
+# == Pass 1: initialize variables ==
+# Inputs: (used to detect a list of $(dirname)s)
+# - Directory variable : `$(dirname)_$(primary)`
+# - Directory variable : `nodist_$(dirname)_$(primary)`
+# - Directory variable : `dist_$(dirname)_$(primary)`
+# Outputs:
+# - Directory variable : `noinst_$(primary) ?=`
+# - Directory variable : `check_$(primary) ?=`
+# - Directory variable : ` $(dirname)_$(primary) ?=`
+# - Directory variable : ` dist_$(dirname)_$(primary) ?=`
+# - Directory variable : `nodist_$(dirname)_$(primary) ?=`
+# - Global variable : `am.outpat_$(dirname)_$(primary) ?= %`
+# - Global variable : `am.syspat_$(dirname)_$(primary) ?= %`
+#
+# Make sure that several variabes are initialized
+endef
+
+# Utility (reused in pass 2)
+_am.primary2dirs = $(filter $(patsubst %dir,%,$(filter %dir,$(.VARIABLES))),\
+ $(patsubst nodist_%,%,$(patsubst dist_%,%,$(patsubst %_$1,%,$(filter %_$1,$(.VARIABLES))))))
+
+define _am.pass1
+# == Pass 1: initialize variables ==
+$(foreach _am.primary,$(_am.primaries),
+ $(foreach _am.dirname,$(call _am.primary2dirs,$(_am.primary)),
+ am.outpat_$(_am.dirname)_$(_am.primary) ?= %
+ am.syspat_$(_am.dirname)_$(_am.primary) ?= %))
+endef
+
+define _am.pass2.doc
+# == Pass 2: Uniform Naming Scheme ==
+# Inputs:
+# - Global variable : `NORMAL_INSTALL`
+# - Global variable : `MKDIR_P`
+# - Global variable : `am.INSTALL_$(primary)`
+# - Global variable : `am.outpat_$(dirname)_$(primary)`
+# - Global variable : `am.syspat_$(dirname)_$(primary)
+# - Global variable : `$(dirname)dir`
+# Erased inputs:
+# - Directory variable : `noinst_$(primary)`
+# - Directory variable : `check_$(primary)`
+#
+# - Directory variable : `$(dirname)_$(primary)`
+# - Directory variable : `dist_$(dirname)_$(primary)`
+# - Directory variable : `nodist_$(dirname)_$(primary)`
+# Outputs:
+# - Directory variable : `am.chk_$(primary)`
+# - Directory variable : `am.out_$(primary)`
+# - Directory variable : `am.sys_$(primary)`
+# - Targets : `$(addprefix $(DESTDIR)$(dirname)/,$(notdir $({,dist_,nodist_}$(dirname)_$(primary))))`
+#
+# TODO
+endef
+
+# Default values
+am.INSTALL_PROGRAMS ?= $(INSTALL_PROGRAM) $< $@
+am.INSTALL_SCRIPTS ?= $(INSTALL) $< $@
+am.INSTALL_LTLIBRARIES ?= $(INSTALL) $< $@
+am.INSTALL_DATA ?= $(INSTALL_DATA) $< $@
+am.INSTALL_HEADERS ?= $(INSTALL_DATA) $< $@
+am.INSTALL_MANS ?= $(INSTALL_DATA) $< $@
+
+# Utility
+_am.var_out = $(_am.dirname)_$(_am.primary)
+_am.var_out += nodist_$(_am.dirname)_$(_am.primary)
+#_am.var_out += noinst_$(_am.primary)
+#_am.var_out += check_$(_am.primary)
+
+_am.var_sys = $(_am.dirname)_$(_am.primary)
+_am.var_sys += nodist_$(_am.dirname)_$(_am.primary)
+_am.var_sys += dist_$(_am.dirname)_$(_am.primary)
+
+define _am.pass2
+# == Pass 2: Uniform Naming Scheme ==
+$(foreach _am.primary,$(_am.primaries),
+ ## primary: $(_am.primary)
+ noinst_$(_am.primary) ?=
+ check_$(_am.primary) ?=
+
+ am.chk_$(_am.primary) := $$(check_$(_am.primary))
+ am.out_$(_am.primary) := $$(noinst_$(_am.primary))
+ am.sys_$(_am.primary) :=
+
+ $(foreach _am.dirname,$(call _am.primary2dirs,$(_am.primary)),
+ ## dirname: $(_am.dirname) ($(_am.primary))
+ $(_am.dirname)_$(_am.primary) ?=
+ dist_$(_am.dirname)_$(_am.primary) ?=
+ nodist_$(_am.dirname)_$(_am.primary) ?=
+
+ $$(addprefix $$(DESTDIR)$$($(_am.dirname)dir)/,$$(notdir $(foreach v,$(_am.var_sys),$$($v)) )): \
+ $$(DESTDIR)$$($(_am.dirname)dir)/$(am.syspat_$(_am.dirname)_$(_am.primary)): $(call at.addprefix,$(outdir),$(am.outpat_$(_am.dirname)_$(_am.primary)))
+ @$$(NORMAL_INSTALL)
+ @$$(MKDIR_P) $$(@D)
+ $$(am.INSTALL_$(_am.primary))
+
+ am.out_$(_am.primary) := $$(patsubst $(am.syspat_$(_am.dirname)_$(_am.primary)),$(am.outpat_$(_am.dirname)_$(_am.primary)),$$(notdir $(foreach v,$(_am.var_out),$$($v)) ))
+ am.sys_$(_am.primary) := $$(addprefix $$($(_am.dirname)dir)/,$$(notdir $(foreach v,$(_am.var_sys),$$($v)) ))
+
+ undefine $(_am.dirname)_$(_am.primary)
+ undefine dist_$(_am.dirname)_$(_am.primary)
+ undefine nodist_$(_am.dirname)_$(_am.primary)
+ ## (end dirname)
+ )
+
+ undefine noinst_$(_am.primary)
+ undefine check_$(_am.primary)
+ ## (end primary)
+)
+endef
+
+define _am.pass3.doc
+# == Pass 3: PROGRAMS ==
+# Inputs:
+# - Directory variable : `am.out_PROGRAMS`
+# Erased inputs:
+# - Directory variable : `$(program)_SOURCES`
+# - Directory variable : `nodist_$(program)_SOURCES`
+# - Directory variable : `$(program)_CFLAGS`
+# - Directory variable : `$(program)_CPPFLAGS`
+# - Directory variable : `$(program)_LDFLAGS`
+# - Directory variable : `$(program)_LDADD`
+# Outputs:
+# - Directory variable : `am.CPPFLAGS`
+# - Directory variable : `am.CFLAGS`
+# - Target dependencies: `$(outdir)/$(program)`
+# - Target variable : `$(outdir)/$(program): am.LDFLAGS`
+# - Directory variable : `am.subdirs`
+#
+# TODO: I'm not in love with how it figures out `am.subdirs`.
+# TODO: I'm not in love with how it does the `install` dependencies.
+endef
+
+# Utility
+_am.var_PROGRAMS = $(_am.var)_SOURCES
+_am.var_PROGRAMS += nodist_$(_am.var)_SOURCES
+_am.var_PROGRAMS += $(_am.var)_CFLAGS
+_am.var_PROGRAMS += $(_am.var)_CPPFLAGS
+_am.var_PROGRAMS += $(_am.var)_LDFLAGS
+_am.var_PROGRAMS += $(_am.var)_LDADD
+
+define _am.pass3
+# == Pass 3: PROGRAMS ==
+$(foreach _am.file,$(am.out_PROGRAMS),
+ $(eval _am.var = $(call _am.file2var,$(_am.file)))
+ ## PROGRAM: $(_am.file) ($(_am.var))
+ $(foreach var,_am.depends $(_am.var_PROGRAMS),
+ $(var) ?=)
+
+ _am.depends += $$(call at.path,$$(call _am.file2.o,$(_am.file)) $$(call _am.file2lib,$(_am.file),LDADD))
+ am.CPPFLAGS += $$($(_am.var)_CPPFLAGS) $$(call _am.file2cpp,$(_am.file),LDADD)
+ am.CFLAGS += $$($(_am.var)_CFLAGS)
+ $$(outdir)/$(_am.file): private am.LDFLAGS := $$($(_am.var)_LDFLAGS)
+ $$(outdir)/$(_am.file): $$(_am.depends)
+ $$(outdir)/install: $$(addsuffix install,$$(dir $$(filter %.la,$$(_am.depends))))
+ am.subdirs := $$(sort $$(am.subdirs)\
+ $$(filter-out $$(abspath $$(srcdir)),\
+ $$(abspath $$(dir $$(filter-out -l% /%,$$(_am.depends))))))
+
+ am.CPPFLAGS := $$(am.CPPFLAGS)
+ am.CFLAGS := $$(am.CFLAGS)
+
+ $(foreach var,_am.depends $(_am.var_PROGRAMS),
+ undefine $(var)))
+endef
+
+define _am.pass4.doc
+# == Pass 4: LTLIBRARIES ==
+# Inputs:
+# - Directory variable : `am.out_LTLIBRARIES`
+# Erased inputs:
+# - Directory variable : `$(library)_SOURCES`
+# - Directory variable : `nodist_$(library)_SOURCES`
+# - Directory variable : `$(library)_CFLAGS`
+# - Directory variable : `$(library)_CPPFLAGS`
+# - Directory variable : `$(library)_LDFLAGS`
+# - Directory variable : `$(library)_LIBADD`
+# Outputs:
+# - Directory variable : `am.CPPFLAGS`
+# - Directory variable : `am.CFLAGS`
+# - Target dependencies: `$(outdir)/$(library)`
+# - Target variable : `$(outdir)/$(library): am.LDFLAGS`
+# - Directory variable : `am.subdirs`
+#
+# TODO: I'm not in love with how it figures out `am.subdirs`.
+# TODO: I'm not in love with how it does the `install` dependencies.
+endef
+
+# Utility
+_am.var_LTLIBRARIES = $(_am.var)_SOURCES
+_am.var_LTLIBRARIES += nodist_$(_am.var)_SOURCES
+_am.var_LTLIBRARIES += $(_am.var)_CFLAGS
+_am.var_LTLIBRARIES += $(_am.var)_CPPFLAGS
+_am.var_LTLIBRARIES += $(_am.var)_LDFLAGS
+_am.var_LTLIBRARIES += $(_am.var)_LIBADD
+
+define _am.pass4
+# == Pass 4: LTLIBRARIES ==
+$(foreach _am.file,$(am.out_LTLIBRARIES),
+ $(eval _am.var = $(call _am.file2var,$(_am.file)))
+ ## LTLIBRARY: $(_am.file) ($(_am.var))
+ $(foreach var,_am.depends $(_am.var_LTLIBRARIES),
+ $(var) ?=)
+
+ _am.depends += $$(call at.path,$$(call _am.file2.lo,$(_am.file)) $$(call _am.file2lib,$(_am.file),LIBADD))
+ am.CPPFLAGS += $$($(_am.var)_CPPFLAGS) $$(call _am.file2cpp,$(_am.file),LIBADD)
+ am.CFLAGS += $$($(_am.var)_CFLAGS)
+ $$(outdir)/$(_am.file): private am.LDFLAGS := $$($(_am.var)_LDFLAGS)
+ $$(outdir)/$(_am.file): $$(_am.depends)
+ $$(outdir)/install: $$(addsuffix install,$$(dir $$(filter %.la,$$(_am.depends))))
+ am.subdirs := $$(sort $$(am.subdirs)\
+ $$(filter-out $$(abspath $$(srcdir)),\
+ $$(abspath $$(dir $$(filter-out -l% /%,$$(_am.depends))))))
+
+ am.CPPFLAGS := $$(am.CPPFLAGS)
+ am.CFLAGS := $$(am.CFLAGS)
+ $(foreach var,_am.depends $(_am.var_LTLIBRARIES),
+ undefine $(var)))
+endef
+
+mod.am.depends += files
+define _am.pass5.doc
+# == Pass 5: export ==
+# Inputs:
+# - Directory variable : `am.subdirs`
+# - Directory variable : `am.sys_$(primary)`
+# - Directory variable : `am.out_$(primary)`
+# - Directory variable : `am.check_$(primary)`
+# Outputs:
+# - Directory variable : `at.subdirs`
+# - Directory variable : `files.sys.all`
+# - Directory variable : `files.out.all`
+# - Directory variable : `files.out.check`
+endef
+_am.pass5 = $(value _am.pass5_)
+define _am.pass5_
+# == Pass 4: export ==
+at.subdirs += $(am.subdirs)
+files.out.check += $(foreach p,$(_am.primaries),$(am.chk_$p))
+files.out.all += $(foreach p,$(_am.primaries),$(am.out_$p))
+files.sys.all += $(foreach p,$(_am.primaries),$(am.sys_$p))
+endef
diff --git a/build-aux/Makefile.once.head/zz-mod.mk b/build-aux/Makefile.once.head/zz-mod.mk
new file mode 100644
index 0000000000..95d251d37c
--- /dev/null
+++ b/build-aux/Makefile.once.head/zz-mod.mk
@@ -0,0 +1,59 @@
+# 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.mod.description = Display information about Autothing modules
+mod.mod.depends += quote
+define mod.mod.doc
+# Inputs:
+# - Files : `$(topsrcdir)/build-aux/Makefile.*/??-*.mk`
+# - Global variable : `mod.*.description`
+# - Global variable : `mod.*.depends`
+# - Global variable : `mod.*.files`
+# - Global variable : `mod.*.doc`
+# Outputs:
+# - Directory variable : `at.targets`
+# - .PHONY Target : `$(outdir)/at-variables-local`
+# - .PHONY Target : `$(outdir)/at-variables-global`
+# - .PHONY Target : `$(outdir)/at-variables`
+# - .PHONY Target : `$(outdir)/at-variables/%`
+# - .PHONY Target : `$(outdir)/at-values`
+# - .PHONY Target : `$(outdir)/at-values/%`
+# - .PHONY Target : `$(outdir)/at-modules`
+# - .PHONY Target : `$(outdir)/at-modules/%`
+# - .PHONY Target : `$(outdir)/at-noop`
+#
+# TODO: prose documentation
+endef
+mod.mod.doc := $(value mod.mod.doc)
+
+# 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)
+
+_mod.file2mod = $(foreach _mod.tmp,$(patsubst %.mk,%,$(notdir $1)),$(subst $(_mod.space),-,$(call _mod.rest,$(subst -, ,$(_mod.tmp)))))
+
+_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.$(_mod.tmp).doc ?=$(at.nl)))
diff --git a/build-aux/Makefile.once.tail/00-dist.mk b/build-aux/Makefile.once.tail/00-dist.mk
new file mode 100644
index 0000000000..59a7dc3c70
--- /dev/null
+++ b/build-aux/Makefile.once.tail/00-dist.mk
@@ -0,0 +1,31 @@
+# Copyright (C) 2015-2017 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/>.
+
+# NB: intentionally resolve symlinks (tack on the -P flag to `cp` to
+# not resolve them). The GNU Coding Standards say to avoid symlinks
+# in tarballs.
+_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): $(_dist.files)
+ $(RM) -r $@ $(@D)/.tmp.$(@F)
+ $(MKDIR) $(@D)/.tmp.$(@F)
+ $(foreach f,$^,$(call _dist.addfile,$(topsrcdir),$(@D)/.tmp.$(@F),$f)$(at.nl))
+ $(MV) $(@D)/.tmp.$(@F) $@ || $(RM) -r $(@D)/.tmp.$(@F)
+
+# TODO: The tar rule isn't reproducible, it should be.
+$(topoutdir)/$(dist.pkgname)-$(dist.version).tar: %.tar: %
+ $(TAR) cf $@ -C $(<D) $(<F)
+$(topoutdir)/$(dist.pkgname)-$(dist.version).tar.gz: %.gz: %
+ $(GZIP) $(GZIPFLAGS) < $< > $@
diff --git a/build-aux/Makefile.once.tail/10-sd.mk b/build-aux/Makefile.once.tail/10-sd.mk
index 7df79c0364..596163d7a4 100644
--- a/build-aux/Makefile.once.tail/10-sd.mk
+++ b/build-aux/Makefile.once.tail/10-sd.mk
@@ -20,8 +20,24 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
-include $(topsrcdir)/build-aux/Makefile.head.mk
+
+_sd.autogen_files = aclocal.m4 automake.mk.in config.h.in configure po/Makefile.in.in
+# `$*`/`%` had better be $(topsrcdir), but we can't enforce that
+$(addprefix %/,$(_sd.autogen_files)): %/configure.ac %/autogen.sh
+ cd $(topsrcdir) && ./autogen.sh
+
+config_files = config.mk automake.mk po/Makefile.in # AC_CONFIG_FILES
+config_headers = config.h # AC_CONFIG_HEADERS
+config_commands = libtool po/stamp-it
+$(topoutdir)/config.status: $(topsrcdir)/configure
+ cd $(topoutdir) && ./config.status --recheck
+$(addprefix $(topoutdir)/,$(config_files)): $(topoutdir)/%: $(topoutdir)/config.status $(topsrcdir)/%.in
+ cd $(topoutdir) && ./config.status --file=$*
+$(addprefix $(topoutdir)/,$(config_headers)): $(topoutdir)/%: $(topoutdir)/%.stamp
+$(foreach f,$(config_headers),$(topoutdir)/$f.stamp): $(topoutdir)/%.stamp: $(topoutdir)/config.status $(topsrcdir)/%.in
+ cd $(topoutdir) && ./config.status --header=$*
+ test -f $(topoutdir)/$*
+ touch $@
# Let's run all tests of the test suite, but under valgrind. Let's
# exclude perl/python/shell scripts we have in there
@@ -35,21 +51,21 @@ valgrind-tests: $(TESTS)
x="\n\n"; \
done
-exported-%: %
- $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@
+# exported-%: %
+# $(AM_V_GEN)$(NM) -g --defined-only $(builddir)/.libs/$(<:.la=.so) 2>&1 /dev/null | grep " T " | cut -d" " -f3 > $@
-exported: $(addprefix exported-, $(lib_LTLIBRARIES))
- $(AM_V_GEN)sort -u $^ > $@
+# exported: $(addprefix exported-, $(lib_LTLIBRARIES))
+# $(AM_V_GEN)sort -u $^ > $@
-.PHONY: check-api-docs
-check-api-docs: exported man
- $(AM_V_GEN)for symbol in `cat exported` ; do \
- if test -f $(builddir)/man/$$symbol.html ; then \
- echo " Symbol $$symbol() is documented." ; \
- else \
- echo "‣ Symbol $$symbol() lacks documentation." ; \
- fi ; \
- done
+# .PHONY: check-api-docs
+# check-api-docs: exported man
+# $(AM_V_GEN)for symbol in `cat exported` ; do \
+# if test -f $(builddir)/man/$$symbol.html ; then \
+# echo " Symbol $$symbol() is documented." ; \
+# else \
+# echo "‣ Symbol $$symbol() lacks documentation." ; \
+# fi ; \
+# done
OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES))
ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v)))
@@ -94,5 +110,3 @@ list-keys:
add-key:
gpg --verbose --no-options --no-default-keyring --no-auto-key-locate --batch --trust-model=always --keyring=$(srcdir)/src/import/import-pubring.gpg --import -
-
-include $(topsrcdir)/build-aux/Makefile.tail.mk
diff --git a/build-aux/Makefile.tail.mk b/build-aux/Makefile.tail.mk
new file mode 100644
index 0000000000..2e4adc611b
--- /dev/null
+++ b/build-aux/Makefile.tail.mk
@@ -0,0 +1,40 @@
+# Copyright (C) 2015-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/>.
+
+# This bit gets evaluated for each Makefile processed
+
+include $(call _at.reverse,$(sort $(wildcard $(topsrcdir)/build-aux/Makefile.each.tail/*.mk)))
+
+_at.tmp_targets := $(at.targets)
+_at.tmp_subdirs := $(call at.addprefix,$(outdir),$(at.subdirs))
+
+# Clean the environment
+$(eval \
+ $(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)))
+
+# Recurse
+$(foreach _at.NO_ONCE,y,\
+ $(foreach _at.tmp,$(call at.path,$(addsuffix /$(at.Makefile),$(_at.tmp_subdirs))),\
+ $(if $(filter-out $(_at.MAKEFILE_LIST),$(abspath $(_at.tmp))),\
+ $(eval include $(_at.tmp)))))
+
+# This bit only gets evaluated once, after all of the other Makefiles are read
+ifeq ($(origin _at.NO_ONCE),undefined)
+
+include $(call _at.reverse,$(sort $(wildcard $(topsrcdir)/build-aux/Makefile.once.tail/*.mk)))
+
+endif # _at.NO_ONCE
diff --git a/build-aux/write-atomic b/build-aux/write-atomic
new file mode 100755
index 0000000000..ab2a417c12
--- /dev/null
+++ b/build-aux/write-atomic
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Copyright (C) 2015-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/>.
+
+outfile=$1
+tmpfile="$(dirname "$outfile")/.tmp.${outfile##*/}.tmp"
+
+cat > "$tmpfile" || { r=$?; rm -f "$tmpfile"; exit $r; }
+mv -f "$tmpfile" "$outfile"