diff options
author | Richard Levitte <levitte@openssl.org> | 2019-10-04 00:08:01 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-10-10 14:12:15 +0200 |
commit | e805c2d6d36d6be3db8141abc98f3ce5c6fa9776 (patch) | |
tree | 57f267f341a32b67ca2392be4b9723edbe680a0a /Configurations/unix-Makefile.tmpl | |
parent | bdea50ca802f7645774a359960e3b6ee9c352921 (diff) |
Build files: Make it possible to source libraries into other libraries
Added functionality to use static libraries as source for other
libraries. When done this way, the target library will use the object
files from the sourced static libraries, making the sourced libraries
work as "containers" for object files.
We also need to make sure that the Unix Makefile template knows how to
deal with shared libraries and modules that depend on static libraries.
That's new situation we haven't had before.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10088)
Diffstat (limited to 'Configurations/unix-Makefile.tmpl')
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 81 |
1 files changed, 49 insertions, 32 deletions
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 6de2acc9e7..7c44a04224 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -1015,7 +1015,7 @@ EOF # last in the line. We may therefore need to put back a line ending. sub src2obj { my %args = @_; - my $obj = platform->obj($args{obj}); + my $obj = platform->convertext($args{obj}); my $dep = platform->dep($args{obj}); my @srcs = @{$args{srcs}}; my $srcs = join(" ", @srcs); @@ -1095,15 +1095,22 @@ EOF sub obj2shlib { my %args = @_; my @linkdirs = (); - foreach (@{args{deps}}) { - my $d = dirname($_); - push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; + my @linklibs = (); + foreach (@{$args{deps}}) { + if (platform->isstaticlib($_)) { + push @linklibs, platform->convertext($_); + } else { + my $d = "-L" . dirname($_); + my $l = basename($_); + $l =~ s/^lib//; + $l = "-l" . $l; + push @linklibs, $l; + push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; + } } - my $linkflags = join("", map { "-L$_ " } @linkdirs); - my $linklibs = join("", map { my $f = basename($_); - (my $l = $f) =~ s/^lib//; - " -l$l" } @{$args{deps}}); - my @objs = map { platform->obj($_) } + my $linkflags = join("", map { $_." " } @linkdirs); + my $linklibs = join("", map { $_." " } @linklibs); + my @objs = map { platform->convertext($_) } grep { !platform->isdef($_) } @{$args{objs}}; my @defs = map { platform->def($_) } @@ -1158,15 +1165,23 @@ EOF my %args = @_; my $dso = platform->dso($args{module}); my @linkdirs = (); - foreach (@{args{deps}}) { - my $d = dirname($_); - push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; + my @linklibs = (); + foreach (@{$args{deps}}) { + next unless defined $_; + if (platform->isstaticlib($_)) { + push @linklibs, platform->convertext($_); + } else { + my $d = "-L" . dirname($_); + my $l = basename($_); + $l =~ s/^lib//; + $l = "-l" . $l; + push @linklibs, $l; + push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; + } } - my $linkflags = join("", map { "-L$_ " } @linkdirs); - my $linklibs = join("", map { my $f = basename($_); - (my $l = $f) =~ s/^lib//; - " -l$l" } @{$args{deps}}); - my @objs = map { platform->obj($_) } + my $linkflags = join("", map { $_." " } @linkdirs); + my $linklibs = join("", map { $_." " } @linklibs); + my @objs = map { platform->convertext($_) } grep { !platform->isdef($_) } @{$args{objs}}; my @defs = map { platform->def($_) } @@ -1180,7 +1195,7 @@ EOF $dso: $deps \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\ -o $dso$shared_def $objs \\ - $linklibs \$(DSO_EX_LIBS) + $linklibs\$(DSO_EX_LIBS) EOF } sub obj2lib { @@ -1200,20 +1215,22 @@ EOF my $objs = join(" ", map { platform->obj($_) } @{$args{objs}}); my $deps = join(" ", compute_lib_depends(@{$args{deps}})); my @linkdirs = (); - foreach (@{args{deps}}) { - next if $_ =~ /\.a$/; - my $d = dirname($_); - push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; + my @linklibs = (); + foreach (@{$args{deps}}) { + next unless defined $_; + if (platform->isstaticlib($_)) { + push @linklibs, platform->convertext($_); + } else { + my $d = "-L" . dirname($_); + my $l = basename($_); + $l =~ s/^lib//; + $l = "-l" . $l; + push @linklibs, $l; + push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; + } } - my $linkflags = join("", map { "-L$_ " } @linkdirs); - my $linklibs = join("", map { if ($_ =~ m/\.a$/) { - " ".platform->staticlib($_); - } else { - my $f = basename($_); - (my $l = $f) =~ s/^lib//; - " -l$l" - } - } @{$args{deps}}); + my $linkflags = join("", map { $_." " } @linkdirs); + my $linklibs = join("", map { $_." " } @linklibs); my $cmd = '$(CC)'; my $cmdflags = '$(BIN_CFLAGS)'; if (grep /_cc\.o$/, @{$args{objs}}) { @@ -1225,7 +1242,7 @@ $bin: $objs $deps rm -f $bin \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\ -o $bin $objs \\ - $linklibs \$(BIN_EX_LIBS) + $linklibs\$(BIN_EX_LIBS) EOF } sub in2script { |