summaryrefslogtreecommitdiff
path: root/usr.bin/libtool
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2014-03-31 13:44:05 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2014-03-31 13:44:05 +0000
commit5e1a2e0e917b59b53b3b5c51b69f921015b1f222 (patch)
treec23a952ff006529f29a950a326afa359201ca128 /usr.bin/libtool
parent63e80dc77d848c5f519ab73b15f772fb0ff2be15 (diff)
Match GNU libtool and properly add -rpath to the linker when linking
libraries. Until now we only did that for bin programs, but some libs can also depend on other libs which aren't in the standard search path. passed a full ports bulk (thanks jasper@) ok jasper@ sthen@
Diffstat (limited to 'usr.bin/libtool')
-rw-r--r--usr.bin/libtool/LT/Mode/Link/Library.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/libtool/LT/Mode/Link/Library.pm b/usr.bin/libtool/LT/Mode/Link/Library.pm
index 8a18d059010..9df38bf4cf3 100644
--- a/usr.bin/libtool/LT/Mode/Link/Library.pm
+++ b/usr.bin/libtool/LT/Mode/Link/Library.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Library.pm,v 1.2 2012/11/09 10:55:01 espie Exp $
+# $OpenBSD: Library.pm,v 1.3 2014/03/31 13:44:04 ajacoutot Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -42,6 +42,8 @@ sub link
tsay {"creating link command for library (linked ",
($shared) ? "dynamically" : "statically", ")"};
+ my $RPdirs = $self->{RPdirs};
+
my @libflags;
my @cmd;
my $dst = ($odir eq '.') ? "$ltdir/$fname" : "$odir/$ltdir/$fname";
@@ -138,6 +140,22 @@ sub link
$libcounter++;
}
+ $libdirs = reverse_zap_duplicates_ref($libdirs);
+ # add libdirs to rpath if they are not in standard lib path
+ for my $l (@$libdirs) {
+ if (!LT::OSConfig->is_search_dir($l)) {
+ push @$RPdirs, $l;
+ }
+ }
+ $RPdirs = reverse_zap_duplicates_ref($RPdirs) if $RPdirs;
+
+ my @linkeropts = ();
+ if (!$ltconfig->noshared) {
+ for my $d (@$RPdirs) {
+ push(@linkeropts, '-rpath', $d);
+ }
+ }
+
@cmd = @$ltprog;
push @cmd, $ltconfig->sharedflag, @{$ltconfig->picflags};
push @cmd, '-o', $dst;
@@ -151,6 +169,7 @@ sub link
my @e = $linker->export_symbols($ltconfig,
"$odir/$ltdir/$la", $gp, @$objs, @$staticlibs);
push(@cmd, join(',', "-Wl", @e)) if @e;
+ push @cmd, join(',', "-Wl", @linkeropts) if @linkeropts;
LT::Exec->link(@cmd);
}