From 15c1a2cd0b845dbfcc2c74ba0129e968552d919d Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 17 Jun 2002 12:20:13 +0000 Subject: [PATCH] * automake.in (process_option_list): Recognize std-options. (handle_options): Enable std-options in gnits strictness. (am_install_var): If std-options, enable CK-OPTS section. * lib/am/scripts.am (installcheck-am): New target. * lib/am/progs.am (installcheck-am): New target. * tests/gnits2.test: New file. * tests/Makefile.am (TESTS): Add gnits2.test. * automake.texi (Gnits, Options): Document std-options. --- ChangeLog | 11 +++++++ NEWS | 2 ++ TODO | 4 --- automake.in | 10 ++++-- automake.texi | 11 +++++++ lib/am/progs.am | 18 +++++++++++ lib/am/scripts.am | 27 ++++++++-------- stamp-vti | 2 +- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/gnits2.test | 78 +++++++++++++++++++++++++++++++++++++++++++++++ version.texi | 2 +- 12 files changed, 145 insertions(+), 22 deletions(-) create mode 100755 tests/gnits2.test diff --git a/ChangeLog b/ChangeLog index 2166c6f2..9eb35065 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-06-17 Paolo Bonzini + + * automake.in (process_option_list): Recognize std-options. + (handle_options): Enable std-options in gnits strictness. + (am_install_var): If std-options, enable CK-OPTS section. + * lib/am/scripts.am (installcheck-am): New target. + * lib/am/progs.am (installcheck-am): New target. + * tests/gnits2.test: New file. + * tests/Makefile.am (TESTS): Add gnits2.test. + * automake.texi (Gnits, Options): Document std-options. + 2002-06-17 Kevin Ryde * automake.in (scan_texinfo_file): Add tmp to @clean_suffixes, diff --git a/NEWS b/NEWS index 83d47ffb..fcb3286f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ New in 1.6a: +* A new option, std-options, tests that programs support --help and --version + when `make installcheck' is run. This is enabled by --gnits. * PDF files are generated by Automake * `make distcheck' will enforce DESTDIR support by attempting a DESTDIR install. diff --git a/TODO b/TODO index 4215b42f..56a75efa 100644 --- a/TODO +++ b/TODO @@ -205,8 +205,6 @@ Alex Hornby * should not put texiname_TEXINFOS into distribution should rename this macro anyway, to foo_texi_DEPENDENCIES -* *all* installed scripts should support --version, --help - * For now I guess I'll just have automake give an error if it encounters non-C source in a libtool library specification. @@ -269,7 +267,6 @@ Some long-term projects: fragments to be merged. e.g., `install-local'. consider putting all check-* targets onto @check? -To support --help/--version checking? take diff-n-query code from libit @@ -320,7 +317,6 @@ characters long. * Don't include any symbolic links in the distribution itself. (ditto hard links) * Make sure that all the files in the distribution are world-readable. -** also, check --help output and --version output. Idea from François * standards no longer prohibit ANSI C. What does this imply for the de-ansi-fication feature? [ must keep it -- some users rely on it ] diff --git a/automake.in b/automake.in index beba6a06..3ed14df1 100755 --- a/automake.in +++ b/automake.in @@ -1462,7 +1462,8 @@ sub process_option_list || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex' || $_ eq 'readme-alpha' || $_ eq 'check-news' || $_ eq 'subdir-objects' || $_ eq 'nostdinc' - || $_ eq 'no-exeext' || $_ eq 'no-define') + || $_ eq 'no-exeext' || $_ eq 'no-define' + || $_ eq 'std-options') { # Explicitly recognize these. } @@ -1529,6 +1530,7 @@ sub handle_options if ($strictness == GNITS) { $options{'readme-alpha'} = 1; + $options{'std-options'} = 1; $options{'check-news'} = 1; } @@ -7782,6 +7784,9 @@ sub am_install_var # If so, with install-exec? (or install-data?). my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o); + my $check_options_p = $install_p + && defined $options{'std-options'}; + # Singular form of $PRIMARY. (my $one_primary = $primary) =~ s/S$//; $output_rules .= &file_contents ($file, @@ -7795,7 +7800,8 @@ sub am_install_var 'EXEC' => $exec_p, 'INSTALL' => $install_p, - 'DIST' => $dist_p)); + 'DIST' => $dist_p, + 'CK-OPTS' => $check_options_p)); $first = 0; } diff --git a/automake.texi b/automake.texi index 887bdd4b..3104a8be 100644 --- a/automake.texi +++ b/automake.texi @@ -4204,6 +4204,11 @@ non-alpha releases. The second form is @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a letter; it should be omitted for non-alpha releases. +@item @code{std-options} +@cindex Options, std-options +Make the @code{installcheck} target check that installed scripts and +programs support the @code{--help} and @code{--version} options. + @item @code{subdir-objects} If this option is specified, then objects are placed into the subdirectory of the build directory corresponding to the subdirectory of @@ -4509,6 +4514,12 @@ The @samp{--gnits} option does everything that @samp{--gnu} does, and checks the following as well: @itemize @bullet +@item +@samp{make installcheck} will check to make sure that the @code{--help} +and @code{--version} really print a usage message and a version string, +respectively. This also provides a basic check that the program's +run-time dependencies are satisfied after installation. + @item @samp{make dist} will check to make sure the @file{NEWS} file has been updated to the current version. diff --git a/lib/am/progs.am b/lib/am/progs.am index c1ccfbba..7b0b323a 100644 --- a/lib/am/progs.am +++ b/lib/am/progs.am @@ -94,3 +94,21 @@ clean-%DIR%PROGRAMS: ?LIBTOOL? echo " rm -f $$p $$f"; \ ?LIBTOOL? rm -f $$p $$f ; \ ?LIBTOOL? done + + +## ---------- ## +## Checking. ## +## ---------- ## + +if %?CK-OPTS% +.PHONY installcheck-am: installcheck-%DIR%PROGRAMS +installcheck-%DIR%PROGRAMS: $(%DIR%_PROGRAMS) + bad=0; pid=$$$$; list="$(%DIR%_PROGRAMS)"; for p in $$list; do \ + for opt in --help --version; do \ + if $(DESTDIR)$(%NDIR%dir)/$$p $$opt > c$${pid}_.out 2> c$${pid}_.err \ + && test -n "`cat c$${pid}_.out`" \ + && test -z "`cat c$${pid}_.err`"; then :; \ + else echo "$$p does not support $$opt" 1>&2; bad=1; fi; \ + done; \ + done; rm -f c$${pid}_.???; exit $$bad +endif %?CK-OPTS% diff --git a/lib/am/scripts.am b/lib/am/scripts.am index b50e19d9..0f5cd5d2 100644 --- a/lib/am/scripts.am +++ b/lib/am/scripts.am @@ -81,17 +81,16 @@ endif %?DIST% ## Checking. ## ## ---------- ## -## Uncomment line in handle_scripts when this is uncommented. -## check-%DIR%SCRIPTS: -## pid=$$$$; list="$(%DIR%_SCRIPTS)"; for p in $$list; do \ -## for opt in --help --version; do \ -## if test -f $$p; then :; \ -## elif test -f $(srcdir)/$$p; then \ -## p=$(srcdir)/$$p; \ -## else exit 1; fi; \ -## if $$p $$opt > .chkout$$pid 2> .chkerr$$pid \ -## && test -n "`cat .chkout$$pid`" \ -## && test -z "`cat .chkerr$$pid`"; then :; \ -## else echo "$$p failed $$opt test" 1>&2; exit 1; fi; \ -## done; \ -## done; rm -f .chk???$$pid +if %?CK-OPTS% +.PHONY installcheck-am: installcheck-%DIR%SCRIPTS +installcheck-%DIR%SCRIPTS: $(%DIR%_SCRIPTS) + bad=0; pid=$$$$; list="$(%DIR%_SCRIPTS)"; for p in $$list; do \ + for opt in --help --version; do \ + if $(DESTDIR)$(%NDIR%dir)/$$p $$opt > c$${pid}_.out 2> c$${pid}_.err \ + && test -n "`cat c$${pid}_.out`" \ + && test -z "`cat c$${pid}_.err`"; then :; \ + else echo "$$p does not support $$opt" 1>&2; bad=1; fi; \ + done; \ + done; rm -f c$${pid}_.???; exit $$bad +endif %?CK-OPTS% + diff --git a/stamp-vti b/stamp-vti index 9815744b..f608a27d 100644 --- a/stamp-vti +++ b/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 13 June 2002 +@set UPDATED 17 June 2002 @set UPDATED-MONTH June 2002 @set EDITION 1.6a @set VERSION 1.6a diff --git a/tests/Makefile.am b/tests/Makefile.am index aa8fa3e6..c86a4238 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -170,6 +170,7 @@ gcj2.test \ gcj3.test \ gcj4.test \ gnits.test \ +gnits2.test \ header.test \ implicit.test \ include.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index ed733d05..13332ba5 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -256,6 +256,7 @@ gcj2.test \ gcj3.test \ gcj4.test \ gnits.test \ +gnits2.test \ header.test \ implicit.test \ include.test \ diff --git a/tests/gnits2.test b/tests/gnits2.test new file mode 100755 index 00000000..524f9749 --- /dev/null +++ b/tests/gnits2.test @@ -0,0 +1,78 @@ +#! /bin/sh + +# Test to ensure std-options checking is correct. + +required=gcc +. $srcdir/defs || exit 1 + +cat >> configure.in << 'END' +AC_PROG_CC +AC_OUTPUT +END + +cat > Makefile.am << 'END' +AUTOMAKE_OPTIONS = gnits +noinst_PROGRAMS = fubar2 +bin_PROGRAMS = fubar fine +fubar_SOURCES = fubar.c +fubar2_SOURCES = fubar2.c +fine_SOURCES = fine.c +END + +echo 'main(int argc, char **argv) { exit(0); }' > fubar.c +echo 'main(int argc, char **argv) { exit(0); }' > fubar2.c + +cat > fine.c << 'END' +#include +main(int argc, char **argv) { + puts ("Which version? Which usage?"); + exit(0); +} +END + +cat > check.sed << 'END' +/fubar does not/ { + s/.*/0/ + H +} +/fubar2 does not/ { + s/.*/1/ + H +} +/fine does not/ { + s/.*/1/ + H +} +$!d + +g +/^\n0\n0$/! { + s/.*/1/ + q +} +s/.*/0/ +END + +# Files required by Gnits. +: > INSTALL +: > NEWS +: > README +: > COPYING +: > AUTHORS +: > ChangeLog +: > THANKS + +set -e + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +mkdir sub +cd sub + +../configure --prefix=`pwd`/../inst-dir +$MAKE all +$MAKE install +exit `$MAKE installcheck 2>&1 | sed -f ../check.sed` + diff --git a/version.texi b/version.texi index 9815744b..f608a27d 100644 --- a/version.texi +++ b/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 13 June 2002 +@set UPDATED 17 June 2002 @set UPDATED-MONTH June 2002 @set EDITION 1.6a @set VERSION 1.6a -- 2.43.5