missing
changeset 374 cde07907e374
parent 285 b3f70e3d7246
child 664 b6b714389ea9
     1.1 --- a/missing	Mon May 27 12:25:10 2013 -0700
     1.2 +++ b/missing	Mon May 27 12:49:03 2013 -0700
     1.3 @@ -1,11 +1,10 @@
     1.4  #! /bin/sh
     1.5 -# Common stub for a few missing GNU programs while installing.
     1.6 +# Common wrapper for a few potentially missing GNU programs.
     1.7  
     1.8 -scriptversion=2006-05-10.23
     1.9 +scriptversion=2012-06-26.16; # UTC
    1.10  
    1.11 -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
    1.12 -#   Free Software Foundation, Inc.
    1.13 -# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
    1.14 +# Copyright (C) 1996-2013 Free Software Foundation, Inc.
    1.15 +# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
    1.16  
    1.17  # This program is free software; you can redistribute it and/or modify
    1.18  # it under the terms of the GNU General Public License as published by
    1.19 @@ -18,9 +17,7 @@
    1.20  # GNU General Public License for more details.
    1.21  
    1.22  # You should have received a copy of the GNU General Public License
    1.23 -# along with this program; if not, write to the Free Software
    1.24 -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    1.25 -# 02110-1301, USA.
    1.26 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.27  
    1.28  # As a special exception to the GNU General Public License, if you
    1.29  # distribute this file as part of a program that contains a
    1.30 @@ -28,66 +25,40 @@
    1.31  # the same distribution terms that you use for the rest of that program.
    1.32  
    1.33  if test $# -eq 0; then
    1.34 -  echo 1>&2 "Try \`$0 --help' for more information"
    1.35 +  echo 1>&2 "Try '$0 --help' for more information"
    1.36    exit 1
    1.37  fi
    1.38  
    1.39 -run=:
    1.40 -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
    1.41 -sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
    1.42 +case $1 in
    1.43  
    1.44 -# In the cases where this matters, `missing' is being run in the
    1.45 -# srcdir already.
    1.46 -if test -f configure.ac; then
    1.47 -  configure_ac=configure.ac
    1.48 -else
    1.49 -  configure_ac=configure.in
    1.50 -fi
    1.51 +  --is-lightweight)
    1.52 +    # Used by our autoconf macros to check whether the available missing
    1.53 +    # script is modern enough.
    1.54 +    exit 0
    1.55 +    ;;
    1.56  
    1.57 -msg="missing on your system"
    1.58 -
    1.59 -case $1 in
    1.60 ---run)
    1.61 -  # Try to run requested program, and just exit if it succeeds.
    1.62 -  run=
    1.63 -  shift
    1.64 -  "$@" && exit 0
    1.65 -  # Exit code 63 means version mismatch.  This often happens
    1.66 -  # when the user try to use an ancient version of a tool on
    1.67 -  # a file that requires a minimum version.  In this case we
    1.68 -  # we should proceed has if the program had been absent, or
    1.69 -  # if --run hadn't been passed.
    1.70 -  if test $? = 63; then
    1.71 -    run=:
    1.72 -    msg="probably too old"
    1.73 -  fi
    1.74 -  ;;
    1.75 +  --run)
    1.76 +    # Back-compat with the calling convention used by older automake.
    1.77 +    shift
    1.78 +    ;;
    1.79  
    1.80    -h|--h|--he|--hel|--help)
    1.81      echo "\
    1.82  $0 [OPTION]... PROGRAM [ARGUMENT]...
    1.83  
    1.84 -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
    1.85 -error status if there is no known handling for PROGRAM.
    1.86 +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
    1.87 +to PROGRAM being missing or too old.
    1.88  
    1.89  Options:
    1.90    -h, --help      display this help and exit
    1.91    -v, --version   output version information and exit
    1.92 -  --run           try to run the given command, and emulate it if it fails
    1.93  
    1.94  Supported PROGRAM values:
    1.95 -  aclocal      touch file \`aclocal.m4'
    1.96 -  autoconf     touch file \`configure'
    1.97 -  autoheader   touch file \`config.h.in'
    1.98 -  autom4te     touch the output file, or create a stub one
    1.99 -  automake     touch all \`Makefile.in' files
   1.100 -  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
   1.101 -  flex         create \`lex.yy.c', if possible, from existing .c
   1.102 -  help2man     touch the output file
   1.103 -  lex          create \`lex.yy.c', if possible, from existing .c
   1.104 -  makeinfo     touch the output file
   1.105 -  tar          try tar, gnutar, gtar, then tar without non-portable flags
   1.106 -  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
   1.107 +  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
   1.108 +  bison     yacc      flex         lex       help2man
   1.109 +
   1.110 +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
   1.111 +'g' are ignored when checking the name.
   1.112  
   1.113  Send bug reports to <bug-automake@gnu.org>."
   1.114      exit $?
   1.115 @@ -99,269 +70,146 @@
   1.116      ;;
   1.117  
   1.118    -*)
   1.119 -    echo 1>&2 "$0: Unknown \`$1' option"
   1.120 -    echo 1>&2 "Try \`$0 --help' for more information"
   1.121 +    echo 1>&2 "$0: unknown '$1' option"
   1.122 +    echo 1>&2 "Try '$0 --help' for more information"
   1.123      exit 1
   1.124      ;;
   1.125  
   1.126  esac
   1.127  
   1.128 -# Now exit if we have it, but it failed.  Also exit now if we
   1.129 -# don't have it and --version was passed (most likely to detect
   1.130 -# the program).
   1.131 -case $1 in
   1.132 -  lex|yacc)
   1.133 -    # Not GNU programs, they don't have --version.
   1.134 +# Run the given program, remember its exit status.
   1.135 +"$@"; st=$?
   1.136 +
   1.137 +# If it succeeded, we are done.
   1.138 +test $st -eq 0 && exit 0
   1.139 +
   1.140 +# Also exit now if we it failed (or wasn't found), and '--version' was
   1.141 +# passed; such an option is passed most likely to detect whether the
   1.142 +# program is present and works.
   1.143 +case $2 in --version|--help) exit $st;; esac
   1.144 +
   1.145 +# Exit code 63 means version mismatch.  This often happens when the user
   1.146 +# tries to use an ancient version of a tool on a file that requires a
   1.147 +# minimum version.
   1.148 +if test $st -eq 63; then
   1.149 +  msg="probably too old"
   1.150 +elif test $st -eq 127; then
   1.151 +  # Program was missing.
   1.152 +  msg="missing on your system"
   1.153 +else
   1.154 +  # Program was found and executed, but failed.  Give up.
   1.155 +  exit $st
   1.156 +fi
   1.157 +
   1.158 +perl_URL=http://www.perl.org/
   1.159 +flex_URL=http://flex.sourceforge.net/
   1.160 +gnu_software_URL=http://www.gnu.org/software
   1.161 +
   1.162 +program_details ()
   1.163 +{
   1.164 +  case $1 in
   1.165 +    aclocal|automake)
   1.166 +      echo "The '$1' program is part of the GNU Automake package:"
   1.167 +      echo "<$gnu_software_URL/automake>"
   1.168 +      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
   1.169 +      echo "<$gnu_software_URL/autoconf>"
   1.170 +      echo "<$gnu_software_URL/m4/>"
   1.171 +      echo "<$perl_URL>"
   1.172 +      ;;
   1.173 +    autoconf|autom4te|autoheader)
   1.174 +      echo "The '$1' program is part of the GNU Autoconf package:"
   1.175 +      echo "<$gnu_software_URL/autoconf/>"
   1.176 +      echo "It also requires GNU m4 and Perl in order to run:"
   1.177 +      echo "<$gnu_software_URL/m4/>"
   1.178 +      echo "<$perl_URL>"
   1.179 +      ;;
   1.180 +  esac
   1.181 +}
   1.182 +
   1.183 +give_advice ()
   1.184 +{
   1.185 +  # Normalize program name to check for.
   1.186 +  normalized_program=`echo "$1" | sed '
   1.187 +    s/^gnu-//; t
   1.188 +    s/^gnu//; t
   1.189 +    s/^g//; t'`
   1.190 +
   1.191 +  printf '%s\n' "'$1' is $msg."
   1.192 +
   1.193 +  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
   1.194 +  case $normalized_program in
   1.195 +    autoconf*)
   1.196 +      echo "You should only need it if you modified 'configure.ac',"
   1.197 +      echo "or m4 files included by it."
   1.198 +      program_details 'autoconf'
   1.199 +      ;;
   1.200 +    autoheader*)
   1.201 +      echo "You should only need it if you modified 'acconfig.h' or"
   1.202 +      echo "$configure_deps."
   1.203 +      program_details 'autoheader'
   1.204 +      ;;
   1.205 +    automake*)
   1.206 +      echo "You should only need it if you modified 'Makefile.am' or"
   1.207 +      echo "$configure_deps."
   1.208 +      program_details 'automake'
   1.209 +      ;;
   1.210 +    aclocal*)
   1.211 +      echo "You should only need it if you modified 'acinclude.m4' or"
   1.212 +      echo "$configure_deps."
   1.213 +      program_details 'aclocal'
   1.214 +      ;;
   1.215 +   autom4te*)
   1.216 +      echo "You might have modified some maintainer files that require"
   1.217 +      echo "the 'automa4te' program to be rebuilt."
   1.218 +      program_details 'autom4te'
   1.219 +      ;;
   1.220 +    bison*|yacc*)
   1.221 +      echo "You should only need it if you modified a '.y' file."
   1.222 +      echo "You may want to install the GNU Bison package:"
   1.223 +      echo "<$gnu_software_URL/bison/>"
   1.224 +      ;;
   1.225 +    lex*|flex*)
   1.226 +      echo "You should only need it if you modified a '.l' file."
   1.227 +      echo "You may want to install the Fast Lexical Analyzer package:"
   1.228 +      echo "<$flex_URL>"
   1.229 +      ;;
   1.230 +    help2man*)
   1.231 +      echo "You should only need it if you modified a dependency" \
   1.232 +           "of a man page."
   1.233 +      echo "You may want to install the GNU Help2man package:"
   1.234 +      echo "<$gnu_software_URL/help2man/>"
   1.235      ;;
   1.236 +    makeinfo*)
   1.237 +      echo "You should only need it if you modified a '.texi' file, or"
   1.238 +      echo "any other file indirectly affecting the aspect of the manual."
   1.239 +      echo "You might want to install the Texinfo package:"
   1.240 +      echo "<$gnu_software_URL/texinfo/>"
   1.241 +      echo "The spurious makeinfo call might also be the consequence of"
   1.242 +      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
   1.243 +      echo "want to install GNU make:"
   1.244 +      echo "<$gnu_software_URL/make/>"
   1.245 +      ;;
   1.246 +    *)
   1.247 +      echo "You might have modified some files without having the proper"
   1.248 +      echo "tools for further handling them.  Check the 'README' file, it"
   1.249 +      echo "often tells you about the needed prerequisites for installing"
   1.250 +      echo "this package.  You may also peek at any GNU archive site, in"
   1.251 +      echo "case some other package contains this missing '$1' program."
   1.252 +      ;;
   1.253 +  esac
   1.254 +}
   1.255  
   1.256 -  tar)
   1.257 -    if test -n "$run"; then
   1.258 -       echo 1>&2 "ERROR: \`tar' requires --run"
   1.259 -       exit 1
   1.260 -    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
   1.261 -       exit 1
   1.262 -    fi
   1.263 -    ;;
   1.264 +give_advice "$1" | sed -e '1s/^/WARNING: /' \
   1.265 +                       -e '2,$s/^/         /' >&2
   1.266  
   1.267 -  *)
   1.268 -    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
   1.269 -       # We have it, but it failed.
   1.270 -       exit 1
   1.271 -    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
   1.272 -       # Could not run --version or --help.  This is probably someone
   1.273 -       # running `$TOOL --version' or `$TOOL --help' to check whether
   1.274 -       # $TOOL exists and not knowing $TOOL uses missing.
   1.275 -       exit 1
   1.276 -    fi
   1.277 -    ;;
   1.278 -esac
   1.279 -
   1.280 -# If it does not exist, or fails to run (possibly an outdated version),
   1.281 -# try to emulate it.
   1.282 -case $1 in
   1.283 -  aclocal*)
   1.284 -    echo 1>&2 "\
   1.285 -WARNING: \`$1' is $msg.  You should only need it if
   1.286 -         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
   1.287 -         to install the \`Automake' and \`Perl' packages.  Grab them from
   1.288 -         any GNU archive site."
   1.289 -    touch aclocal.m4
   1.290 -    ;;
   1.291 -
   1.292 -  autoconf)
   1.293 -    echo 1>&2 "\
   1.294 -WARNING: \`$1' is $msg.  You should only need it if
   1.295 -         you modified \`${configure_ac}'.  You might want to install the
   1.296 -         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
   1.297 -         archive site."
   1.298 -    touch configure
   1.299 -    ;;
   1.300 -
   1.301 -  autoheader)
   1.302 -    echo 1>&2 "\
   1.303 -WARNING: \`$1' is $msg.  You should only need it if
   1.304 -         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
   1.305 -         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
   1.306 -         from any GNU archive site."
   1.307 -    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
   1.308 -    test -z "$files" && files="config.h"
   1.309 -    touch_files=
   1.310 -    for f in $files; do
   1.311 -      case $f in
   1.312 -      *:*) touch_files="$touch_files "`echo "$f" |
   1.313 -				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
   1.314 -      *) touch_files="$touch_files $f.in";;
   1.315 -      esac
   1.316 -    done
   1.317 -    touch $touch_files
   1.318 -    ;;
   1.319 -
   1.320 -  automake*)
   1.321 -    echo 1>&2 "\
   1.322 -WARNING: \`$1' is $msg.  You should only need it if
   1.323 -         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
   1.324 -         You might want to install the \`Automake' and \`Perl' packages.
   1.325 -         Grab them from any GNU archive site."
   1.326 -    find . -type f -name Makefile.am -print |
   1.327 -	   sed 's/\.am$/.in/' |
   1.328 -	   while read f; do touch "$f"; done
   1.329 -    ;;
   1.330 -
   1.331 -  autom4te)
   1.332 -    echo 1>&2 "\
   1.333 -WARNING: \`$1' is needed, but is $msg.
   1.334 -         You might have modified some files without having the
   1.335 -         proper tools for further handling them.
   1.336 -         You can get \`$1' as part of \`Autoconf' from any GNU
   1.337 -         archive site."
   1.338 -
   1.339 -    file=`echo "$*" | sed -n "$sed_output"`
   1.340 -    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
   1.341 -    if test -f "$file"; then
   1.342 -	touch $file
   1.343 -    else
   1.344 -	test -z "$file" || exec >$file
   1.345 -	echo "#! /bin/sh"
   1.346 -	echo "# Created by GNU Automake missing as a replacement of"
   1.347 -	echo "#  $ $@"
   1.348 -	echo "exit 0"
   1.349 -	chmod +x $file
   1.350 -	exit 1
   1.351 -    fi
   1.352 -    ;;
   1.353 -
   1.354 -  bison|yacc)
   1.355 -    echo 1>&2 "\
   1.356 -WARNING: \`$1' $msg.  You should only need it if
   1.357 -         you modified a \`.y' file.  You may need the \`Bison' package
   1.358 -         in order for those modifications to take effect.  You can get
   1.359 -         \`Bison' from any GNU archive site."
   1.360 -    rm -f y.tab.c y.tab.h
   1.361 -    if test $# -ne 1; then
   1.362 -        eval LASTARG="\${$#}"
   1.363 -	case $LASTARG in
   1.364 -	*.y)
   1.365 -	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
   1.366 -	    if test -f "$SRCFILE"; then
   1.367 -	         cp "$SRCFILE" y.tab.c
   1.368 -	    fi
   1.369 -	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
   1.370 -	    if test -f "$SRCFILE"; then
   1.371 -	         cp "$SRCFILE" y.tab.h
   1.372 -	    fi
   1.373 -	  ;;
   1.374 -	esac
   1.375 -    fi
   1.376 -    if test ! -f y.tab.h; then
   1.377 -	echo >y.tab.h
   1.378 -    fi
   1.379 -    if test ! -f y.tab.c; then
   1.380 -	echo 'main() { return 0; }' >y.tab.c
   1.381 -    fi
   1.382 -    ;;
   1.383 -
   1.384 -  lex|flex)
   1.385 -    echo 1>&2 "\
   1.386 -WARNING: \`$1' is $msg.  You should only need it if
   1.387 -         you modified a \`.l' file.  You may need the \`Flex' package
   1.388 -         in order for those modifications to take effect.  You can get
   1.389 -         \`Flex' from any GNU archive site."
   1.390 -    rm -f lex.yy.c
   1.391 -    if test $# -ne 1; then
   1.392 -        eval LASTARG="\${$#}"
   1.393 -	case $LASTARG in
   1.394 -	*.l)
   1.395 -	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
   1.396 -	    if test -f "$SRCFILE"; then
   1.397 -	         cp "$SRCFILE" lex.yy.c
   1.398 -	    fi
   1.399 -	  ;;
   1.400 -	esac
   1.401 -    fi
   1.402 -    if test ! -f lex.yy.c; then
   1.403 -	echo 'main() { return 0; }' >lex.yy.c
   1.404 -    fi
   1.405 -    ;;
   1.406 -
   1.407 -  help2man)
   1.408 -    echo 1>&2 "\
   1.409 -WARNING: \`$1' is $msg.  You should only need it if
   1.410 -	 you modified a dependency of a manual page.  You may need the
   1.411 -	 \`Help2man' package in order for those modifications to take
   1.412 -	 effect.  You can get \`Help2man' from any GNU archive site."
   1.413 -
   1.414 -    file=`echo "$*" | sed -n "$sed_output"`
   1.415 -    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
   1.416 -    if test -f "$file"; then
   1.417 -	touch $file
   1.418 -    else
   1.419 -	test -z "$file" || exec >$file
   1.420 -	echo ".ab help2man is required to generate this page"
   1.421 -	exit 1
   1.422 -    fi
   1.423 -    ;;
   1.424 -
   1.425 -  makeinfo)
   1.426 -    echo 1>&2 "\
   1.427 -WARNING: \`$1' is $msg.  You should only need it if
   1.428 -         you modified a \`.texi' or \`.texinfo' file, or any other file
   1.429 -         indirectly affecting the aspect of the manual.  The spurious
   1.430 -         call might also be the consequence of using a buggy \`make' (AIX,
   1.431 -         DU, IRIX).  You might want to install the \`Texinfo' package or
   1.432 -         the \`GNU make' package.  Grab either from any GNU archive site."
   1.433 -    # The file to touch is that specified with -o ...
   1.434 -    file=`echo "$*" | sed -n "$sed_output"`
   1.435 -    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
   1.436 -    if test -z "$file"; then
   1.437 -      # ... or it is the one specified with @setfilename ...
   1.438 -      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
   1.439 -      file=`sed -n '
   1.440 -	/^@setfilename/{
   1.441 -	  s/.* \([^ ]*\) *$/\1/
   1.442 -	  p
   1.443 -	  q
   1.444 -	}' $infile`
   1.445 -      # ... or it is derived from the source name (dir/f.texi becomes f.info)
   1.446 -      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
   1.447 -    fi
   1.448 -    # If the file does not exist, the user really needs makeinfo;
   1.449 -    # let's fail without touching anything.
   1.450 -    test -f $file || exit 1
   1.451 -    touch $file
   1.452 -    ;;
   1.453 -
   1.454 -  tar)
   1.455 -    shift
   1.456 -
   1.457 -    # We have already tried tar in the generic part.
   1.458 -    # Look for gnutar/gtar before invocation to avoid ugly error
   1.459 -    # messages.
   1.460 -    if (gnutar --version > /dev/null 2>&1); then
   1.461 -       gnutar "$@" && exit 0
   1.462 -    fi
   1.463 -    if (gtar --version > /dev/null 2>&1); then
   1.464 -       gtar "$@" && exit 0
   1.465 -    fi
   1.466 -    firstarg="$1"
   1.467 -    if shift; then
   1.468 -	case $firstarg in
   1.469 -	*o*)
   1.470 -	    firstarg=`echo "$firstarg" | sed s/o//`
   1.471 -	    tar "$firstarg" "$@" && exit 0
   1.472 -	    ;;
   1.473 -	esac
   1.474 -	case $firstarg in
   1.475 -	*h*)
   1.476 -	    firstarg=`echo "$firstarg" | sed s/h//`
   1.477 -	    tar "$firstarg" "$@" && exit 0
   1.478 -	    ;;
   1.479 -	esac
   1.480 -    fi
   1.481 -
   1.482 -    echo 1>&2 "\
   1.483 -WARNING: I can't seem to be able to run \`tar' with the given arguments.
   1.484 -         You may want to install GNU tar or Free paxutils, or check the
   1.485 -         command line arguments."
   1.486 -    exit 1
   1.487 -    ;;
   1.488 -
   1.489 -  *)
   1.490 -    echo 1>&2 "\
   1.491 -WARNING: \`$1' is needed, and is $msg.
   1.492 -         You might have modified some files without having the
   1.493 -         proper tools for further handling them.  Check the \`README' file,
   1.494 -         it often tells you about the needed prerequisites for installing
   1.495 -         this package.  You may also peek at any GNU archive site, in case
   1.496 -         some other package would contain this missing \`$1' program."
   1.497 -    exit 1
   1.498 -    ;;
   1.499 -esac
   1.500 -
   1.501 -exit 0
   1.502 +# Propagate the correct exit status (expected to be 127 for a program
   1.503 +# not found, 63 for a program that failed due to version mismatch).
   1.504 +exit $st
   1.505  
   1.506  # Local variables:
   1.507  # eval: (add-hook 'write-file-hooks 'time-stamp)
   1.508  # time-stamp-start: "scriptversion="
   1.509  # time-stamp-format: "%:y-%02m-%02d.%02H"
   1.510 -# time-stamp-end: "$"
   1.511 +# time-stamp-time-zone: "UTC"
   1.512 +# time-stamp-end: "; # UTC"
   1.513  # End: