From: Stefano Lattarini Date: Wed, 18 Jan 2012 17:42:46 +0000 (+0100) Subject: Merge branch 'maint' X-Git-Tag: ng-0.5a~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a7b60b1ca8a2f2b86acf494d649bff66beb445b;p=thirdparty%2Fautomake.git Merge branch 'maint' * maint: cmdline parsing: move into a dedicated perl module --- 3a7b60b1ca8a2f2b86acf494d649bff66beb445b diff --cc automake.in index bf9f0c064,3c70b38e2..df502386c --- a/automake.in +++ b/automake.in @@@ -8324,61 -8490,46 +8324,40 @@@ EO # Parse command line. sub parse_arguments () { - # Start off as gnu. - set_strictness ('gnu'); + my $strict = 'gnu'; + my $cygnus = 0; + my $ignore_deps = 0; + my @warnings = (); - my $cli_where = new Automake::Location; my %cli_options = ( + 'version' => \&version, + 'help' => \&usage, 'libdir=s' => \$libdir, - 'gnu' => sub { set_strictness ('gnu'); }, - 'gnits' => sub { set_strictness ('gnits'); }, - 'cygnus' => sub { set_global_option ('cygnus', $cli_where); }, - 'foreign' => sub { set_strictness ('foreign'); }, - 'include-deps' => sub { unset_global_option ('no-dependencies'); }, - 'i|ignore-deps' => sub { set_global_option ('no-dependencies', - $cli_where); }, + 'gnu' => sub { $strict = 'gnu'; }, + 'gnits' => sub { $strict = 'gnits'; }, + 'foreign' => sub { $strict = 'foreign'; }, + 'cygnus' => \$cygnus, + 'include-deps' => sub { $ignore_deps = 0; }, + 'i|ignore-deps' => sub { $ignore_deps = 1; }, 'no-force' => sub { $force_generation = 0; }, 'f|force-missing' => \$force_missing, - 'o|output-dir=s' => \$output_directory, 'a|add-missing' => \$add_missing, 'c|copy' => \$copy_missing, 'v|verbose' => sub { setup_channel 'verb', silent => 0; }, - 'W|warnings=s' => \&parse_warnings, - # These long options (--Werror and --Wno-error) for backward - # compatibility. Use -Werror and -Wno-error today. - 'Werror' => sub { parse_warnings 'W', 'error'; }, - 'Wno-error' => sub { parse_warnings 'W', 'no-error'; }, + 'W|warnings=s' => \@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 Automake does `exit 0'.) - my %cli_options_1st_pass = - ( - 'version' => \&version, - 'help' => \&usage, - # 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; + use Automake::Getopt (); + Automake::Getopt::parse_options %cli_options; - if (defined $output_directory) - { - msg 'obsolete', "`--output-dir' is deprecated\n"; - } - else + set_strictness ($strict); + my $cli_where = new Automake::Location; + set_global_option ('cygnus', $cli_where) if $cygnus; + set_global_option ('no-dependencies', $cli_where) if $ignore_deps; + for my $warning (@warnings) { - # In the next release we'll remove this entirely. - $output_directory = '.'; + &parse_warnings ('-W', $warning); } return unless @ARGV;