diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-07-10 13:32:11 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-07-10 13:32:11 +0000 |
commit | b16f2e96bc757b77b35fff0983b26c50ba37655e (patch) | |
tree | ae5daa44b2c72b67d255e90f2e02b351d39934a4 | |
parent | 7b8b53306400e4a0b44009bf4edafc1cd28b166d (diff) |
bye-bye Getopt::Long
-rw-r--r-- | usr.bin/libtool/LT/LaFile.pm | 14 | ||||
-rw-r--r-- | usr.bin/libtool/LT/Mode/Link.pm | 113 | ||||
-rw-r--r-- | usr.bin/libtool/LT/Program.pm | 16 | ||||
-rwxr-xr-x | usr.bin/libtool/libtool | 14 |
4 files changed, 75 insertions, 82 deletions
diff --git a/usr.bin/libtool/LT/LaFile.pm b/usr.bin/libtool/LT/LaFile.pm index fd208dc2b43..bf29445fd64 100644 --- a/usr.bin/libtool/LT/LaFile.pm +++ b/usr.bin/libtool/LT/LaFile.pm @@ -1,4 +1,4 @@ -# $OpenBSD: LaFile.pm,v 1.9 2012/07/10 12:24:45 espie Exp $ +# $OpenBSD: LaFile.pm,v 1.10 2012/07/10 13:32:10 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -215,7 +215,7 @@ use File::Basename; sub link { my ($class, $self, $ltprog, $ltconfig, $la, $fname, $odir, $shared, - $objs, $dirs, $libs, $deplibs, $libdirs, $parser, $opts) = @_; + $objs, $dirs, $libs, $deplibs, $libdirs, $parser, $gp) = @_; tsay {"creating link command for library (linked ", ($shared) ? "dynamically" : "statically", ")"}; @@ -290,16 +290,16 @@ sub link # dynamic linking my $symbolsfile; - if ($opts->{'export-symbols'}) { - $symbolsfile = $opts->{'export-symbols'}; - } elsif ($opts->{'export-symbols-regex'}) { + if ($gp->export_symbols) { + $symbolsfile = $gp->export_symbols; + } elsif ($gp->export_symbols_regex) { ($symbolsfile = "$odir/$ltdir/$la") =~ s/\.la$/.exp/; - LT::Archive->get_symbollist($symbolsfile, $opts->{'export-symbols-regex'}, $objs); + LT::Archive->get_symbollist($symbolsfile, $gp->export_symbols_regex, $objs); } my $tmp = []; while (my $k = shift @$finalorderedlibs) { my $l = $libs->{$k}; - $l->find($dirs, 1, $opts->{'static'}, $what); + $l->find($dirs, 1, $gp->static, $what); if ($l->{dropped}) { # remove library if dependency on it has been dropped delete $libs->{$k}; diff --git a/usr.bin/libtool/LT/Mode/Link.pm b/usr.bin/libtool/LT/Mode/Link.pm index f93263d9b9c..f2712bd31a0 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.6 2012/07/10 12:24:45 espie Exp $ +# $OpenBSD: Link.pm,v 1.7 2012/07/10 13:32:10 espie Exp $ # # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -42,7 +42,6 @@ Link object files and libraries into a library or a program EOH } -our %opts; my $shared = 0; my $static = 1; my @libsearchdirs; @@ -53,9 +52,7 @@ sub run my $noshared = $ltconfig->noshared; my $cmd; - my @Ropts; # -R options on the command line my @Rresolved; # -R options originating from .la resolution - my @RPopts; # -rpath options my $libdirs = []; # list of libdirs my $libs = {}; # libraries my $dirs = {}; # paths to find libraries @@ -63,45 +60,53 @@ sub run # always look here $dirs->{'/usr/lib'} = 3; - $gp->getoptions('all-static' => \$opts{'all-static'}, - 'avoid-version' => \$opts{'avoid-version'}, - 'dlopen=s{1}' => \$opts{'dlopen'}, - 'dlpreopen=s{1}' => \$opts{'dlpreopen'}, - 'export-dynamic' => \$opts{'export-dynamic'}, - 'export-symbols=s' => \$opts{'export-symbols'}, - 'export-symbols-regex=s'=> \$opts{'export-symbols-regex'}, - 'module' => \$opts{'module'}, - 'no-fast-install' => \$opts{'no-fast-install'}, - 'no-install' => \$opts{'no-install'}, - 'no-undefined' => \$opts{'no-undefined'}, - 'o=s' => \$opts{'o'}, - 'objectlist=s' => \$opts{'objectlist'}, - 'precious-files-regex=s'=> \$opts{'precious-files-regex'}, - 'prefer-pic' => \$opts{'prefer-pic'}, - 'prefer-non-pic' => \$opts{'prefer-non-pic'}, - 'release=s' => \$opts{'release'}, - 'rpath=s' => \@RPopts, - 'R=s' => \@Ropts, - 'shrext=s' => \$opts{'shrext'}, - 'static' => \$opts{'static'}, - 'thread-safe' => \$opts{'thread-safe'}, - 'version-info=s{1}' => \$opts{'version-info'}, - 'version_info=s{1}' => \$opts{'version-info'}, - 'version-number=s{1}' => \$opts{'version-info'}, - ); + $gp->handle_permuted_options( + 'all-static', + 'allow-undefined', # we don't care about THAT one + 'avoid-version', + 'dlopen:', + 'dlpreopen:', + 'export-dynamic', + 'export-symbols:', + 'export-symbols-regex:', + 'module', + 'no-fast-install', + 'no-install', + 'no-undefined', + 'o:@', + 'objectlist:', + 'precious-files-regex:', + 'prefer-pic', + 'prefer-non-pic', + 'release:', + 'rpath:@', + 'R:@', + 'shrext:', + 'static', + 'thread-safe', # XXX and --thread-safe ? + 'version-info:', + 'version-number:'); + # XXX options ignored: dlopen, dlpreopen, no-fast-install, # no-install, no-undefined, precious-files-regex, # shrext, thread-safe, prefer-pic, prefer-non-pic + my @RPopts = $gp->rpath; # -rpath options + my @Ropts = $gp->R; # -R options on the command line + @libsearchdirs = get_search_dirs(); # add the .libs dir as well in case people try to link directly # with the real library instead of the .la library push @libsearchdirs, './.libs'; - my $outfile = $opts{'o'}; - if (!$outfile) { - die "No output file given.\n"; + if (!$gp->o) { + shortdie "No output file given.\n"; } + if ($gp->o > 1) { + shortdie "Multiple output files given.\n"; + } + + my $outfile = ($gp->o)[0]; tsay {"outfile = $outfile"}; my $odir = dirname($outfile); my $ofile = basename($outfile); @@ -118,8 +123,8 @@ sub run my @objs; my @sobjs; - if ($opts{'objectlist'}) { - my $objectlist = $opts{'objectlist'}; + if ($gp->objectlist) { + my $objectlist = $gp->objectlist; open(my $ol, '<', $objectlist) or die "Cannot open $objectlist: $!\n"; my @objlist = <$ol>; for (@objlist) { chomp; } @@ -140,7 +145,7 @@ sub run my $program = LT::Program->new; $program->{outfilepath} = $outfile; # XXX give higher priority to dirs of not installed libs - if ($opts{'export-dynamic'}) { + if ($gp->export_dynamic) { push(@{$parser->{args}}, "-Wl,-E"); } @@ -164,15 +169,15 @@ sub run @$RPdirs = (@Ropts, @RPopts, @Rresolved); $program->{RPdirs} = $RPdirs; - $program->link($ltprog, $ltconfig, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); + $program->link($ltprog, $ltconfig, $dirs, $libs, $deplibs, $libdirs, $parser, $gp); } elsif ($linkmode == LIBRARY) { my $convenience = 0; require LT::LaFile; my $lainfo = LT::LaFile->new; - $shared = 1 if ($opts{'version-info'} || - $opts{'avoid-version'} || - $opts{module}); + $shared = 1 if ($gp->version_info || + $gp->avoid_version || + $gp->module); if (!@RPopts) { $convenience = 1; $noshared = 1; @@ -190,7 +195,7 @@ sub run my $sharedlib = $libname.'.so'; my $sharedlib_symlink; - if ($opts{'static'} || $opts{'all-static'}) { + if ($gp->static || $gp->all_static) { $shared = 0; $static = 1; } @@ -207,8 +212,8 @@ sub run # environment overrides -version-info (my $envlibname = $libname) =~ s/[.+-]/_/g; my ($current, $revision, $age) = (0, 0, 0); - if ($opts{'version-info'}) { - ($current, $revision, $age) = parse_version_info($opts{'version-info'}); + if ($gp->version_info) { + ($current, $revision, $age) = parse_version_info($gp->version_info); $origver = "$current.$revision"; $sover = $origver; } @@ -218,16 +223,16 @@ sub run ($current, $revision) = split /\./, $sover; $age = 0; } - if (defined $opts{release}) { + if ($gp->release) { $sharedlib_symlink = $sharedlib; - $sharedlib = $libname.'-'.$opts{release}.'.so'; + $sharedlib = $libname.'-'.$gp->release.'.so'; } - if ($opts{'avoid-version'} || - (defined $opts{release} && !$opts{'version-info'})) { + if ($gp->avoid_version || + ($gp->release && !$gp->version_info)) { # don't add a version in these cases } else { $sharedlib .= ".$sover"; - if (defined $opts{release}) { + if ($gp->release) { $sharedlib_symlink .= ".$sover"; } } @@ -243,8 +248,8 @@ sub run $lainfo->{'dlname'} = $sharedlib; $lainfo->{'library_names'} = $sharedlib; $lainfo->{'library_names'} .= " $sharedlib_symlink" - if (defined $opts{release}); - $lainfo->link($ltprog, $ltconfig, $ofile, $sharedlib, $odir, 1, \@sobjs, $dirs, $libs, $deplibs, $libdirs, $parser, \%opts); + if $gp->release; + $lainfo->link($ltprog, $ltconfig, $ofile, $sharedlib, $odir, 1, \@sobjs, $dirs, $libs, $deplibs, $libdirs, $parser, $gp); tsay {"sharedlib: $sharedlib"}; $lainfo->{'current'} = $current; $lainfo->{'revision'} = $revision; @@ -252,14 +257,14 @@ sub run } if ($static) { $lainfo->{'old_library'} = $staticlib; - $lainfo->link($ltprog, $ltconfig, $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, $gp); tsay {($convenience ? "convenience" : "static"), " lib: $staticlib"}; } $lainfo->{installed} = 'no'; - $lainfo->{shouldnotlink} = $opts{module} ? 'yes' : 'no'; + $lainfo->{shouldnotlink} = $gp->module ? 'yes' : 'no'; map { $_ = "-R$_" } @Ropts; - unshift @$deplibs, @Ropts if (@Ropts); + unshift @$deplibs, @Ropts if @Ropts; tsay {"deplibs = @$deplibs"}; my $finaldeplibs = reverse_zap_duplicates_ref($deplibs); tsay {"finaldeplibs = @$finaldeplibs"}; @@ -282,7 +287,7 @@ sub run if (defined $pdeplibs) { $lainfo->set('dependency_libs', "@$pdeplibs"); } - if (! $opts{module}) { + if (! $gp->module) { $lainfo->write_shared_libs_log($origver); } } diff --git a/usr.bin/libtool/LT/Program.pm b/usr.bin/libtool/LT/Program.pm index 073b1625937..4540f62d52f 100644 --- a/usr.bin/libtool/LT/Program.pm +++ b/usr.bin/libtool/LT/Program.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Program.pm,v 1.7 2012/07/10 12:24:45 espie Exp $ +# $OpenBSD: Program.pm,v 1.8 2012/07/10 13:32:10 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -94,9 +94,9 @@ use File::Basename; sub link { my ($class, $self, $ltprog, $ltconfig, $dirs, $libs, $deplibs, - $libdirs, $parser, $opts) = @_; + $libdirs, $parser, $gp) = @_; - tsay {"linking program (", ($opts->{'static'}) ? "not " : "", + tsay {"linking program (", ($gp->static ? "not " : ""), "dynamically linking not-installed libtool libraries)"}; my $what = ref($self); @@ -137,11 +137,11 @@ sub link } my $symbolsfile; - if ($opts->{'export-symbols'}) { - $symbolsfile = $opts->{'export-symbols'}; - } elsif ($opts->{'export-symbols-regex'}) { + if ($gp->export_symbols) { + $symbolsfile = $gp->export_symbols; + } elsif ($gp->export_symbols_regex) { ($symbolsfile = "$odir/$ltdir/$fname") =~ s/\.la$/.exp/; - LT::Archive->get_symbollist($symbolsfile, $opts->{'export-symbols-regex'}, $self->{objlist}); + LT::Archive->get_symbollist($symbolsfile, $gp->export_symbols_regex, $self->{objlist}); } $libdirs = reverse_zap_duplicates_ref($libdirs); # add libdirs to rpath if they are not in standard lib path @@ -164,7 +164,7 @@ sub link $libs->{$k} = LT::Library->new($k); } my $l = $libs->{$k}; - $l->find($dirs, 1, $opts->{'static'}, $what); + $l->find($dirs, 1, $gp->static, $what); } my @libobjects = values %$libs; diff --git a/usr.bin/libtool/libtool b/usr.bin/libtool/libtool index 0dd3d003f32..17d0ceae26e 100755 --- a/usr.bin/libtool/libtool +++ b/usr.bin/libtool/libtool @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: libtool,v 1.35 2012/07/10 12:24:45 espie Exp $ +# $OpenBSD: libtool,v 1.36 2012/07/10 13:32:10 espie Exp $ # Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org> # Copyright (c) 2012 Marc Espie <espie@openbsd.org> @@ -262,18 +262,6 @@ sub has_tag return defined $self->{tags}{$tag}; } -sub getoptions -{ - my $o = shift; - require Getopt::Long; - my $p = Getopt::Long::Parser->new; - $p->configure('no_ignore_case', - 'pass_through', - 'no_auto_abbrev', - 'permute'); - $p->getoptions(@_); -} - sub is_abreviated_mode { my ($self, $arg) = @_; |