From: Ian Jackson Date: Tue, 24 Dec 2019 00:28:30 +0000 (+0000) Subject: generate: Track output Makefiles properly X-Git-Tag: subdirmk/0.3~114 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?p=subdirmk.git;a=commitdiff_plain;h=e637ec96e688439ca41a25fb09e11a958180ba75;hp=3820bf022300cf56d2d2e87b08c07160b630e6c5;ds=sidebyside generate: Track output Makefiles properly This fixes a bug where the intermediate directory Makefile was not included whe it should be. Signed-off-by: Ian Jackson --- diff --git a/generate b/generate index 14deda4..c17d5f7 100755 --- a/generate +++ b/generate @@ -60,6 +60,7 @@ our $writing_output; our $buffering_output; our %output_files; our %input_files; +our @output_makefiles; sub close_any_output_file() { return unless defined $writing_output; @@ -233,6 +234,7 @@ sub process_subtree ($$) { my $dir_name = join '/', @$path ? @$path : '.'; my $var_prefix = join '', map { "${_}_" } @$path ? @$path : qw(TOP); + push @output_makefiles, "${dir_prefix}Subdir.mk"; write_makefile($dir_prefix, scalar @$path); my %targets = (all => []); @@ -286,9 +288,8 @@ sub process_tree() { } o "SUBDIRMK_MAKEFILES :=\n"; o "MAKEFILE_TEMPLATES :=\n"; - o "SUBDIRMK_MAKEFILES += Subdir.mk\n"; - foreach my $subdir (@subdirs) { - o "SUBDIRMK_MAKEFILES += $subdir/Subdir.mk\n"; + foreach my $mf (@output_makefiles) { + o "SUBDIRMK_MAKEFILES += $mf\n"; } foreach my $input (sort keys %input_files) { o "MAKEFILE_TEMPLATES += $input\n"; diff --git a/tests/filter/main.mk.expected b/tests/filter/main.mk.expected index 90073a2..ba72c96 100644 --- a/tests/filter/main.mk.expected +++ b/tests/filter/main.mk.expected @@ -4,6 +4,7 @@ abs_top_srcdir=@abs_top_srcdir@ SUBDIRMK_MAKEFILES := MAKEFILE_TEMPLATES := SUBDIRMK_MAKEFILES += Subdir.mk +SUBDIRMK_MAKEFILES += sub/Subdir.mk SUBDIRMK_MAKEFILES += sub/dir/Subdir.mk MAKEFILE_TEMPLATES += ./Subdir.sd.mk MAKEFILE_TEMPLATES += ./sub/dir/Subdir.sd.mk