summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/libtool/LT/Getopt.pm41
-rw-r--r--usr.bin/libtool/LT/Mode/Compile.pm17
2 files changed, 51 insertions, 7 deletions
diff --git a/usr.bin/libtool/LT/Getopt.pm b/usr.bin/libtool/LT/Getopt.pm
index 82c5fe0a52f..aba27228741 100644
--- a/usr.bin/libtool/LT/Getopt.pm
+++ b/usr.bin/libtool/LT/Getopt.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Getopt.pm,v 1.7 2012/07/09 17:53:15 espie Exp $
+# $OpenBSD: Getopt.pm,v 1.8 2012/07/09 21:38:38 espie Exp $
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
#
@@ -115,12 +115,38 @@ sub match
return 0;
}
+package Option::Regexp;
+sub new
+{
+ my ($class, $re, $code) = @_;
+ bless {re => $re, code => $code}, $class;
+}
+
+sub setup
+{
+ return shift;
+}
+
+sub match
+{
+ my ($self, $arg, $opts) = @_;
+ if (my @l = ($arg =~ m/^$self->{re}$/)) {
+ &{$self->{code}}(@l);
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
package Options;
sub new
{
my ($class, $string, $code) = @_;
+ if (ref($string) eq 'Regexp') {
+ return Option::Regexp->new($string, $code);
+ }
my @alternates = split(/\|/, $string);
bless {alt => [map { Option->factory($_); } @alternates], code => $code}, $class;
@@ -241,7 +267,8 @@ sub handle_permuted_options
my @options = $self->create_options(@l);
- my @kept = ();
+ $self->{kept} = [];
+
MAINLOOP2:
while (@main::ARGV > 0) {
my $_ = shift @main::ARGV;
@@ -255,9 +282,15 @@ MAINLOOP2:
}
}
}
- push(@kept, $_);
+ $self->keep_for_later($_);
}
- @main::ARGV = @kept;
+ @main::ARGV = @{$self->{kept}};
+}
+
+sub keep_for_later
+{
+ my ($self, @args) = @_;
+ push(@{$self->{kept}}, @args);
}
sub new
diff --git a/usr.bin/libtool/LT/Mode/Compile.pm b/usr.bin/libtool/LT/Mode/Compile.pm
index 9234f06223b..c2c97508c32 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.7 2012/07/09 17:54:27 espie Exp $
+# $OpenBSD: Compile.pm,v 1.8 2012/07/09 21:38:38 espie Exp $
#
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -43,9 +43,20 @@ sub run
my ($class, $ltprog, $gp, $noshared) = @_;
my $lofile = LT::LoFile->new;
- $DB::single = 1;
$gp->handle_permuted_options('o:@',
- 'prefer-pic', 'prefer-non-pic', 'static');
+ qr{\-Wc\,(.*)},
+ sub {
+ $gp->keep_for_later(split(/\,/, shift));
+ },
+ 'Xcompiler',
+ sub {
+ die "-Xcompiler wants an argument" if @main::ARGV == 0;
+ my $arg = shift @main::ARGV;
+ $gp->keep_for_later($arg);
+ },
+ # recognize, don't do shit
+ 'no-suppress',
+ 'prefer-pic', 'prefer-non-pic', 'static', 'shared');
# XXX options ignored: -prefer-pic and -prefer-non-pic
my $pic = 0;
my $nonpic = 1;