summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/Makefile.each.head/00-am.mk1
-rw-r--r--build-aux/Makefile.each.tail/60-am.mk89
-rw-r--r--build-aux/Makefile.each.tail/60-amcfg.mk45
-rw-r--r--build-aux/Makefile.each.tail/70-sdcompletion.mk23
-rw-r--r--build-aux/Makefile.once.head/00-amcfg.mk58
-rw-r--r--build-aux/Makefile.once.head/20-sd.mk37
-rw-r--r--build-aux/Makefile.once.head/30-am.mk287
7 files changed, 360 insertions, 180 deletions
diff --git a/build-aux/Makefile.each.head/00-am.mk b/build-aux/Makefile.each.head/00-am.mk
index dbd57445da..09a2d3c5ac 100644
--- a/build-aux/Makefile.each.head/00-am.mk
+++ b/build-aux/Makefile.each.head/00-am.mk
@@ -1,4 +1,3 @@
-$(eval $(foreach v,$(foreach p,$(am.primaries),am.sys_$p am.out_$p am.check_$p),$v ?=$(at.nl)))
am.CFLAGS ?=
am.CPPFLAGS ?=
am.subdirs ?=
diff --git a/build-aux/Makefile.each.tail/60-am.mk b/build-aux/Makefile.each.tail/60-am.mk
index 302fccc091..38ebc10ea9 100644
--- a/build-aux/Makefile.each.tail/60-am.mk
+++ b/build-aux/Makefile.each.tail/60-am.mk
@@ -1,83 +1,6 @@
-mod.am.depends += files
-
-rootbin_PROGRAMS ?=
-bin_PROGRAMS ?=
-dist_bin_SCRIPTS ?=
-bashcompletion_DATA ?=
-zshcompletion_DATA ?=
-dist_bashcompletion_DATA := $(sort $(bashcompletion_DATA) $(rootbin_PROGRAMS) $(bin_PROGRAMS) $(dist_bin_SCRIPTS))
-dist_zshcompletion_DATA := $(sort $(zshcompletion_DATA) $(addprefix _,$(rootbin_PROGRAMS) $(bin_PROGRAMS) $(dist_bin_SCRIPTS)))
-
-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)))
-
-$(eval \
- $(foreach p,$(am.primaries) ,$(call _am.per_primary,$p)$(at.nl)))
-$(eval \
- $(foreach f,$(am.out_PROGRAMS) ,$(call _am.per_PROGRAM,$f,$(call am.file2var,$f))$(at.nl))\
- $(foreach f,$(am.out_LTLIBRARIES),$(call _am.per_LTLIBRARY,$f,$(call am.file2var,$f))$(at.nl))\
- $(foreach d,$(am.sys2dirs) ,$(call _am.per_directory,$d)$(at.nl)))
-
-$(DESTDIR)$(includedir)/%.h: $(srcdir)/include/%.h
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-
-$(DESTDIR)$(sysusersdir)/%.conf: $(srcdir)/%.sysusers
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-$(DESTDIR)$(sysusersdir)/%.conf: $(outdir)/%.sysusers
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-
-$(DESTDIR)$(sysctldir)/%.conf: $(srcdir)/%.sysctl
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-$(DESTDIR)$(sysctldir)/%.conf: $(outdir)/%.sysctl
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-
-$(DESTDIR)$(tmpfilesdir)/%.conf: $(srcdir)/%.tmpfiles
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-$(DESTDIR)$(tmpfilesdir)/%.conf: $(outdir)/%.tmpfiles
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-
-$(DESTDIR)$(pamconfdir)/%: $(srcdir)/%.pam
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-$(DESTDIR)$(pamconfdir)/%: $(outdir)/%.pam
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-
-$(DESTDIR)$(bashcompletiondir)/%: $(srcdir)/%.completion.bash
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-$(DESTDIR)$(bashcompletiondir)/%: $(outdir)/%.completion.bash
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-
-$(DESTDIR)$(zshcompletiondir)/_%: $(srcdir)/%.completion.zsh
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-$(DESTDIR)$(zshcompletiondir)/_%: $(outdir)/%.completion.zsh
- @$(NORMAL_INSTALL)
- $(am.INSTALL)
-
-at.subdirs += $(am.subdirs)
-files.sys.all += $(foreach p,$(am.primaries),$(am.sys_$p))
-files.out.all += $(foreach p,$(am.primaries),$(am.out_$p))
-files.out.check += $(foreach p,$(am.primaries),$(am.check_$p))
+$(eval $(value _am.pass0))
+$(eval $(value _am.pass1))
+$(eval $(value _am.pass2))
+$(eval $(value _am.pass3))
+$(eval $(value _am.pass4))
+$(eval $(value _am.pass5))
diff --git a/build-aux/Makefile.each.tail/60-amcfg.mk b/build-aux/Makefile.each.tail/60-amcfg.mk
new file mode 100644
index 0000000000..f86bdf4998
--- /dev/null
+++ b/build-aux/Makefile.each.tail/60-amcfg.mk
@@ -0,0 +1,45 @@
+$(DESTDIR)$(includedir)/%.h: $(srcdir)/include/%.h
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+
+$(DESTDIR)$(sysusersdir)/%.conf: $(srcdir)/%.sysusers
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(sysusersdir)/%.conf: $(outdir)/%.sysusers
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+
+$(DESTDIR)$(sysctldir)/%.conf: $(srcdir)/%.sysctl
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(sysctldir)/%.conf: $(outdir)/%.sysctl
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+
+$(DESTDIR)$(tmpfilesdir)/%.conf: $(srcdir)/%.tmpfiles
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(tmpfilesdir)/%.conf: $(outdir)/%.tmpfiles
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+
+$(DESTDIR)$(pamconfdir)/%: $(srcdir)/%.pam
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(pamconfdir)/%: $(outdir)/%.pam
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+
+$(DESTDIR)$(bashcompletiondir)/%: $(srcdir)/%.completion.bash
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(bashcompletiondir)/%: $(outdir)/%.completion.bash
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+
+$(DESTDIR)$(zshcompletiondir)/_%: $(srcdir)/%.completion.zsh
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
+$(DESTDIR)$(zshcompletiondir)/_%: $(outdir)/%.completion.zsh
+ @$(NORMAL_INSTALL)
+ $(am.INSTALL)
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..22a0d1be62
--- /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 _,$(rootbin_PROGRAMS) $(bin_PROGRAMS) $(dist_bin_SCRIPTS)))
diff --git a/build-aux/Makefile.once.head/00-amcfg.mk b/build-aux/Makefile.once.head/00-amcfg.mk
new file mode 100644
index 0000000000..e2610b4be5
--- /dev/null
+++ b/build-aux/Makefile.once.head/00-amcfg.mk
@@ -0,0 +1,58 @@
+mod.amcfg.description = (systemd) Automake-to-Autothing configuration
+mod.amcfg.depends += am
+define mod.amcfg.doc
+# User varaibles:
+# - `V`
+# - `AM_V_*`
+endef
+mod.amcfg.doc := $(value mod.amcfg.doc)
+
+am.sys2out_DATA = \
+ $(notdir \
+ $(patsubst $(pamconfdir)/%,%.pam,\
+ $(patsubst $(tmpfilesdir)/%.conf,%.tmpfiles,\
+ $(patsubst $(sysusersdir)/%.conf,%.sysusers,\
+ $(patsubst $(sysctldir)/%.conf,%.sysctl,\
+ $(patsubst $(bashcompletiondir)/%,%.completion.bash,\
+ $(patsubst $(zshcompletiondir)/_%,%.completion.zsh,\
+ $1)))))))
+am.sys2out_HEADERS = $(abspath $(addprefix $(srcdir)/include/,$(notdir $1)))
+
+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 3c4d6bfd5c..545071d233 100644
--- a/build-aux/Makefile.once.head/20-sd.mk
+++ b/build-aux/Makefile.once.head/20-sd.mk
@@ -119,48 +119,11 @@ INTLTOOL_V_MERGE_ ?= $(INTLTOOL_V_MERGE_$(AM_DEFAULT_VERBOSITY))
INTLTOOL_V_MERGE_0 ?= @echo " ITMRG " $@;
INTLTOOL_V_MERGE_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) $< $@
-
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 ?=
-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 ?=
-
sd.substitutions = \
'|rootlibexecdir=$(rootlibexecdir)|' \
'|rootbindir=$(rootbindir)|' \
diff --git a/build-aux/Makefile.once.head/30-am.mk b/build-aux/Makefile.once.head/30-am.mk
index 3663e07093..82c01fbc22 100644
--- a/build-aux/Makefile.once.head/30-am.mk
+++ b/build-aux/Makefile.once.head/30-am.mk
@@ -1,70 +1,191 @@
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.sys2out_DATA = \
- $(notdir \
- $(patsubst $(pamconfdir)/%,%.pam,\
- $(patsubst $(tmpfilesdir)/%.conf,%.tmpfiles,\
- $(patsubst $(sysusersdir)/%.conf,%.sysusers,\
- $(patsubst $(sysctldir)/%.conf,%.sysctl,\
- $(patsubst $(bashcompletiondir)/%,%.completion.bash,\
- $(patsubst $(zshcompletiondir)/_%,%.completion.zsh,\
- $1)))))))
-am.sys2out_HEADERS = $(abspath $(addprefix $(srcdir)/include/,$(notdir $1)))
+_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
-am.var_PROGRAMS = $1_SOURCES nodist_$1_SOURCES $1_CFLAGS $1_CPPFLAGS $1_LDFLAGS $1_LDADD
-am.var_LTLIBRARIES = $1_SOURCES nodist_$1_SOURCES $1_CFLAGS $1_CPPFLAGS $1_LDFLAGS $1_LIBADD
+# Used by the per_PROGRAM and per_LTLIBRARY 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
+define _am.pass0
+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: _am.per_primary ==
+# Inputs:
+# - Global variable : `am.INSTALL_$(primary)`
+# - Global variable : `am.sys2out_$(primary)`
+# - Global variable : `$(dirname)dir`
+# Erased inputs:
+# - Directory variable : `$(dirname)_$(primary)` [1] [2]
+# - Directory variable : `dist_$(dirname)_$(primary)` [1] [2]
+# - Directory variable : `nodist_$(dirname)_$(primary)` [1] [2]
+# - Directory variable : `noinst_$(primary)` [2]
+# - Directory variable : `check_$(primary)` [2]
+# Outputs:
+# - Directory variable : `am.sys_$(primary)`
+# - Directory variable : `am.out_$(primary)`
+# - Directory variable : `am.check_$(primary)`
+# - Target variable : `am.INSTALL`
+#
+# [1]: HACK: Each of these is first passed through `$(dir ...)`.
+#
+# [2]: HACK: For `am.out_*` each of these are turned into
+# $(DESTDIR)-relative paths (ie, as if for `am.sys_*`), then turned
+# back into $(outdir)-relative paths with `$(call
+# am.sys2out_$(primary),...)`.
+endef
-# So these are reasonable defaults, to keep my sanity. They get overridden by
-# `libtool`/`AM_V_*`-aware versions in `*-sd.mk`
+# 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) $< $@
+$(eval $(foreach p,$(_am.primaries),am.sys2out_$p ?= $$(notdir $$1)$(at.nl)))
-am.LDFLAGS =
-
-########################################################################
+# Utility functions
+_am.primary2dirs = $(filter $(patsubst %dir,%,$(filter %dir,$(.VARIABLES))),\
+ $(patsubst nodist_%,%,$(patsubst dist_%,%,$(patsubst %_$1,%,$(filter %_$1,$(.VARIABLES))))))
-# this list of primaries is based on the Automake 1.15 manual
-am.primaries ?= PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA HEADERS MANS TEXINFOS
-$(eval $(foreach p,$(am.primaries),am.sys2out_$p ?= $$(notdir $$1)$(at.nl)))
-
-am.primary2dirs = $(filter $(patsubst %dir,%,$(filter %dir,$(.VARIABLES))),\
- $(patsubst nodist_%,%,$(patsubst dist_%,%,$(patsubst %_$1,%,$(filter %_$1,$(.VARIABLES))))))
-am.sys2dirs = $(sort $(patsubst %/,%,$(dir $(foreach p,$(am.primaries),$(am.sys_$p)))))
-
-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) , ))
-
+_am.pass1 = $(eval $(foreach p,$(_am.primaries) ,$(call _am.per_primary,$p)$(at.nl)))
define _am.per_primary
-$(foreach d,$(call am.primary2dirs,$1),$d_$1 ?=$(at.nl)dist_$d_$1 ?=$(at.nl)nodist_$d_$1 ?=$(at.nl))
+# Initialize input variables
+$(foreach d,$(call _am.primary2dirs,$1),\
+ $d_$1 ?=$(at.nl)\
+ dist_$d_$1 ?=$(at.nl)\
+ nodist_$d_$1 ?=$(at.nl))
noinst_$1 ?=
-check_$1 ?=
+check_$1 ?=
-am.sys_$1 := $(foreach d,$(call am.primary2dirs,$1),$$(addprefix $$($ddir)/,$$(notdir $$($d_$1) $$(dist_$d_$1) $$(nodist_$d_$1))))
-am.out_$1 := $$(call am.sys2out_$1,$(foreach d,$(call am.primary2dirs,$1),$$(addprefix $$($ddir)/,$$(notdir $$($d_$1) $$(nodist_$d_$1) ))) $$(noinst_$1))
+# Directory variable outputs
am.check_$1 := $$(check_$1)
-$(foreach d,$(call am.primary2dirs,$1),undefine $d_$1$(at.nl)undefine dist_$d_$1$(at.nl)undefine nodist_$d_$1$(at.nl))
+am.sys_$1 := $(foreach d,$(call _am.primary2dirs,$1),$$(addprefix $$($ddir)/,$$(notdir $$($d_$1) $$(dist_$d_$1) $$(nodist_$d_$1))))
+am.out_$1 := $$(call am.sys2out_$1,$(foreach d,$(call _am.primary2dirs,$1),$$(addprefix $$($ddir)/,$$(notdir $$($d_$1) $$(nodist_$d_$1)))) $$(noinst_$1))
+# ^^^ ^
+# notdir-'|| |
+# addprefix--'| |
+# foreach d---' |
+# am.sys2out------------------'
+
+# Erase appropriate inputs
+$(foreach d,$(call _am.primary2dirs,$1),undefine $d_$1$(at.nl)undefine dist_$d_$1$(at.nl)undefine nodist_$d_$1$(at.nl))
undefine noinst_$1
undefine check_$1
+
+# Target variable outputs
$$(addprefix $$(DESTDIR),$$(am.sys_$1)): private am.INSTALL = $$(am.INSTALL_$1)
endef
-########################################################################
-# TODO: I'm not in love with how _am.per_PROGRAM figures out am.subdirs
+
+define _am.pass2.doc
+# == Pass 2: _am.per_PROGRAM ==
+# 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`.
+endef
+_am.pass2 = $(eval $(foreach f,$(am.out_PROGRAMS) ,$(call _am.per_PROGRAM,$f,$(call _am.file2var,$f))$(at.nl)))
+_am.var_PROGRAMS = $1_SOURCES nodist_$1_SOURCES $1_CFLAGS $1_CPPFLAGS $1_LDFLAGS $1_LDADD
# $1 = filename
# $2 = varname
define _am.per_PROGRAM
-$(foreach var,_am.depends $(call am.var_PROGRAMS,$2),$(var) ?=$(at.nl))
-_am.depends += $$(call at.path,$$(call am.file2.o,$1) $$(call am.file2lib,$1,LDADD))
-am.CPPFLAGS += $$($2_CPPFLAGS) $$(call am.file2cpp,$1,LDADD)
+$(foreach var,_am.depends $(call _am.var_PROGRAMS,$2),$(var) ?=$(at.nl))
+_am.depends += $$(call at.path,$$(call _am.file2.o,$1) $$(call _am.file2lib,$1,LDADD))
+am.CPPFLAGS += $$($2_CPPFLAGS) $$(call _am.file2cpp,$1,LDADD)
am.CFLAGS += $$($2_CFLAGS)
$$(outdir)/$1: private am.LDFLAGS := $$($2_LDFLAGS)
$$(outdir)/$1: $$(_am.depends)
@@ -73,16 +194,37 @@ am.subdirs := $$(sort $$(am.subdirs)\
$$(abspath $$(dir $$(filter-out -l% /%,$$(_am.depends))))))
am.CPPFLAGS := $$(am.CPPFLAGS)
am.CFLAGS := $$(am.CFLAGS)
-$(foreach var,_am.depends $(call am.var_LTLIBRARIES,$2),undefine $(var)$(at.nl))
+$(foreach var,_am.depends $(call _am.var_PROGRAMS,$2),undefine $(var)$(at.nl))
+endef
+
+define _am.pass3.doc
+# == Pass 3: _am.per_LTLIBRARY ==
+# 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`.
endef
-########################################################################
-# TODO: I'm not in love with how _am.per_LTLIBRARY figures out am.subdirs
+_am.pass3 = $(eval $(foreach f,$(am.out_LTLIBRARIES),$(call _am.per_LTLIBRARY,$f,$(call _am.file2var,$f))$(at.nl)))
+_am.var_LTLIBRARIES = $1_SOURCES nodist_$1_SOURCES $1_CFLAGS $1_CPPFLAGS $1_LDFLAGS $1_LIBADD
# $1 = filename
# $2 = varname
define _am.per_LTLIBRARY
-$(foreach var,_am.depends $(call am.var_LTLIBRARIES,$2),$(var) ?=$(at.nl))
-_am.depends += $$(call at.path,$$(call am.file2.lo,$1) $$(call am.file2lib,$1,LIBADD))
-am.CPPFLAGS += $$($2_CPPFLAGS) $$(call am.file2cpp,$1,LIBADD)
+$(foreach var,_am.depends $(call _am.var_LTLIBRARIES,$2),$(var) ?=$(at.nl))
+_am.depends += $$(call at.path,$$(call _am.file2.lo,$1) $$(call _am.file2lib,$1,LIBADD))
+am.CPPFLAGS += $$($2_CPPFLAGS) $$(call _am.file2cpp,$1,LIBADD)
am.CFLAGS += $$($2_CFLAGS)
$$(outdir)/$1: private am.LDFLAGS := $$($2_LDFLAGS)
$$(outdir)/$1: $$(_am.depends)
@@ -91,9 +233,24 @@ am.subdirs := $$(sort $$(am.subdirs)\
$$(abspath $$(dir $$(filter-out -l% /%,$$(_am.depends))))))
am.CPPFLAGS := $$(am.CPPFLAGS)
am.CFLAGS := $$(am.CFLAGS)
-$(foreach var,_am.depends $(call am.var_LTLIBRARIES,$2),undefine $(var)$(at.nl))
+$(foreach var,_am.depends $(call _am.var_LTLIBRARIES,$2),undefine $(var)$(at.nl))
endef
-########################################################################
+
+define _am.pass4.doc
+# == Pass 4: Install rules / _am.per_directory ==
+# Inputs:
+# - Directory variable : `am.sys_$(primary)`
+# Outputs:
+# - Target : `$(DESTDIR)/$($(dirname)dir)/%`
+#
+# Creates simple `install` rules. You will need to define your own rules if
+# `am.sys2out_$(primary)` changed the notdir part of the filename.
+endef
+
+# Utility functions
+_am.sys2dirs = $(sort $(patsubst %/,%,$(dir $(foreach p,$(_am.primaries),$(am.sys_$p)))))
+
+_am.pass3 = $(eval $(foreach d,$(_am.sys2dirs) ,$(call _am.per_directory,$d)$(at.nl)))
define _am.per_directory
$$(DESTDIR)$1/%: $$(outdir)/%
@$$(NORMAL_INSTALL)
@@ -102,12 +259,24 @@ $$(DESTDIR)$1/%: $$(srcdir)/%
@$$(NORMAL_INSTALL)
$$(am.INSTALL)
endef
-########################################################################
-define _am.per_include_directory
-$$(DESTDIR)$1/%: $$(outdir)/include/%
- @$$(NORMAL_INSTALL)
- $$(am.INSTALL)
-$$(DESTDIR)$1/%: $$(srcdir)/include/%
- @$$(NORMAL_INSTALL)
- $$(am.INSTALL)
+
+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
+define _am.pass5
+at.subdirs += $(am.subdirs)
+files.sys.all += $(foreach p,$(_am.primaries),$(am.sys_$p))
+files.out.all += $(foreach p,$(_am.primaries),$(am.out_$p))
+files.out.check += $(foreach p,$(_am.primaries),$(am.check_$p))
endef