From: Alexandre Duret-Lutz Date: Wed, 10 Jul 2002 20:30:24 +0000 (+0000) Subject: * automake.in (parse_arguments): Call Getopt twice: once to catch X-Git-Tag: Release-1-6b~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a86371edc6f148d45f614bdcb7cd752089d6c95;p=thirdparty%2Fautomake.git * automake.in (parse_arguments): Call Getopt twice: once to catch --help or --verbose, and once to process the other arguments. (usage, verbose): Always exit 0, ignoring $exit_code (which anyway should always be 0 because of the change to parse_arguments). * tests/Makefile.am (TESTS): Add getopt.test. * tests/getopt.test: New file. --- diff --git a/ChangeLog b/ChangeLog index 81663d343..6d705600e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-07-10 Alexandre Duret-Lutz + + * automake.in (parse_arguments): Call Getopt twice: once to catch + --help or --verbose, and once to process the other arguments. + (usage, verbose): Always exit 0, ignoring $exit_code (which anyway + should always be 0 because of the change to parse_arguments). + * tests/Makefile.am (TESTS): Add getopt.test. + * tests/getopt.test: New file. + 2002-07-09 Tom Tromey For PR automake/286: diff --git a/Makefile.in b/Makefile.in index 85ee96a4e..463ad0fbf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -328,10 +328,17 @@ tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done ETAGS = etags ETAGSFLAGS = +CTAGS = ctags +CTAGSFLAGS = + tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) @@ -362,13 +369,28 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = . @@ -595,23 +617,24 @@ uninstall-am: uninstall-binSCRIPTS uninstall-info-am uninstall-info: uninstall-info-recursive -.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ - clean-generic clean-recursive dist dist-all dist-bzip2 \ - dist-gzip dist-info distcheck distclean distclean-generic \ - distclean-recursive distclean-tags distcleancheck distdir dvi \ - dvi-am dvi-recursive info info-am info-recursive install \ - install-am install-binSCRIPTS install-data install-data-am \ - install-data-recursive install-exec install-exec-am \ - install-exec-recursive install-info install-info-am \ - install-info-recursive install-man install-recursive \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am installdirs-recursive maintainer-clean \ - maintainer-clean-aminfo maintainer-clean-generic \ - maintainer-clean-recursive maintainer-clean-vti mostlyclean \ - mostlyclean-aminfo mostlyclean-generic mostlyclean-recursive \ - mostlyclean-vti pdf pdf-am pdf-recursive ps ps-am ps-recursive \ - tags tags-recursive uninstall uninstall-am uninstall-binSCRIPTS \ - uninstall-info-am uninstall-info-recursive uninstall-recursive +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \ + clean-generic clean-recursive ctags ctags-recursive dist \ + dist-all dist-bzip2 dist-gzip dist-info distcheck distclean \ + distclean-generic distclean-recursive distclean-tags \ + distcleancheck distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-binSCRIPTS \ + install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-recursive install-strip installcheck installcheck-am \ + installdirs installdirs-am installdirs-recursive \ + maintainer-clean maintainer-clean-aminfo \ + maintainer-clean-generic maintainer-clean-recursive \ + maintainer-clean-vti mostlyclean mostlyclean-aminfo \ + mostlyclean-generic mostlyclean-recursive mostlyclean-vti pdf \ + pdf-am pdf-recursive ps ps-am ps-recursive tags tags-recursive \ + uninstall uninstall-am uninstall-binSCRIPTS uninstall-info-am \ + uninstall-info-recursive uninstall-recursive install-exec-hook: diff --git a/automake.in b/automake.in index 753e9a120..ab10831a0 100755 --- a/automake.in +++ b/automake.in @@ -1410,47 +1410,68 @@ sub parse_warnings ($$) # Parse command line. sub parse_arguments () { - # Start off as gnu. - &set_strictness ('gnu'); - - use Getopt::Long; - Getopt::Long::config ("bundling", "pass_through"); - Getopt::Long::GetOptions - ( - 'version' => \&version, - 'help' => \&usage, - 'libdir:s' => \$libdir, - 'gnu' => sub { &set_strictness ('gnu'); }, - 'gnits' => sub { &set_strictness ('gnits'); }, - 'cygnus' => \$cygnus_mode, - 'foreign' => sub { &set_strictness ('foreign'); }, - 'include-deps' => sub { $cmdline_use_dependencies = 1; }, - 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; }, - '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'; }, - ) - or exit 1; - - if (defined $output_directory) + # Start off as gnu. + &set_strictness ('gnu'); + + my %options = + ( + 'libdir:s' => \$libdir, + 'gnu' => sub { &set_strictness ('gnu'); }, + 'gnits' => sub { &set_strictness ('gnits'); }, + 'cygnus' => \$cygnus_mode, + 'foreign' => sub { &set_strictness ('foreign'); }, + 'include-deps' => sub { $cmdline_use_dependencies = 1; }, + 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; }, + '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'; }, + ); + + 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 garanty this + # if we treat other options first. (Handling other options first + # could produce error diagnostics, and in this condition it is + # confusing if Automake `exit 0'.) + my %options_1st_pass = + ( + 'version' => \&version, + 'help' => \&usage, + # Recognize all other options (and their arguments) but do nothing. + map { $_ => sub {} } (keys %options) + ); + my @ARGV_backup = @ARGV; + Getopt::Long::GetOptions %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. + Getopt::Long::GetOptions %options + or exit 1; + + if (defined $output_directory) { msg 'obsolete', "`--output-dir' is deprecated\n"; } - else + else { # In the next release we'll remove this entirely. $output_directory = '.'; } - foreach my $arg (@ARGV) + foreach my $arg (@ARGV) { if ($arg =~ /^-./) { @@ -1479,9 +1500,9 @@ sub parse_arguments () $output_files{$input} = join (':', ($local, @rest)); } - # Take global strictness from whatever we currently have set. - $default_strictness = $strictness; - $default_strictness_name = $strictness_name; + # Take global strictness from whatever we currently have set. + $default_strictness = $strictness; + $default_strictness_name = $strictness_name; } ################################################################ @@ -8578,7 +8599,8 @@ Warning categories include: print "\nReport bugs to .\n"; - exit $exit_code; + # --help always returns 0 per GNU standards. + exit 0; } @@ -8595,7 +8617,8 @@ Copyright 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. EOF - exit $exit_code; + # --version always returns 0 per GNU standards. + exit 0; } ### Setup "GNU" style for perl-mode and cperl-mode. diff --git a/lib/Automake/Makefile.in b/lib/Automake/Makefile.in index f5c00fa5d..8781e3525 100644 --- a/lib/Automake/Makefile.in +++ b/lib/Automake/Makefile.in @@ -126,6 +126,9 @@ uninstall-dist_perllibDATA: tags: TAGS TAGS: +ctags: CTAGS +CTAGS: + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. diff --git a/lib/Makefile.in b/lib/Makefile.in index f5f425ddb..5e17ebbb0 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -212,10 +212,17 @@ tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done ETAGS = etags ETAGSFLAGS = +CTAGS = ctags +CTAGSFLAGS = + tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) @@ -246,13 +253,28 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. @@ -372,11 +394,11 @@ uninstall-am: uninstall-dist_pkgvdataDATA uninstall-dist_scriptDATA \ uninstall-info: uninstall-info-recursive -.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ - clean-generic clean-recursive distclean distclean-generic \ - distclean-recursive distclean-tags distdir dvi dvi-am \ - dvi-recursive info info-am info-recursive install install-am \ - install-data install-data-am install-data-recursive \ +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \ + clean-generic clean-recursive ctags ctags-recursive distclean \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am dvi-recursive info info-am info-recursive install \ + install-am install-data install-data-am install-data-recursive \ install-dist_pkgvdataDATA install-dist_scriptDATA install-exec \ install-exec-am install-exec-recursive install-info \ install-info-am install-info-recursive install-man \ diff --git a/lib/am/Makefile.in b/lib/am/Makefile.in index 4c4db2850..48cbafb43 100644 --- a/lib/am/Makefile.in +++ b/lib/am/Makefile.in @@ -134,6 +134,9 @@ uninstall-dist_amDATA: tags: TAGS TAGS: +ctags: CTAGS +CTAGS: + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. diff --git a/m4/Makefile.in b/m4/Makefile.in index 0fc808ea6..52ad8987a 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -155,6 +155,9 @@ uninstall-nodist_m4dataDATA: tags: TAGS TAGS: +ctags: CTAGS +CTAGS: + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. diff --git a/stamp-vti b/stamp-vti index d09a9fd83..832b35e66 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 9 July 2002 +@set UPDATED 10 July 2002 @set UPDATED-MONTH July 2002 @set EDITION 1.6a @set VERSION 1.6a diff --git a/tests/Makefile.am b/tests/Makefile.am index 415f058dc..367c39bf1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -174,6 +174,7 @@ gcj2.test \ gcj3.test \ gcj4.test \ gcj5.test \ +getopt.test \ gnits.test \ gnits2.test \ header.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index f1b97acca..719f6e249 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -261,6 +261,7 @@ gcj2.test \ gcj3.test \ gcj4.test \ gcj5.test \ +getopt.test \ gnits.test \ gnits2.test \ header.test \ @@ -511,6 +512,9 @@ uninstall-info-am: tags: TAGS TAGS: +ctags: CTAGS +CTAGS: + check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; skip=0; \ diff --git a/tests/getopt.test b/tests/getopt.test new file mode 100755 index 000000000..384fe9c3c --- /dev/null +++ b/tests/getopt.test @@ -0,0 +1,31 @@ +#! /bin/sh + +# Automake --help, and --version should have priority over any other option +# so that their `exit 0' is coherent. + +. $srcdir/defs || exit 1 + +set -e + +# This is expected to fail ... +$AUTOMAKE -Wnonexistant 2>stderr && exit 1 +cat stderr +grep ':.*nonexistant' stderr + +# ... but this should not. +$AUTOMAKE -Wnonexistant --help 2>stderr +cat stderr +grep ':.*nonexistant' stderr && exit 1 + + +# Similarly, this should fail ... +$AUTOMAKE --nonexistant 2>stderr && exit 1 +cat stderr +grep ':.*nonexistant' stderr + +# ... but this should not. +$AUTOMAKE --nonexistant --help 2>stderr +cat stderr +grep ':.*nonexistant' stderr && exit 1 + +: diff --git a/version.texi b/version.texi index d09a9fd83..832b35e66 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 9 July 2002 +@set UPDATED 10 July 2002 @set UPDATED-MONTH July 2002 @set EDITION 1.6a @set VERSION 1.6a