diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-07-10 12:24:46 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-07-10 12:24:46 +0000 |
commit | 9888a79d217db040e9827eff5502198e36ab4691 (patch) | |
tree | 004d53711e24303d99c1f2b51019994f14ca9397 /usr.bin/libtool | |
parent | 9473e3217a1fe156cc8e8ca6485c729ebd0c0b27 (diff) |
clean-up shit, pull some of LT::Util into ltconfig object
make that a somewhat more "real" object...
Diffstat (limited to 'usr.bin/libtool')
-rw-r--r-- | usr.bin/libtool/LT/LaFile.pm | 8 | ||||
-rw-r--r-- | usr.bin/libtool/LT/Mode/Compile.pm | 10 | ||||
-rw-r--r-- | usr.bin/libtool/LT/Mode/Link.pm | 11 | ||||
-rw-r--r-- | usr.bin/libtool/LT/Program.pm | 6 | ||||
-rw-r--r-- | usr.bin/libtool/LT/Util.pm | 7 | ||||
-rwxr-xr-x | usr.bin/libtool/libtool | 91 |
6 files changed, 82 insertions, 51 deletions
diff --git a/usr.bin/libtool/LT/LaFile.pm b/usr.bin/libtool/LT/LaFile.pm index f82d860c277..fd208dc2b43 100644 --- a/usr.bin/libtool/LT/LaFile.pm +++ b/usr.bin/libtool/LT/LaFile.pm @@ -1,4 +1,4 @@ -# $OpenBSD: LaFile.pm,v 1.8 2012/07/08 12:29:21 jasper Exp $ +# $OpenBSD: LaFile.pm,v 1.9 2012/07/10 12:24:45 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -214,8 +214,8 @@ use File::Basename; sub link { - my ($class, $self, $ltprog, $la, $fname, $odir, $shared, $objs, $dirs, - $libs, $deplibs, $libdirs, $parser, $opts) = @_; + my ($class, $self, $ltprog, $ltconfig, $la, $fname, $odir, $shared, + $objs, $dirs, $libs, $deplibs, $libdirs, $parser, $opts) = @_; tsay {"creating link command for library (linked ", ($shared) ? "dynamically" : "statically", ")"}; @@ -343,7 +343,7 @@ sub link } @cmd = @$ltprog; - push @cmd, $sharedflag, @picflags; + push @cmd, $ltconfig->sharedflag, @{$ltconfig->picflags}; push @cmd, '-o', $dst; push @cmd, @$args if $args; push @cmd, @$objs if @$objs; diff --git a/usr.bin/libtool/LT/Mode/Compile.pm b/usr.bin/libtool/LT/Mode/Compile.pm index cf25d91a567..55a0a931743 100644 --- a/usr.bin/libtool/LT/Mode/Compile.pm +++ b/usr.bin/libtool/LT/Mode/Compile.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Compile.pm,v 1.10 2012/07/10 11:41:10 espie Exp $ +# $OpenBSD: Compile.pm,v 1.11 2012/07/10 12:24:45 espie Exp $ # # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -40,10 +40,10 @@ EOH my @valid_src = qw(asm c cc cpp cxx f s); sub run { - my ($class, $ltprog, $gp, $noshared) = @_; + my ($class, $ltprog, $gp, $ltconfig) = @_; my $lofile = LT::LoFile->new; - my $pic = !$noshared; + my $pic = !$ltconfig->noshared; my $nonpic = 1; if ($gp->has_tag('disable-shared')) { $pic = 0; @@ -120,9 +120,9 @@ sub run $lofile->{picobj} = $picobj if $pic; $lofile->{nonpicobj} = $nonpicobj if $nonpic; - $lofile->{picflags} = \@main::picflags; + $lofile->{picflags} = $ltconfig->picflags; if ($pic_mode) { - $lofile->{nonpicflags} = \@main::picflags; + $lofile->{nonpicflags} = $ltconfig->picflags; } else { $lofile->{nonpicflags} = \@pie_flags; } diff --git a/usr.bin/libtool/LT/Mode/Link.pm b/usr.bin/libtool/LT/Mode/Link.pm index dab82c29bf9..f93263d9b9c 100644 --- a/usr.bin/libtool/LT/Mode/Link.pm +++ b/usr.bin/libtool/LT/Mode/Link.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Link.pm,v 1.5 2012/07/09 10:52:26 espie Exp $ +# $OpenBSD: Link.pm,v 1.6 2012/07/10 12:24:45 espie Exp $ # # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -49,8 +49,9 @@ my @libsearchdirs; sub run { - my ($class, $ltprog, $gp, $noshared) = @_; + my ($class, $ltprog, $gp, $ltconfig) = @_; + my $noshared = $ltconfig->noshared; my $cmd; my @Ropts; # -R options on the command line my @Rresolved; # -R options originating from .la resolution @@ -163,7 +164,7 @@ sub run @$RPdirs = (@Ropts, @RPopts, @Rresolved); $program->{RPdirs} = $RPdirs; - $program->link($ltprog, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); + $program->link($ltprog, $ltconfig, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); } elsif ($linkmode == LIBRARY) { my $convenience = 0; require LT::LaFile; @@ -243,7 +244,7 @@ sub run $lainfo->{'library_names'} = $sharedlib; $lainfo->{'library_names'} .= " $sharedlib_symlink" if (defined $opts{release}); - $lainfo->link($ltprog, $ofile, $sharedlib, $odir, 1, \@sobjs, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); + $lainfo->link($ltprog, $ltconfig, $ofile, $sharedlib, $odir, 1, \@sobjs, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); tsay {"sharedlib: $sharedlib"}; $lainfo->{'current'} = $current; $lainfo->{'revision'} = $revision; @@ -251,7 +252,7 @@ sub run } if ($static) { $lainfo->{'old_library'} = $staticlib; - $lainfo->link($ltprog, $ofile, $staticlib, $odir, 0, ($convenience && @sobjs > 0) ? \@sobjs : \@objs, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); + $lainfo->link($ltprog, $ltconfig, $ofile, $staticlib, $odir, 0, ($convenience && @sobjs > 0) ? \@sobjs : \@objs, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); tsay {($convenience ? "convenience" : "static"), " lib: $staticlib"}; } diff --git a/usr.bin/libtool/LT/Program.pm b/usr.bin/libtool/LT/Program.pm index 54ef8e839ed..073b1625937 100644 --- a/usr.bin/libtool/LT/Program.pm +++ b/usr.bin/libtool/LT/Program.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Program.pm,v 1.6 2012/07/08 10:42:25 espie Exp $ +# $OpenBSD: Program.pm,v 1.7 2012/07/10 12:24:45 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -93,8 +93,8 @@ use File::Basename; sub link { - my ($class, $self, $ltprog, $dirs, $libs, $deplibs, $libdirs, $parser, - $opts) = @_; + my ($class, $self, $ltprog, $ltconfig, $dirs, $libs, $deplibs, + $libdirs, $parser, $opts) = @_; tsay {"linking program (", ($opts->{'static'}) ? "not " : "", "dynamically linking not-installed libtool libraries)"}; diff --git a/usr.bin/libtool/LT/Util.pm b/usr.bin/libtool/LT/Util.pm index 1c709c7baa0..e092ac38468 100644 --- a/usr.bin/libtool/LT/Util.pm +++ b/usr.bin/libtool/LT/Util.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Util.pm,v 1.4 2012/07/10 11:39:11 espie Exp $ +# $OpenBSD: Util.pm,v 1.5 2012/07/10 12:24:45 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -20,15 +20,12 @@ use warnings; package LT::Util; require Exporter; our @ISA = qw(Exporter); -our @EXPORT = qw(reverse_zap_duplicates_ref abs_dir $ltdir $version - @picflags $sharedflag shortdie); +our @EXPORT = qw(reverse_zap_duplicates_ref abs_dir $ltdir $version shortdie); use File::Basename; use Cwd; our $ltdir = '.libs'; our $version = '1.5.26'; # pretend to be this version of libtool -our @picflags = ('-fPIC', '-DPIC'); -our $sharedflag = '-shared'; # walk a list from back to front, removing any duplicates # this should make sure a library's dependencies are behind the library itself diff --git a/usr.bin/libtool/libtool b/usr.bin/libtool/libtool index af09f6af22e..0dd3d003f32 100755 --- a/usr.bin/libtool/libtool +++ b/usr.bin/libtool/libtool @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: libtool,v 1.34 2012/07/10 09:51:32 espie Exp $ +# $OpenBSD: libtool,v 1.35 2012/07/10 12:24:45 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -41,29 +41,64 @@ package LT::OSConfig; use Config; use LT::Util; +my @picflags =qw(-fPIC -DPIC); + sub new { - my $class = shift; - # XXX: incomplete - my $self = { - machine_arch => $Config{ARCH}, - ltdir => $ltdir, - version => $version, - objdir => $ltdir, - build_old_libs => 'yes', - pic_flags => join(' ', @picflags), - }; - ($self->{gnu_arch} = $self->{machine_arch}) =~ s/amd64/x86_64/; - - if (grep { $_ eq $self->{machine_arch} } qw(m88k vax)) { - $self->{build_libtool_libs} = 'yes'; - $self->{noshared} = 1; - } else { - $self->{build_libtool_libs} = 'no'; - $self->{noshared} = 0; - } - - bless $self, $class; + my $class = shift; + # XXX: incomplete + my $self = { + machine_arch => $Config{ARCH}, + ltdir => $ltdir, + version => $version, + objdir => $ltdir, + build_old_libs => 'yes', + pic_flags => join(' ', @picflags), + }; + ($self->{gnu_arch} = $self->{machine_arch}) =~ s/amd64/x86_64/; + + if (grep { $_ eq $self->{machine_arch} } qw(m88k vax)) { + $self->{build_libtool_libs} = 'yes'; + $self->{noshared} = 1; + } else { + $self->{build_libtool_libs} = 'no'; + $self->{noshared} = 0; + } + + bless $self, $class; +} + +sub noshared +{ + my $self = shift; + return $self->{noshared}; +} + +sub host +{ + my $self = shift; + if (!defined $self->{osversion}) { + chomp($self->{osversion} = `uname -r`); + } + return "$self->{gnu_arch}-unknown-openbsd$self->{osversion}"; +} + +# XXX +sub picflags +{ + my $self = shift; + return \@picflags; +} + +sub sharedflag +{ + return '-shared'; +} + +sub version +{ + my $self = shift; + return $self->{version}; } sub dump @@ -152,7 +187,7 @@ package LT::Mode::Execute; our @ISA = qw(LT::Mode); sub run { - my ($class, $ltprog, $gp, $noshared) = @_; + my ($class, $ltprog, $gp, $ltconfig) = @_; # XXX check whether this is right LT::Exec->silent_run; LT::Exec->execute(@$ltprog, @main::ARGV); @@ -311,10 +346,8 @@ $gp->handle_options( }, '-dry-run|-dryrun|n' => sub { LT::Exec->dry_run; }, '-features' => sub { - my $v = `uname -r`; - chomp $v; - say "host: $ltconfig->{gnu_arch}-unknown-openbsd$v"; - say "enable shared libraries" unless $ltconfig->{noshared}; + say "host: ", $ltconfig->host; + say "enable shared libraries" unless $ltconfig->noshared; say "enable static libraries"; exit 0; }, @@ -328,7 +361,7 @@ $gp->handle_options( '-verbose|-no-silent|-no-quiet|v' => sub {$verbose = 1;}, '-tag=' => sub { $gp->add_tag($_[2]); }, '-version' => sub { - say "libtool (not (GNU libtool)) $ltconfig->{version}"; + say "libtool (not (GNU libtool)) ", $ltconfig->version; exit 0; }, '-no-warning|-no-warn' => sub {}, @@ -399,7 +432,7 @@ if (!$mode->isa("LT::Mode::Execute")) { # from here, options may be intermixed with arguments -$mode->run($ltprog, $gp, $ltconfig->{noshared}); +$mode->run($ltprog, $gp, $ltconfig); if (LT::Exec->performed == 0) { die "No commands to execute.\n" |