chiark / gitweb /
Interface: Read Final.sd.mk
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 25 Dec 2019 19:14:57 +0000 (19:14 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 11:35:15 +0000 (11:35 +0000)
Tests will come in a moment, although we already see the new output
file mentioned in main.mk.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README
generate
regen.mk.in
subdirmk.ac
tests/filter/main.mk.expected

diff --git a/README b/README
index 5e78187942da813ac76be9ff07b9c9cada4cd232..7de4def345f95bdfa39f6da34992be894b22e11f 100644 (file)
--- a/README
+++ b/README
@@ -93,8 +93,8 @@ zonk' in lib will fail.  If you want to make a target exist
 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
@@ -112,6 +112,9 @@ autogenerated `main.mk' which merely has some basic settings and
 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
@@ -149,7 +152,7 @@ There are two kinds of template files.
  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
index 5273e1543d2567a79096d3103a619fd3111cee72..66919df2b633452c7767178f517d59b216860053 100755 (executable)
--- a/generate
+++ b/generate
@@ -299,8 +299,22 @@ sub process_subtree ($$) {
     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";
index 06b2fbd08e1ce6fa56b100cbd3422fcf6d34d7df..bdb1b2714d7411bfa45056abd42dab40049acd89 100644 (file)
@@ -55,14 +55,16 @@ main.mk $(SUBDIRMK_MAKEFILES) $(CONFIG_STATUS_OUTPUTS): .makefiles.stamp
 # 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            \
index bacd1cfa64dae69b4c5f9854b5fbea714bfa5795..9498a86e8cd5ebdb2a0409588e4c6171e268b1f3 100644 (file)
@@ -15,6 +15,7 @@ AC_DEFUN_ONCE([_SUBDIRMK_INIT],[
   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
   ])
index 95cae4875f26cdd6188049cd5bb097f768c1f05b..b9357a1e5d243db1557b572d34fc0d73a96568a3 100644 (file)
@@ -6,6 +6,7 @@ MAKEFILE_TEMPLATES :=
 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