+++ /dev/null
-
-&:include subdirmk/cdeps.mk.in
-&:include subdirmk/clean.mk.in
--- /dev/null
+
+&:include subdirmk/cdeps.sd.mk
+&:include subdirmk/clean.sd.mk
INCLUDES += -I&^/lib/
-&:include subdirmk/usual.mk.in
+include subdirmk/usual.mk
include subdirmk/regen.mk
--------------
The developer is expected to write a makefile fragment in each
-relevant subdirectory called `Subdir.mk.in'.
+relevant subdirectory called `Subdir.sd.mk'.
These fragments may contain ordinary make language.
`the current directory'. There are a variety of convenient
constructions.
-The result is that to a large extent, the Subdir.mk.in has an easy way
+The result is that to a large extent, the Subdir.sd.mk has an easy way
to namespace its "local" make variables, and an easy way to refer to
its "local" filenames.
-The Subdir.mk.in's are filtered, fed through autoconf in the usual way
+The Subdir.sd.mk's are filtered, fed through autoconf in the usual way
(for @..@-substitutions) and included by one autogenerated toplevel
makefile.
which exists purely to capture ordinary make invocations and arrange
for something suitable to happen.
-Where there are dependencies between subdirectories, each Subdir.mk.in
+Where there are dependencies between subdirectories, each Subdir.sd.mk
can simply refer to files in other subdirectories directly.
Invocation, "recursive" per-directory targets
Each subdirectory has its own `all' target. For example a
subdirectory `src' has a target `src/all'. The rules for these are
automatically generated from the settings of the per-directory
-&TARGETS variables. (In src/Subdir.mk.in, this of course refers to a
+&TARGETS variables. (In src/Subdir.sd.mk, this of course refers to a
make variable called src_TARGETS.)
The `all' target in a parent directory is taken to imply the `all'
where at least something mentions them. So for example, if
&TARGETS_zonk is mentioned in src but not lib, `make zonk' in
lib will fail. If you want to make a target exist everywhere,
-mention its name in Perdir.mk.in (see below).
+mention its name in Perdir.sd.mk (see below).
-Perdir.mk.in, inclusion
+Perdir.sd.mk, inclusion
-----------------------
-The file Perdir.mk.in in the toplevel of fthe source is automatically
-processed after each individual directory's Subdir.mk.in, and the
+The file Perdir.sd.mk in the toplevel of fthe source is automatically
+processed after each individual directory's Subdir.sd.mk, and the
&-substituted contents therefore appear once for each subdirectory.
This lets you do per-directory boilerplate. Some useful boilerplate
is already provided in subdirmk, for you to reference like this:
- &:include subdirmk/cdeps.mk.in
- &:include subdirmk/clean.mk.in
+ &:include subdirmk/cdeps.sd.mk
+ &:include subdirmk/clean.sd.mk
+(for example in Perdir.sd.mk).
-Note that you must use &:include, which is an include processed during
-the generation of the per-directory Subdir.mk files. That ensures
-that the contents of these files is replicated, with appropriate
-per-directory substitutions, for each directory.
+Subdirectory templates `.sd.mk' vs plain autoconf templates `.mk.in'
+--------------------------------------------------------------------
+
+There are two kinds of template files.
+
+ Filename .sd.mk .mk.in
+
+ Processed by &-substitution, autoconf only
+ then autoconf
+
+ Need to be mentioned No, but Subdir.sd.mk All not in subdirmk/
+ in configure.ac via SUBDIRMK_SUBDIRS via SUBDIRMK_MAKEFILES
+
+ How to include `&:include foo.sd.mk' `include foo.mk'
+ in all relevant .sd.mk in only one
+ (but not needed for Subdir.sd.mk
+ Subdir and Perdir)
+
+If you `include subdirmk/regen.mk', dependency management and
+automatic regeneration for all of this template substitution, and for
+config.status etc. is done for you.
Global definitions
------------------
# $(srcdir)/subdirmk/generate [--srcdir=SRCDIR] [--] SUBDIR...
#
# generates in each subdirectory from in each subdirectory
-# Subdir.mk.tmp Subdir.mk.in
+# Subdir.mk.tmp Subdir.sd.mk
# Makefile
# and in toplevel and in toplevel
-# main.mk.tmp Perdir.mk.in
+# main.mk.tmp Perdir.sd.mk
use strict;
use POSIX;
die "open $f: $!\n" unless $!==ENOENT && $enoent_ok;
return;
}
+ o "MAKEFILE_TEMPLATES += $f\n";
+
while (<$input>) {
if (s#^\s*$esc\:##) {
$buffering_output='';
$buffering_output=undef;
if (m#^(-?)include\s+(\S+)\s+$#) {
my $subf = "$srcdir/$2";
- o "MAKEFILE_TEMPLATES += $subf\n";
process_input_mk($dir_prefix, $dir_suffix, $dir_name,
$var_prefix, $targets,
$subf, $esclitr, $subf);
$var_prefix, $targets,
"${srcdir}/$f", \$esclit, $enoentok);
};
- $pi->("${dir_prefix}Subdir.mk.in", 0);
- $pi->("Perdir.mk.in", 1);
+ $pi->("${dir_prefix}Subdir.sd.mk", 0);
+ $pi->("Perdir.sd.mk", 1);
}
sub process_subtree ($$);
$(CONFIG_STATUS): $(top_srcdir)/$(CONFIGURE)
./$(CONFIG_STATUS) --recheck
-MAKEFILES += subdirmk/regen.mk
-
-MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.mk.in
+MAKEFILE_TEMPLATES += $(top_srcdir)/Perdir.sd.mk
+MAKEFILE_TEMPLATES += $(addprefix $(top_srcdir)/, $(addsuffix .in, \
+ @_SUBDIRMK_MAKEFILES@ \
+ ))
main.mk $(MAKEFILES): .makefiles.stamp ;
.makefiles.stamp: \
$(top_srcdir)/subdirmk/generate \
$(CONFIG_STATUS) \
- $(MAKEFILE_TEMPLATES) \
- $(foreach m,$(MAKEFILES),$(top_srcdir)/$(m).in)
+ $(MAKEFILE_TEMPLATES)
# This filtering arranges that we can often run config.status to
# generate only particular output files. We look for *inputs* that
# have changed. If the only inputs that have changed are ones that we
# regen.mk.in twice because if $(top_srcdir) is `.', make elides the
# directory part from $?.
./$(CONFIG_STATUS) $(if \
- $(filter-out Subdir.mk.in %/Subdir.mk.in \
- subdirmk/regen.mk.in \
- $(top_srcdir)/subdirmk/regen.mk.in \
+ $(filter-out Subdir.sd.mk %/Subdir.sd.mk \
+ %.mk.in \
, $?),, \
- $(sort $(patsubst %.mk.in,%.mk,$(filter %.mk.in,$?))))
+ $(sort \
+ $(patsubst %.sd.mk,%.mk,$(filter %.sd.mk,$?)) \
+ $(patsubst %.mk.in,%.mk,$(filter %.mk.in,$?))))
touch $@
realclean:: clean
+_SUBDIRMK_MAKEFILES=""
+AC_SUBST([_SUBDIRMK_MAKEFILES])
+
AC_DEFUN([SUBDIRMK_SUBDIRS],
-[m4_map_args_w([$1],[_SUBDIRMK_SUBDIR(],[/)])])dnl
+[_SUBDIRMK_INIT
+m4_map_args_w([$1],[_SUBDIRMK_SUBDIR(],[/)])])dnl
AC_DEFUN_ONCE([_SUBDIRMK_INIT],[
AC_CONFIG_FILES([
main.mk:main.mk.tmp
Subdir.mk:Subdir.mk.tmp
- subdirmk/regen.mk
],[],[
- '$srcdir'/subdirmk/generate --srcdir='$srcdir' $subdirsmk_subdirs
+ '$srcdir'/subdirmk/generate --srcdir='$srcdir' $subdirmk_subdirs
])
+ SUBDIRMK_MAKEFILES([subdirmk/regen.mk subdirmk/usual.mk])
])
AC_DEFUN([_SUBDIRMK_SUBDIR],[
- AC_REQUIRE([_SUBDIRMK_INIT])
- subdirsmk_subdirs="$subdirsmk_subdirs '$1'"
+ subdirmk_subdirs="$subdirmk_subdirs '$1'"
AC_CONFIG_FILES([$1Subdir.mk:$1Subdir.mk.tmp])
])
+
+AC_DEFUN([SUBDIRMK_MAKEFILES],
+[_SUBDIRMK_INIT
+m4_map_args_w([$1],[_SUBDIRMK_MAKEFILE(],[)])])dnl
+
+AC_DEFUN([_SUBDIRMK_MAKEFILE],[
+ _SUBDIRMK_MAKEFILES="$_SUBDIRMK_MAKEFILES $1"
+ AC_CONFIG_FILES([$1:$1.in])
+])