--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-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:
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)
|| $(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 = .
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:
# 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 =~ /^-./)
{
$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;
}
################################################################
print "\nReport bugs to <bug-automake\@gnu.org>.\n";
- exit $exit_code;
+ # --help always returns 0 per GNU standards.
+ exit 0;
}
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.
tags: TAGS
TAGS:
+ctags: CTAGS
+CTAGS:
+
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ../..
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)
|| $(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 = ..
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 \
tags: TAGS
TAGS:
+ctags: CTAGS
+CTAGS:
+
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ../..
tags: TAGS
TAGS:
+ctags: CTAGS
+CTAGS:
+
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
-@set UPDATED 9 July 2002
+@set UPDATED 10 July 2002
@set UPDATED-MONTH July 2002
@set EDITION 1.6a
@set VERSION 1.6a
gcj3.test \
gcj4.test \
gcj5.test \
+getopt.test \
gnits.test \
gnits2.test \
header.test \
gcj3.test \
gcj4.test \
gcj5.test \
+getopt.test \
gnits.test \
gnits2.test \
header.test \
tags: TAGS
TAGS:
+ctags: CTAGS
+CTAGS:
+
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
--- /dev/null
+#! /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
+
+:
-@set UPDATED 9 July 2002
+@set UPDATED 10 July 2002
@set UPDATED-MONTH July 2002
@set EDITION 1.6a
@set VERSION 1.6a