From: Ian Jackson Date: Wed, 25 Dec 2019 19:14:57 +0000 (+0000) Subject: Interface: Read Final.sd.mk X-Git-Tag: v0.6.0~249^2~68 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=commitdiff_plain;h=963054a07f6670d984c3e69280bde4832ca837d6 Interface: Read Final.sd.mk Tests will come in a moment, although we already see the new output file mentioned in main.mk. Signed-off-by: Ian Jackson --- diff --git a/README b/README index 5e78187..7de4def 100644 --- 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 diff --git a/generate b/generate index 5273e15..66919df 100755 --- 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"; diff --git a/regen.mk.in b/regen.mk.in index 06b2fbd..bdb1b27 100644 --- a/regen.mk.in +++ b/regen.mk.in @@ -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 \ diff --git a/subdirmk.ac b/subdirmk.ac index bacd1cf..9498a86 100644 --- a/subdirmk.ac +++ b/subdirmk.ac @@ -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 ]) diff --git a/tests/filter/main.mk.expected b/tests/filter/main.mk.expected index 95cae48..b9357a1 100644 --- a/tests/filter/main.mk.expected +++ b/tests/filter/main.mk.expected @@ -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