X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=Configurations%2Fcommon.tmpl;h=b7d2a0777e011753cb38e1064914c6f68f791555;hb=b96ab5e6d0125c7e2a6804d568cb2a732cbf4504;hp=d811a2a144651f8c1ef190a171f535f1594ce9f2;hpb=84f3867536625253b48e270cc261f0559b8861a9;p=thirdparty%2Fopenssl.git diff --git a/Configurations/common.tmpl b/Configurations/common.tmpl index d811a2a144..b7d2a0777e 100644 --- a/Configurations/common.tmpl +++ b/Configurations/common.tmpl @@ -9,15 +9,23 @@ # there are no duplicate dependencies and that they are in the # right order. This is especially used to sort the list of # libraries that a build depends on. + sub extensionlesslib { + my @result = map { $_ =~ /(\.a)?$/; $` } @_; + return @result if wantarray; + return $result[0]; + } sub resolvedepends { my $thing = shift; + my $extensionlessthing = extensionlesslib($thing); my @listsofar = @_; # to check if we're looping - my @list = @{$unified_info{depends}->{$thing}}; + my @list = @{$unified_info{depends}->{$thing} // + $unified_info{depends}->{$extensionlessthing}}; my @newlist = (); if (scalar @list) { foreach my $item (@list) { + my $extensionlessitem = extensionlesslib($item); # It's time to break off when the dependency list starts looping - next if grep { $_ eq $item } @listsofar; + next if grep { extensionlesslib($_) eq $extensionlessitem } @listsofar; push @newlist, $item, resolvedepends($item, @listsofar, $item); } } @@ -26,12 +34,22 @@ sub reducedepends { my @list = @_; my @newlist = (); + my %replace = (); while (@list) { my $item = shift @list; - push @newlist, $item - unless grep { $item eq $_ } @list; + my $extensionlessitem = extensionlesslib($item); + if (grep { $extensionlessitem eq extensionlesslib($_) } @list) { + if ($item ne $extensionlessitem) { + # If this instance of the library is explicitly static, we + # prefer that to any shared library name, since it must have + # been done on purpose. + $replace{$extensionlessitem} = $item; + } + } else { + push @newlist, $item; + } } - @newlist; + map { $replace{$_} // $_; } @newlist; } # is_installed checks if a given file will be installed (i.e. they are @@ -60,12 +78,14 @@ if ref $unified_info{generate}->{$src} eq ""; my $script = $unified_info{generate}->{$src}->[0]; $OUT .= generatesrc(src => $src, + product => $bin, generator => $unified_info{generate}->{$src}, generator_incs => $unified_info{includes}->{$script}, generator_deps => $unified_info{depends}->{$script}, deps => $unified_info{depends}->{$src}, - incs => [ @{$unified_info{includes}->{$bin}}, - @{$unified_info{includes}->{$obj}} ], + incs => [ @{$unified_info{includes}->{$obj}}, + @{$unified_info{includes}->{$bin}} ], + defs => $unified_info{defines}->{$obj}, %opts); foreach (@{$unified_info{depends}->{$src}}) { dogenerate($_, $obj, $bin, %opts); @@ -79,16 +99,16 @@ 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, + $OUT .= src2obj(obj => $obj, product => $bin, srcs => $unified_info{sources}->{$obj}, deps => $unified_info{depends}->{$obj}, - incs => [ @{$unified_info{includes}->{$bin}}, - @{$unified_info{includes}->{$obj}} ], + incs => [ @{$unified_info{includes}->{$obj}}, + @{$unified_info{includes}->{$bin}} ], + defs => $unified_info{defines}->{$obj}, %opts); foreach ((@{$unified_info{sources}->{$obj}}, @{$unified_info{depends}->{$obj}})) { @@ -99,33 +119,34 @@ } # dolib is responsible for building libraries. It will call - # libobj2shlib is shared libraries are produced, and obj2lib in all + # obj2shlib is shared libraries are produced, and obj2lib in all # cases. It also makes sure all object files for the library are # built. sub dolib { my $lib = shift; return "" if $cache{$lib}; - unless ($disabled{shared}) { - my %ordinals = - $unified_info{ordinals}->{$lib} - ? (ordinals => $unified_info{ordinals}->{$lib}) : (); - $OUT .= libobj2shlib(shlib => $unified_info{sharednames}->{$lib}, + unless ($disabled{shared} || $lib =~ /\.a$/) { + my $obj2shlib = defined &obj2shlib ? \&obj2shlib : \&libobj2shlib; + $OUT .= $obj2shlib->(shlib => $unified_info{sharednames}->{$lib}, lib => $lib, - objs => [ map { (my $x = $_) =~ s|\.o$||; $x } - (@{$unified_info{sources}->{$lib}}, - @{$unified_info{shared_sources}->{$lib}}) ], + objs => $unified_info{shared_sources}->{$lib}, deps => [ reducedepends(resolvedepends($lib)) ], - installed => is_installed($lib), - %ordinals); - foreach (@{$unified_info{shared_sources}->{$lib}}) { - doobj($_, $lib, intent => "lib", installed => is_installed($lib)); + installed => is_installed($lib)); + foreach ((@{$unified_info{shared_sources}->{$lib}}, + @{$unified_info{sources}->{$lib}})) { + # If this is somehow a compiled object, take care of it that way + # Otherwise, it might simply be generated + if (defined $unified_info{sources}->{$_}) { + doobj($_, $lib, intent => "shlib", installed => is_installed($lib)); + } else { + dogenerate($_, undef, undef, intent => "lib"); + } } } $OUT .= obj2lib(lib => $lib, - objs => [ map { (my $x = $_) =~ s|\.o$||; $x } - @{$unified_info{sources}->{$lib}} ]); + objs => [ @{$unified_info{sources}->{$lib}} ]); foreach (@{$unified_info{sources}->{$lib}}) { - doobj($_, $lib, intent => "lib"); + doobj($_, $lib, intent => "lib", installed => is_installed($lib)); } $cache{$lib} = 1; } @@ -137,14 +158,17 @@ my $lib = shift; return "" if $cache{$lib}; $OUT .= obj2dso(lib => $lib, - objs => [ map { (my $x = $_) =~ s|\.o$||; $x } - (@{$unified_info{sources}->{$lib}}, - @{$unified_info{shared_sources}->{$lib}}) ], + objs => $unified_info{shared_sources}->{$lib}, deps => [ resolvedepends($lib) ], installed => is_installed($lib)); - foreach ((@{$unified_info{sources}->{$lib}}, - @{$unified_info{shared_sources}->{$lib}})) { - doobj($_, $lib, intent => "dso", installed => is_installed($lib)); + foreach (@{$unified_info{shared_sources}->{$lib}}) { + # If this is somehow a compiled object, take care of it that way + # Otherwise, it might simply be generated + if (defined $unified_info{sources}->{$_}) { + doobj($_, $lib, intent => "dso", installed => is_installed($lib)); + } else { + dogenerate($_, undef, $lib, intent => "dso"); + } } $cache{$lib} = 1; } @@ -156,8 +180,7 @@ return "" if $cache{$bin}; my $deps = [ reducedepends(resolvedepends($bin)) ]; $OUT .= obj2bin(bin => $bin, - objs => [ map { (my $x = $_) =~ s|\.o$||; $x } - @{$unified_info{sources}->{$bin}} ], + objs => [ @{$unified_info{sources}->{$bin}} ], deps => $deps, installed => is_installed($bin)); foreach (@{$unified_info{sources}->{$bin}}) { @@ -189,47 +212,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($_); }