X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=Configurations%2Fcommon.tmpl;h=d89817efd2eb9b3a642acd6cbe3bea23312a9b8b;hb=ffc8d605e81c12d4ce06bce758df84f7945c0f02;hp=a750e21a33a8c33ec1718c941e481d4c9d881114;hpb=ddf1847dc81c30e80e7027c928720bf869264bd4;p=openssl.git diff --git a/Configurations/common.tmpl b/Configurations/common.tmpl index a750e21a33..d89817efd2 100644 --- a/Configurations/common.tmpl +++ b/Configurations/common.tmpl @@ -1,6 +1,7 @@ {- # -*- Mode: perl -*- - my $a; + # A cache of objects for which a recipe has already been generated + my %cache; # resolvedepends and reducedepends work in tandem to make sure # there are no duplicate dependencies and that they are in the @@ -31,23 +32,50 @@ @newlist; } + # dogenerate is responsible for producing all the recipes that build + # generated source files. It recurses in case a dependency is also a + # generated source file. + sub dogenerate { + my $src = shift; + return "" if $cache{$src}; + my $obj = shift; + my $bin = shift; + my %opts = @_; + if ($unified_info{generate}->{$src}) { + $OUT .= generatesrc(src => $src, + generator => $unified_info{generate}->{$src}, + deps => $unified_info{depends}->{$src}, + incs => [ @{$unified_info{includes}->{$bin}}, + @{$unified_info{includes}->{$obj}} ], + %opts); + foreach (@{$unified_info{depends}->{$src}}) { + dogenerate($_, $obj, $bin, %opts); + } + } + $cache{$src} = 1; + } + # doobj is responsible for producing all the recipes that build # object files as well as dependency files. sub doobj { my $obj = shift; + return "" if $cache{$obj}; (my $obj_no_o = $obj) =~ s|\.o$||; my $bin = shift; + my %opts = @_; if (@{$unified_info{sources}->{$obj}}) { $OUT .= src2obj(obj => $obj_no_o, srcs => $unified_info{sources}->{$obj}, - deps => [ reducedepends(resolvedepends($obj)) ], + deps => $unified_info{depends}->{$obj}, incs => [ @{$unified_info{includes}->{$bin}}, - @{$unified_info{includes}->{$obj}} ]); - $OUT .= src2dep(obj => $obj_no_o, - srcs => $unified_info{sources}->{$obj}, - incs => [ @{$unified_info{includes}->{$bin}}, - @{$unified_info{includes}->{$obj}} ]); + @{$unified_info{includes}->{$obj}} ], + %opts); + foreach ((@{$unified_info{sources}->{$obj}}, + @{$unified_info{depends}->{$obj}})) { + dogenerate($_, $obj, $bin, %opts); + } } + $cache{$obj} = 1; } # dolib is responsible for building libraries. It will call @@ -56,7 +84,8 @@ # built. sub dolib { my $lib = shift; - if (!$config{no_shared}) { + return "" if $cache{$lib}; + unless ($disabled{shared}) { my %ordinals = $unified_info{ordinals}->{$lib} ? (ordinals => $unified_info{ordinals}->{$lib}) : (); @@ -71,40 +100,50 @@ objs => [ map { (my $x = $_) =~ s|\.o$||; $x } @{$unified_info{sources}->{$lib}} ]); map { doobj($_, $lib, intent => "lib") } @{$unified_info{sources}->{$lib}}; + $cache{$lib} = 1; } # doengine is responsible for building engines. It will call - # obj2dynlib, and also makes sure all object files for the library + # obj2dso, and also makes sure all object files for the library # are built. sub doengine { my $lib = shift; - $OUT .= obj2dynlib(lib => $lib, - objs => [ map { (my $x = $_) =~ s|\.o$||; $x } - @{$unified_info{sources}->{$lib}} ], - deps => [ resolvedepends($lib) ]); - map { doobj($_, $lib, intent => "lib") } @{$unified_info{sources}->{$lib}}; + return "" if $cache{$lib}; + $OUT .= obj2dso(lib => $lib, + objs => [ map { (my $x = $_) =~ s|\.o$||; $x } + @{$unified_info{sources}->{$lib}} ], + deps => [ resolvedepends($lib) ]); + map { doobj($_, $lib, intent => "dso") } @{$unified_info{sources}->{$lib}}; + $cache{$lib} = 1; } # dobin is responsible for building programs. It will call obj2bin, # and also makes sure all object files for the library are built. sub dobin { my $bin = shift; + return "" if $cache{$bin}; my $deps = [ reducedepends(resolvedepends($bin)) ]; $OUT .= obj2bin(bin => $bin, objs => [ map { (my $x = $_) =~ s|\.o$||; $x } @{$unified_info{sources}->{$bin}} ], deps => $deps); map { doobj($_, $bin, intent => "bin") } @{$unified_info{sources}->{$bin}}; + $cache{$bin} = 1; } # dobin is responsible for building scripts from templates. It will # call in2script. sub doscript { my $script = shift; + return "" if $cache{$script}; $OUT .= in2script(script => $script, sources => $unified_info{sources}->{$script}); + $cache{$script} = 1; } + # Start with populating the cache with all the overrides + %cache = map { $_ => 1 } @{$unified_info{overrides}}; + # Build all known libraries, engines, programs and scripts. # Everything else will be handled as a consequence. map { dolib($_) } @{$unified_info{libraries}};