From b6e660754c2e799cffe4906269fcace0e07c73bc Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Sun, 21 Oct 2018 11:11:04 +0200 Subject: [PATCH] Configuration: when building the dirinfo structure, include shared_sources This makes sure that any resulting directory target in the build files also depend on object files meant for shared libraries. As a side effect, we move the production of the dirinfo structure from common.tmpl to Configure, to make it easier to check the result. Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/7452) --- Configurations/common.tmpl | 41 ---------------------------- Configurations/unix-Makefile.tmpl | 6 +++- Configurations/windows-makefile.tmpl | 6 +++- Configure | 36 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 43 deletions(-) diff --git a/Configurations/common.tmpl b/Configurations/common.tmpl index c1c96a2b4e..4a086559c1 100644 --- a/Configurations/common.tmpl +++ b/Configurations/common.tmpl @@ -210,47 +210,6 @@ # Start with populating the cache with all the overrides %cache = map { $_ => 1 } @{$unified_info{overrides}}; - # For convenience collect information regarding directories where - # files are generated, those generated files and the end product - # they end up in where applicable. Then, add build rules for those - # directories - if (exists &generatedir) { - my %loopinfo = ( "dso" => [ @{$unified_info{engines}} ], - "lib" => [ @{$unified_info{libraries}} ], - "bin" => [ @{$unified_info{programs}} ], - "script" => [ @{$unified_info{scripts}} ] ); - foreach my $type (keys %loopinfo) { - foreach my $product (@{$loopinfo{$type}}) { - my %dirs = (); - my $pd = dirname($product); - - # We already have a "test" target, and the current directory - # is just silly to make a target for - $dirs{$pd} = 1 unless $pd eq "test" || $pd eq "."; - - foreach (@{$unified_info{sources}->{$product}}) { - my $d = dirname($_); - - # We don't want to create targets for source directories - # when building out of source - next if ($config{sourcedir} ne $config{builddir} - && $d =~ m|^\Q$config{sourcedir}\E|); - # We already have a "test" target, and the current directory - # is just silly to make a target for - next if $d eq "test" || $d eq "."; - - $dirs{$d} = 1; - push @{$unified_info{dirinfo}->{$d}->{deps}}, $_ - if $d ne $pd; - } - foreach (keys %dirs) { - push @{$unified_info{dirinfo}->{$_}->{products}->{$type}}, - $product; - } - } - } - } - # Build mandatory generated headers foreach (@{$unified_info{depends}->{""}}) { dogenerate($_); } diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 9b563d8971..f81ebb015a 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -1303,6 +1303,10 @@ EOF lib => $libext, bin => $exeext ); + # We already have a 'test' target, and the top directory is just plain + # silly + return if $dir eq "test" || $dir eq "."; + foreach my $type (("dso", "lib", "bin", "script")) { next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); # For lib object files, we could update the library. However, it @@ -1323,7 +1327,7 @@ EOF my $deps = join(" ", @deps); my $actions = join("\n", "", @actions); return <<"EOF"; -$args{dir} $args{dir}/: $deps$actions +$dir $dir/: $deps$actions EOF } "" # Important! This becomes part of the template result. diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index c4987f2407..6344d1862e 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -750,6 +750,10 @@ EOF lib => $libext, bin => $exeext ); + # We already have a 'test' target, and the top directory is just plain + # silly + return if $dir eq "test" || $dir eq "."; + foreach my $type (("dso", "lib", "bin", "script")) { next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); # For lib object files, we could update the library. However, @@ -767,7 +771,7 @@ EOF my $deps = join(" ", @deps); my $actions = join("\n", "", @actions); return <<"EOF"; -$args{dir} $args{dir}\\ : $deps$actions +$dir $dir\\ : $deps$actions EOF } "" # Important! This becomes part of the template result. diff --git a/Configure b/Configure index 46218f79c3..bf0c2d5f97 100755 --- a/Configure +++ b/Configure @@ -2330,6 +2330,42 @@ EOF delete $unified_info{includes}->{$dest}; } } + + # For convenience collect information regarding directories where + # files are generated, those generated files and the end product + # they end up in where applicable. Then, add build rules for those + # directories + my %loopinfo = ( "lib" => [ @{$unified_info{libraries}} ], + "dso" => [ @{$unified_info{engines}} ], + "bin" => [ @{$unified_info{programs}} ], + "script" => [ @{$unified_info{scripts}} ] ); + foreach my $type (keys %loopinfo) { + foreach my $product (@{$loopinfo{$type}}) { + my %dirs = (); + my $pd = dirname($product); + + foreach (@{$unified_info{sources}->{$product}}, + @{$unified_info{shared_sources}->{$product} // []}) { + my $d = dirname($_); + + # We don't want to create targets for source directories + # when building out of source + next if ($config{sourcedir} ne $config{builddir} + && $d =~ m|^\Q$config{sourcedir}\E|); + # We already have a "test" target, and the current directory + # is just silly to make a target for + next if $d eq "test" || $d eq "."; + + $dirs{$d} = 1; + push @{$unified_info{dirinfo}->{$d}->{deps}}, $_ + if $d ne $pd; + } + foreach (keys %dirs) { + push @{$unified_info{dirinfo}->{$_}->{products}->{$type}}, + $product; + } + } + } } # For the schemes that need it, we provide the old *_obj configs