everywhere, += it with nothing in Prefix.sd.mk or Suffix.sd.mk (see
below).
-Prefix.sd.mk, Suffix.sd.mk, inclusion
--------------------------------------
+Prefix.sd.mk, Suffix.sd.mk, Final.sd.mk, inclusion
+--------------------------------------------------
The files Prefix.sd.mk and Suffix.sd.mk in the toplevel of the source
are automatically processed before and after each individual
includes. So if you want to get in early and set global variables,
put them near the top of Subdir.sd.mk.
+The file Final.sd.mk in the toplevel directory is processed and
+included after all the other files.
+
subdirmk's filter script itself sets (only) these variables:
top_srcdir
abs_top_srcdir
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
- Prefix, Suffix)
+ Prefix, Suffix, Final)
If you `include subdirmk/regen.mk', dependency management and
automatic regeneration for all of this template substitution, and for
return @targets;
}
+sub process_final ($) {
+ my ($otargets) = @_;
+ set_dir_vars([]);
+ push @output_makefiles, "Final.mk";
+ start_output_file("Final.mk.tmp");
+ my %ntargets;
+ my $esclit='&';
+ process_input_mk(\%ntargets, "${srcdir}/Final.sd.mk", \$esclit, 1);
+ delete $ntargets{$_} foreach @$otargets;
+ my @ntargets = sort keys %ntargets;
+ die "late new targets @ntargets" if @ntargets;
+}
+
sub process_tree() {
- process_subtree($root, [ ]);
+ my @targets = process_subtree($root, [ ]);
+ process_final(\@targets);
start_output_file("main.mk.tmp");
foreach my $v (qw(top_srcdir abs_top_srcdir)) {
o "$v=\@$v@\n";
# 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
-# know affect only one output (Subdir.sd.mk and *.mk.in), we pass
-# config.status the corresponding output file names. Otherwise we
-# pass nothing and config.status does them all. We need to mention
-# Subdir.sd.mk twice because if $(top_srcdir) is `.', make elides the
-# directory part from $?.
+# know affect only one output (Subdir.sd.mk, Final.sd.mk and *.mk.in),
+# we pass config.status the corresponding output file names.
+# Otherwise we pass nothing and config.status does them all. We need
+# to mention Subdir.sd.mk twice because if $(top_srcdir) is `.', make
+# elides the directory part from $?. Similarly but not identically
+# Final.sd.mk.
$(SUBDIRMK_REGEN_NDEBUG): REGEN STAMP WANTS DEPS=$?
./$(CONFIG_STATUS) $(if \
$(filter-out Subdir.sd.mk %/Subdir.sd.mk \
+ Final.sd.mk $(top_srcdir)/Final.sd.mk \
%.mk.in \
, $?),, \
$(patsubst $(top_srcdir)/%,%, $(sort \
AC_CONFIG_FILES([
main.mk:main.mk.tmp
Subdir.mk:Subdir.mk.tmp
+ Final.mk:Final.mk.tmp
],[],[
'$srcdir'/subdirmk/generate --srcdir='$srcdir' $subdirmk_subdirs
])
SUBDIRMK_MAKEFILES += Subdir.mk
SUBDIRMK_MAKEFILES += sub/Subdir.mk
SUBDIRMK_MAKEFILES += sub/dir/Subdir.mk
+SUBDIRMK_MAKEFILES += Final.mk
MAKEFILE_TEMPLATES += ./Prefix.sd.mk
MAKEFILE_TEMPLATES += ./Subdir.sd.mk
MAKEFILE_TEMPLATES += ./Suffix.sd.mk