- when writing a program wrapper, use the correct path
a/path/to/.libs/foo instead of .libs/a/path/to/foo - make sure the symlinks pointing to the library are also in this path problem spotted by naddy in net/gnet regression tests
This commit is contained in:
parent
de9012a2ed
commit
1e8a0905a2
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
# $OpenBSD: libtool,v 1.10 2010/09/25 17:14:48 steven Exp $
|
||||
# $OpenBSD: libtool,v 1.11 2010/09/28 18:42:17 steven Exp $
|
||||
|
||||
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
|
||||
#
|
||||
@ -670,7 +670,11 @@ sub link
|
||||
# probably just a convenience library
|
||||
$dst = ($odir eq '.') ? "$fname" : "$odir/$fname";
|
||||
}
|
||||
mkdir "$odir/$ltdir" if (! -d "$odir/$ltdir");
|
||||
my $symlinkdir = $ltdir;
|
||||
if ($odir ne '.') {
|
||||
$symlinkdir = "$odir/$ltdir";
|
||||
}
|
||||
mkdir $symlinkdir if (! -d $symlinkdir);
|
||||
|
||||
Trace::debug {"argvstring (pre resolve_la): @{$parser->{args}}\n"};
|
||||
my $args = $parser->resolve_la($deplibs, $libdirs);
|
||||
@ -751,7 +755,7 @@ sub link
|
||||
Trace::debug {"libs:\n", join("\n", (keys %$libs)), "\n"};
|
||||
Trace::debug {"libfiles:\n", join("\n", map { $_->{fullpath}//'UNDEF' } @libobjects), "\n"};
|
||||
|
||||
main::create_symlinks($ltdir, $libs);
|
||||
main::create_symlinks($symlinkdir, $libs);
|
||||
my $prev_was_archive = 0;
|
||||
my $libcounter = 0;
|
||||
foreach my $k (@$finalorderedlibs) {
|
||||
@ -786,7 +790,7 @@ sub link
|
||||
push @cmd, @$objs if (@$objs);
|
||||
push @cmd, '-Wl,-whole-archive', @$staticlibs, '-Wl,-no-whole-archive'
|
||||
if (@$staticlibs);
|
||||
push @cmd, "-L$ltdir", @libflags if (@libflags);
|
||||
push @cmd, "-L$symlinkdir", @libflags if (@libflags);
|
||||
push @cmd, "-Wl,-retain-symbols-file,$symbolsfile" if ($symbolsfile);
|
||||
Exec->command(@cmd);
|
||||
}
|
||||
@ -860,26 +864,28 @@ sub write_wrapper
|
||||
my $program = $self->{outfilepath};
|
||||
my $ltdir = $main::ltdir;
|
||||
my $version = $main::version;
|
||||
my $pfile = basename $program;
|
||||
my $realprogram = $ltdir . '/' . $pfile;
|
||||
open(my $pw, '>', $program) or die "cannot write $program: $!\n";
|
||||
print $pw <<EOF
|
||||
#!/bin/sh
|
||||
|
||||
# $program - wrapper for $ltdir/$program
|
||||
# $program - wrapper for $realprogram
|
||||
# Generated by libtool $version
|
||||
|
||||
argdir=`dirname \$0`
|
||||
if test -f "\$argdir/$ltdir/$program"; then
|
||||
if test -f "\$argdir/$realprogram"; then
|
||||
# Add our own library path to LD_LIBRARY_PATH
|
||||
LD_LIBRARY_PATH=\$argdir/$ltdir
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
# Run the actual program with our arguments.
|
||||
exec "\$argdir/$ltdir/$program" \${1+"\$\@"}
|
||||
exec "\$argdir/$realprogram" \${1+"\$\@"}
|
||||
|
||||
echo "\$0: cannot exec $program \${1+"\$\@"}"
|
||||
exit 1
|
||||
else
|
||||
echo "\$0: error: \\\`\$argdir/$ltdir/$program' does not exist." 1>&2
|
||||
echo "\$0: error: \\\`\$argdir/$realprogram' does not exist." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
EOF
|
||||
@ -937,9 +943,13 @@ sub link
|
||||
my $finalorderedlibs = main::reverse_zap_duplicates_ref($orderedlibs);
|
||||
Trace::debug {"final orderedlibs = @$finalorderedlibs\n"};
|
||||
|
||||
my $symlinkdir = $ltdir;
|
||||
if ($odir ne '.') {
|
||||
$symlinkdir = "$odir/$ltdir";
|
||||
}
|
||||
if ($self->{shared} && $parser->{seen_la_shared}) {
|
||||
$dst = ($odir eq '.') ? "$ltdir/$fname" : "$odir/$ltdir/$fname";
|
||||
mkdir "$odir/$ltdir" if (! -d "$odir/$ltdir");
|
||||
mkdir $symlinkdir if (! -d $symlinkdir);
|
||||
$self->write_wrapper();
|
||||
} else {
|
||||
$dst = ($odir eq '.') ? $fname : "$odir/$fname";
|
||||
@ -979,7 +989,7 @@ sub link
|
||||
Trace::debug {"libs:\n", join("\n", (keys %$libs)), "\n"};
|
||||
Trace::debug {"libfiles:\n", join("\n", map { $_->{fullpath} } @libobjects), "\n"};
|
||||
|
||||
main::create_symlinks($ltdir, $libs);
|
||||
main::create_symlinks($symlinkdir, $libs);
|
||||
foreach my $k (@$finalorderedlibs) {
|
||||
my $a = $libs->{$k}->{fullpath} || die "ERROR: $k not found in \$libs";
|
||||
if ($a =~ m/\.a$/) {
|
||||
@ -1003,7 +1013,7 @@ sub link
|
||||
push @cmd, @$args if ($args);
|
||||
push @cmd, @{$self->{objlist}} if (@{$self->{objlist}});
|
||||
push @cmd, @$staticlibs if (@$staticlibs);
|
||||
push @cmd, "-L$ltdir", @libflags if (@libflags);
|
||||
push @cmd, "-L$symlinkdir", @libflags if (@libflags);
|
||||
push @cmd, @$RPdirs if (@$RPdirs);
|
||||
push @cmd, "-Wl,-retain-symbols-file,$symbolsfile" if ($symbolsfile);
|
||||
Exec->command(@cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user