diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-01-18 18:42:46 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-01-18 18:42:46 +0100 |
commit | 3a7b60b1ca8a2f2b86acf494d649bff66beb445b (patch) | |
tree | 879bf39e27829b1c249aee94a472acdf69be9c8f /aclocal.in | |
parent | c45e3c37a9a0e9df08484ba3a6100af9761a2d97 (diff) | |
parent | 52246cc7355cedbc9cb992095870572beb767ca1 (diff) | |
download | automake-3a7b60b1ca8a2f2b86acf494d649bff66beb445b.tar.gz |
Merge branch 'maint'
* maint:
cmdline parsing: move into a dedicated perl module
Diffstat (limited to 'aclocal.in')
-rw-r--r-- | aclocal.in | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/aclocal.in b/aclocal.in index 93ed5eb71..8cffe7116 100644 --- a/aclocal.in +++ b/aclocal.in @@ -944,6 +944,8 @@ sub parse_arguments () my %cli_options = ( + 'help' => sub { usage(0); }, + 'version' => \&version, 'acdir=s' => \&handle_acdir_option, 'system-acdir=s' => sub { shift; @system_includes = @_; }, 'automake-acdir=s' => sub { shift; @automake_includes = @_; }, @@ -957,55 +959,9 @@ sub parse_arguments () 'verbose' => sub { setup_channel 'verb', silent => 0; }, 'W|warnings=s' => \&parse_warnings, ); - use Getopt::Long; - Getopt::Long::config ("bundling", "pass_through"); - - # See if --version or --help is used. We want to process these before - # anything else because the GNU Coding Standards require us to - # `exit 0' after processing these options, and we can't guarantee this - # if we treat other options first. (Handling other options first - # could produce error diagnostics, and in this condition it is - # confusing if aclocal does `exit 0'.) - my %cli_options_1st_pass = - ( - 'version' => \&version, - 'help' => sub { usage(0); }, - # Recognize all other options (and their arguments) but do nothing. - map { $_ => sub {} } (keys %cli_options) - ); - my @ARGV_backup = @ARGV; - Getopt::Long::GetOptions %cli_options_1st_pass - or exit 1; - @ARGV = @ARGV_backup; - - # Now *really* process the options. This time we know that --help - # and --version are not present, but we specify them nonetheless so - # that ambiguous abbreviation are diagnosed. - Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {} - or exit 1; - - if (@ARGV) - { - my %argopts; - for my $k (keys %cli_options) - { - if ($k =~ /(.*)=s$/) - { - map { $argopts{(length ($_) == 1) - ? "-$_" : "--$_" } = 1; } (split (/\|/, $1)); - } - } - if (exists $argopts{$ARGV[0]}) - { - fatal ("option `$ARGV[0]' requires an argument.\n" - . "Try `$0 --help' for more information"); - } - else - { - fatal ("unrecognized option `$ARGV[0]'\n" - . "Try `$0 --help' for more information"); - } - } + + use Automake::Getopt (); + Automake::Getopt::parse_options %cli_options; if ($print_and_exit) { |