]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
* automake.in (parse_arguments): Call Getopt twice: once to catch
authorAlexandre Duret-Lutz <adl@gnu.org>
Wed, 10 Jul 2002 20:30:24 +0000 (20:30 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Wed, 10 Jul 2002 20:30:24 +0000 (20:30 +0000)
--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.

12 files changed:
ChangeLog
Makefile.in
automake.in
lib/Automake/Makefile.in
lib/Makefile.in
lib/am/Makefile.in
m4/Makefile.in
stamp-vti
tests/Makefile.am
tests/Makefile.in
tests/getopt.test [new file with mode: 0755]
version.texi

index 81663d34375f8e59141f8ab73a0fb56722eccb62..6d705600e4b86617c92c4c16be48311de532f7cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2002-07-10  Alexandre Duret-Lutz  <duret_g@epita.fr>
+
+       * 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  <tromey@redhat.com>
 
        For PR automake/286:
index 85ee96a4ebf9119dd2fe8725e3a2af2c02d404dd..463ad0fbf37de59b9e4ca31811bdf363a6c535f6 100644 (file)
@@ -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:
index 753e9a120a832caf5955fe279db9f593bcef62d1..ab10831a02dc9365315eaee716d1561244bc9ae3 100755 (executable)
@@ -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 <bug-automake\@gnu.org>.\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.
index f5c00fa5d4ab663a0ae78a3ff8458e6cc7813185..8781e3525423b9a3fa39438c721f37e14518784f 100644 (file)
@@ -126,6 +126,9 @@ uninstall-dist_perllibDATA:
 tags: TAGS
 TAGS:
 
+ctags: CTAGS
+CTAGS:
+
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
 top_distdir = ../..
index f5f425ddb719d0a935d81e92ac54db201f646f93..5e17ebbb0b5ebdb63dcfbbee88dd057cc2bae1e1 100644 (file)
@@ -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 \
index 4c4db285013da073a8e3ae7220fd8eb3882c9a02..48cbafb436b2b6324d5e1d6af8f90eb5d9ef63c2 100644 (file)
@@ -134,6 +134,9 @@ uninstall-dist_amDATA:
 tags: TAGS
 TAGS:
 
+ctags: CTAGS
+CTAGS:
+
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
 top_distdir = ../..
index 0fc808ea6499e86ccf1936ce29d15a9899d69fc4..52ad8987a5dd28842bf91d80c1ecb85fee13ac91 100644 (file)
@@ -155,6 +155,9 @@ uninstall-nodist_m4dataDATA:
 tags: TAGS
 TAGS:
 
+ctags: CTAGS
+CTAGS:
+
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
 top_distdir = ..
index d09a9fd830f6d735898a8a422684dfe17d24e216..832b35e66dc64c56840a5fdb24801c8b0564a1cf 100644 (file)
--- 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
index 415f058dc436fc9248eaf59a1320b1b729192057..367c39bf144e02d02b667569f3c315ab800e87b4 100644 (file)
@@ -174,6 +174,7 @@ gcj2.test \
 gcj3.test \
 gcj4.test \
 gcj5.test \
+getopt.test \
 gnits.test \
 gnits2.test \
 header.test \
index f1b97acca73f8f54fff52e53a21d7d0b49088b45..719f6e24960e949e4151830953de334022a8f482 100644 (file)
@@ -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 (executable)
index 0000000..384fe9c
--- /dev/null
@@ -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
+
+:
index d09a9fd830f6d735898a8a422684dfe17d24e216..832b35e66dc64c56840a5fdb24801c8b0564a1cf 100644 (file)
@@ -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