summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2012-07-09 10:34:53 +0000
committerMarc Espie <espie@cvs.openbsd.org>2012-07-09 10:34:53 +0000
commit88990884fb6d8058429a8e871679a8ee4aecf422 (patch)
treecfa116936a2d2b1a5105ca6527a771f53b3d132a
parent88275368be7ef728a660462267aaddb36b08b5ff (diff)
framework for handling help better
-rw-r--r--usr.bin/libtool/LT/Mode/Compile.pm3
-rw-r--r--usr.bin/libtool/LT/Mode/Install.pm3
-rw-r--r--usr.bin/libtool/LT/Mode/Link.pm4
-rwxr-xr-xusr.bin/libtool/libtool44
4 files changed, 33 insertions, 21 deletions
diff --git a/usr.bin/libtool/LT/Mode/Compile.pm b/usr.bin/libtool/LT/Mode/Compile.pm
index 2d63009819c..e1231fcbcca 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.3 2012/07/08 18:29:08 espie Exp $
+# $OpenBSD: Compile.pm,v 1.4 2012/07/09 10:34:52 espie Exp $
#
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -19,6 +19,7 @@ use strict;
use warnings;
package LT::Mode::Compile;
+our @ISA = qw(LT::Mode);
use File::Basename;
use LT::LoFile;
diff --git a/usr.bin/libtool/LT/Mode/Install.pm b/usr.bin/libtool/LT/Mode/Install.pm
index d6a64fc274f..2e7d1827ef8 100644
--- a/usr.bin/libtool/LT/Mode/Install.pm
+++ b/usr.bin/libtool/LT/Mode/Install.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Install.pm,v 1.3 2012/07/04 12:39:34 espie Exp $
+# $OpenBSD: Install.pm,v 1.4 2012/07/09 10:34:52 espie Exp $
#
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -19,6 +19,7 @@ use strict;
use warnings;
package LT::Mode::Install;
+our @ISA = qw(LT::Mode);
use LT::Util;
use LT::Trace;
diff --git a/usr.bin/libtool/LT/Mode/Link.pm b/usr.bin/libtool/LT/Mode/Link.pm
index 7e60cd390e0..6cd9e8eb163 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.3 2012/07/04 12:39:34 espie Exp $
+# $OpenBSD: Link.pm,v 1.4 2012/07/09 10:34:52 espie Exp $
#
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -20,6 +20,8 @@ use warnings;
use feature qw(say);
package LT::Mode::Link;
+our @ISA = qw(LT::Mode);
+
use LT::Util;
use LT::Parser;
use LT::Trace;
diff --git a/usr.bin/libtool/libtool b/usr.bin/libtool/libtool
index 11ce537550d..a6ad1e196a5 100755
--- a/usr.bin/libtool/libtool
+++ b/usr.bin/libtool/libtool
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $OpenBSD: libtool,v 1.25 2012/07/09 10:17:04 espie Exp $
+# $OpenBSD: libtool,v 1.26 2012/07/09 10:34:52 espie Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -100,18 +100,28 @@ sub factory
}
}
+sub help
+{
+}
+
+sub help_all
+{
+ for my $class (values %$mode_maker) {
+ # XXX autoload *if needed*.
+ eval "require $class; ";
+ $class->help;
+ }
+}
+
package LT::Mode::Empty;
our @ISA = qw(LT::Mode);
sub run
{
exit 0;
}
-package LT::Mode::Compile;
-our @ISA = qw(LT::Mode);
package LT::Mode::Clean;
our @ISA = qw(LT::Mode::Empty);
-
package LT::Mode::Execute;
our @ISA = qw(LT::Mode);
sub run
@@ -125,12 +135,6 @@ sub run
package LT::Mode::Finish;
our @ISA = qw(LT::Mode::Empty);
-package LT::Mode::Install;
-our @ISA = qw(LT::Mode);
-
-package LT::Mode::Link;
-our @ISA = qw(LT::Mode);
-
package LT::Mode::Uninstall;
our @ISA = qw(LT::Mode::Empty);
@@ -229,14 +233,11 @@ sub valid_modes
package main;
-use subs qw(
- help
- );
-
my $ltconfig = LT::OSConfig->new;
my $cwd = getcwd();
my $mode;
my $verbose = 1;
+my $help = 0;
# just to be clear:
# when building a library:
@@ -267,7 +268,8 @@ $gp->handle_options(
exit 0;
},
'-finish' => sub { $mode = LT::Mode::Finish->new('--finish'); },
- '-help|-help-all?|h' => \&help, # does not return
+ '-help|?|h' => sub { $help = 1; },
+ '-help-all' => sub { basic_help(); LT::Mode->help_all; exit 0; },
'-mode=' => sub {
$mode = LT::Mode->factory($_[2], "--mode=$_[2]");
},
@@ -278,11 +280,18 @@ $gp->handle_options(
say "libtool (not (GNU libtool)) $ltconfig->{version}";
exit 0;
},
- '-no-warning|-no-warn' -> sub {},
+ '-no-warning|-no-warn' => sub {},
# -preserve-dup-deps
# dlopen|-dlopen
);
+if ($help) {
+ basic_help();
+ if ($mode) {
+ $mode->help;
+ }
+ exit 0;
+}
if ($verbose) {
LT::Exec->verbose_run;
}
@@ -336,7 +345,7 @@ if (LT::Exec->performed == 0) {
###########################################################################
-sub help
+sub basic_help
{
print <<EOF
Usage: $0 [options]
@@ -351,7 +360,6 @@ Usage: $0 [options]
--version - print version of libtool
EOF
;
- exit 0;
}
sub config