summaryrefslogtreecommitdiff
path: root/usr.bin/libtool
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2012-07-12 09:43:35 +0000
committerMarc Espie <espie@cvs.openbsd.org>2012-07-12 09:43:35 +0000
commit0bbb7d268e3f3366bd5d4465abcec2ec381f16a2 (patch)
treea4ac13a7d34b13250e92f9206265693e17593c75 /usr.bin/libtool
parent8dd4a2ef85264beba28733f364af90f544c08284 (diff)
simplify yet a bit more
Diffstat (limited to 'usr.bin/libtool')
-rw-r--r--usr.bin/libtool/LT/LaFile.pm24
-rw-r--r--usr.bin/libtool/LT/Linker.pm17
-rw-r--r--usr.bin/libtool/LT/Parser.pm11
-rw-r--r--usr.bin/libtool/LT/Program.pm18
4 files changed, 34 insertions, 36 deletions
diff --git a/usr.bin/libtool/LT/LaFile.pm b/usr.bin/libtool/LT/LaFile.pm
index 8fd66ffdb2e..4a6562a0727 100644
--- a/usr.bin/libtool/LT/LaFile.pm
+++ b/usr.bin/libtool/LT/LaFile.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: LaFile.pm,v 1.13 2012/07/10 17:05:34 espie Exp $
+# $OpenBSD: LaFile.pm,v 1.14 2012/07/12 09:43:34 espie Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -231,20 +231,10 @@ sub link
if ($odir ne '.') {
$symlinkdir = "$odir/$ltdir";
}
- mkdir $symlinkdir if (! -d $symlinkdir);
-
- tsay {"argvstring (pre resolve_la): @{$parser->{args}}"};
- my $args = $parser->resolve_la($deplibs, $libdirs);
- tsay {"argvstring (post resolve_la): @{$parser->{args}}"};
- my $orderedlibs = [];
- my $staticlibs = [];
- $parser->{args} = $args;
- $args = $parser->parse_linkargs2($gp, $orderedlibs, $staticlibs, $dirs,
- $libs);
- tsay {"staticlibs = \n", join("\n", @$staticlibs)};
- tsay {"orderedlibs = @$orderedlibs"};
- my $finalorderedlibs = reverse_zap_duplicates_ref($orderedlibs);
- tsay {"final orderedlibs = @$finalorderedlibs"};
+ mkdir $symlinkdir if ! -d $symlinkdir;
+
+ my ($staticlibs, $finalorderedlibs, $args) =
+ $linker->common1($parser, $gp, $deplibs, $libdirs, $dirs, $libs);
# static linking
if (!$shared) {
@@ -280,8 +270,8 @@ sub link
push @libflags, @kobjs;
}
}
- push @cmd, @libflags if (@libflags);
- push @cmd, @$objs if (@$objs);
+ push @cmd, @libflags if @libflags;
+ push @cmd, @$objs if @$objs;
LT::Exec->link(@cmd);
LT::Exec->link('ranlib', $dst);
return;
diff --git a/usr.bin/libtool/LT/Linker.pm b/usr.bin/libtool/LT/Linker.pm
index 16ff6748ffb..7637954b9f3 100644
--- a/usr.bin/libtool/LT/Linker.pm
+++ b/usr.bin/libtool/LT/Linker.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Linker.pm,v 1.3 2012/07/10 16:41:00 espie Exp $
+# $OpenBSD: Linker.pm,v 1.4 2012/07/12 09:43:34 espie Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -66,6 +66,21 @@ sub create_symlinks
return $dir;
}
+sub common1
+{
+ my ($self, $parser, $gp, $deplibs, $libdirs, $dirs, $libs) = @_;
+
+ $parser->resolve_la($deplibs, $libdirs);
+ my $orderedlibs = [];
+ my $staticlibs = [];
+ my $args = $parser->parse_linkargs2($gp, $orderedlibs, $staticlibs, $dirs,
+ $libs);
+ tsay {"staticlibs = \n", join("\n", @$staticlibs)};
+ tsay {"orderedlibs = @$orderedlibs"};
+ $orderedlibs = reverse_zap_duplicates_ref($orderedlibs);
+ tsay {"final orderedlibs = @$orderedlibs"};
+ return ($staticlibs, $orderedlibs, $args);
+}
1;
diff --git a/usr.bin/libtool/LT/Parser.pm b/usr.bin/libtool/LT/Parser.pm
index 216afb44e94..82634eaa8a7 100644
--- a/usr.bin/libtool/LT/Parser.pm
+++ b/usr.bin/libtool/LT/Parser.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Parser.pm,v 1.8 2012/07/12 07:35:45 espie Exp $
+# $OpenBSD: Parser.pm,v 1.9 2012/07/12 09:43:34 espie Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -82,6 +82,7 @@ sub resolve_la
{
my ($self, $deplibs, $libdirs) = @_;
+ tsay {"argvstring (pre resolve_la): @{$self->{args}}"};
my $o = { result => [], deplibs => $deplibs, libdirs => $libdirs};
$self->internal_resolve_la($o, $self->{args});
@@ -90,8 +91,8 @@ sub resolve_la
unshift(@{$o->{deplibs}}, '-pthread');
}
- $self->{result} = $o->{result};
- return $o->{result};
+ tsay {"argvstring (post resolve_la): @{$self->{args}}"};
+ $self->{args} = $o->{result};
}
# parse link flags and arguments
@@ -109,6 +110,8 @@ sub resolve_la
sub internal_parse_linkargs1
{
my ($self, $deplibs, $gp, $dirs, $libs, $args, $level) = @_;
+
+ $level //= 0;
tsay {"parse_linkargs1, level: $level"};
tsay {" args: @$args"};
my $result = $self->{result};
@@ -216,7 +219,7 @@ sub parse_linkargs1
my ($self, $deplibs, $gp, $dirs, $libs, $args) = @_;
$self->{result} = [];
$self->internal_parse_linkargs1($deplibs, $gp, $dirs, $libs,
- $self->{args}, 0);
+ $self->{args});
$self->{args} = $self->{result};
}
diff --git a/usr.bin/libtool/LT/Program.pm b/usr.bin/libtool/LT/Program.pm
index a59f68fe509..09fb009acc9 100644
--- a/usr.bin/libtool/LT/Program.pm
+++ b/usr.bin/libtool/LT/Program.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Program.pm,v 1.14 2012/07/11 09:34:05 espie Exp $
+# $OpenBSD: Program.pm,v 1.15 2012/07/12 09:43:34 espie Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -109,19 +109,9 @@ sub link
my @cmd;
my $dst;
- tsay {"argvstring (pre resolve_la): @{$parser->{args}}"};
- my $args = $parser->resolve_la($deplibs, $libdirs);
- tsay {"argvstring (post resolve_la): @{$parser->{args}}"};
- my $orderedlibs = [];
- my $staticlibs = [];
- $parser->{args} = $args;
- $parser->{seen_la_shared} = 0;
- $args = $parser->parse_linkargs2($gp, $orderedlibs, $staticlibs, $dirs,
- $libs);
- tsay {"staticlibs = \n", join("\n", @$staticlibs)};
- tsay {"orderedlibs = @$orderedlibs"};
- my $finalorderedlibs = reverse_zap_duplicates_ref($orderedlibs);
- tsay {"final orderedlibs = @$finalorderedlibs"};
+ my ($staticlibs, $finalorderedlibs, $args) =
+ $linker->common1($parser, $gp, $deplibs, $libdirs, $dirs, $libs);
+ $parser->resolve_la($deplibs, $libdirs);
my $symlinkdir = $ltdir;
if ($odir ne '.') {