automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Support `missing PROGNAME --version'


From: Alexandre Duret-Lutz
Subject: Re: [PATCH] Support `missing PROGNAME --version'
Date: Tue, 07 Sep 2004 08:24:52 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "Paolo" == Paolo Bonzini <address@hidden> writes:

[...]

 Paolo> I'd rather fix missing since it is easy to do and it may as well help
 Paolo> other programs.  Here is a patch against Automake 1.9.1's script,
 Paolo> which I'd like to import if the patch is accepted upstream.

 Paolo> In addition, this patch checks if flex and bison failed, trying to
 Paolo> pass it --version.  Before this patch, flex/lex and bison/yacc were
 Paolo> grouped together, and since lex/yacc do not support --version it was
 Paolo> not tried even for flex/bison.

 Paolo> Alexandre, is it ok for 1.9 branch and HEAD?  (I do not have CVS
 Paolo> access for Automake).

Sorry for the delay, I'm just back from vacation.

I'm installing your patch as follows.  Beware not to use `test a == a'
in shell scripts as `==' is not portable.

2004-09-07  Alexandre Duret-Lutz  <address@hidden>

        * tests/missing3.test: New file (check for Paolo's change below).
        * tests/Makefile.am (TESTS): Add missing3.test.

2004-09-07  Paolo Bonzini  <address@hidden>

        * missing: Handle all command line options together.  Add a
        separate case statement to detect failed runs, and fail
        silently there if --help or --version is passed to the program.

Index: lib/missing
===================================================================
RCS file: /cvs/automake/automake/lib/missing,v
retrieving revision 1.24
diff -u -r1.24 missing
--- lib/missing 6 Sep 2003 21:10:39 -0000       1.24
+++ lib/missing 7 Sep 2004 06:03:44 -0000
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Common stub for a few missing GNU programs while installing.

-scriptversion=2003-09-02.23
+scriptversion=2004-09-07.08

-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
 #   Free Software Foundation, Inc.
 # Originally by Fran,cois Pinard <address@hidden>, 1996.

@@ -60,11 +60,6 @@
     msg="probably too old"
   fi
   ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in

   -h|--h|--he|--hel|--help)
     echo "\
@@ -92,10 +87,12 @@
   yacc         create \`y.tab.[ch]', if possible, from existing .[ch]

 Send bug reports to <address@hidden>."
+    exit 0
     ;;

   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
     echo "missing $scriptversion (GNU Automake)"
+    exit 0
     ;;

   -*)
@@ -104,12 +101,42 @@
     exit 1
     ;;

-  aclocal*)
+esac
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case "$1" in
+  lex|yacc)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
     if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
        # We have it, but it failed.
        exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
     fi
+    ;;
+esac

+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+  aclocal*)
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
@@ -119,11 +146,6 @@
     ;;

   autoconf)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified \`${configure_ac}'.  You might want to install the
@@ -133,11 +155,6 @@
     ;;

   autoheader)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified \`acconfig.h' or \`${configure_ac}'.  You might want
@@ -157,11 +174,6 @@
     ;;

   automake*)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
@@ -173,11 +185,6 @@
     ;;

   autom4te)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
     echo 1>&2 "\
 WARNING: \`$1' is needed, but is $msg.
          You might have modified some files without having the
@@ -254,11 +261,6 @@
     ;;

   help2man)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
         you modified a dependency of a manual page.  You may need the
@@ -279,11 +281,6 @@
     ;;

   makeinfo)
-    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
-       # We have makeinfo, but it failed.
-       exit 1
-    fi
-
     echo 1>&2 "\
 WARNING: \`$1' is $msg.  You should only need it if
          you modified a \`.texi' or \`.texinfo' file, or any other file
@@ -301,10 +298,6 @@

   tar)
     shift
-    if test -n "$run"; then
-      echo 1>&2 "ERROR: \`tar' requires --run"
-      exit 1
-    fi

     # We have already tried tar in the generic part.
     # Look for gnutar/gtar before invocation to avoid ugly error
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.567
diff -u -r1.567 Makefile.am
--- tests/Makefile.am   1 Aug 2004 22:16:03 -0000       1.567
+++ tests/Makefile.am   7 Sep 2004 06:03:45 -0000
@@ -332,6 +332,7 @@
 mdate4.test \
 missing.test \
 missing2.test \
+missing3.test \
 mkinst2.test \
 mkinstall.test \
 mmodely.test \
Index: tests/missing3.test
===================================================================
RCS file: tests/missing3.test
diff -N tests/missing3.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/missing3.test 7 Sep 2004 06:03:45 -0000
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2004  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Test missing when running a tool's --version.
+
+. ./defs || exit 1
+
+set -e
+
+# b7cb8259 assumed not to exist.
+
+./missing b7cb8259 --version 2>stderr && exit 1
+grep . stderr && exit 1
+./missing b7cb8259 --grep 2>stderr && exit 1
+grep WARNING stderr
+
+./missing --run b7cb8259 --version && exit 1
+./missing --run b7cb8259 --grep 2>stderr && exit 1
+grep WARNING stderr
+
+# missing itself it known to exist :)
+
+./missing ./missing --version 2>stderr && exit 1
+grep . stderr && exit 1
+./missing ./missing --grep 2>stderr && exit 1
+grep WARNING stderr
+
+./missing --run ./missing --version 2>stderr
+grep . stderr && exit 1
+./missing --run ./missing --grep 2>stderr && exit 1
+grep WARNING stderr && exit 1
+grep Unknown stderr
--
Alexandre Duret-Lutz





reply via email to

[Prev in Thread] Current Thread [Next in Thread]