Blame missing

Packit b66677
#! /bin/sh
Packit b66677
# Common wrapper for a few potentially missing GNU programs.
Packit b66677
Packit b66677
scriptversion=2013-10-28.13; # UTC
Packit b66677
Packit b66677
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
Packit b66677
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
Packit b66677
Packit b66677
# This program is free software; you can redistribute it and/or modify
Packit b66677
# it under the terms of the GNU General Public License as published by
Packit b66677
# the Free Software Foundation; either version 2, or (at your option)
Packit b66677
# any later version.
Packit b66677
Packit b66677
# This program is distributed in the hope that it will be useful,
Packit b66677
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b66677
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b66677
# GNU General Public License for more details.
Packit b66677
Packit b66677
# You should have received a copy of the GNU General Public License
Packit b66677
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit b66677
Packit b66677
# As a special exception to the GNU General Public License, if you
Packit b66677
# distribute this file as part of a program that contains a
Packit b66677
# configuration script generated by Autoconf, you may include it under
Packit b66677
# the same distribution terms that you use for the rest of that program.
Packit b66677
Packit b66677
if test $# -eq 0; then
Packit b66677
  echo 1>&2 "Try '$0 --help' for more information"
Packit b66677
  exit 1
Packit b66677
fi
Packit b66677
Packit b66677
case $1 in
Packit b66677
Packit b66677
  --is-lightweight)
Packit b66677
    # Used by our autoconf macros to check whether the available missing
Packit b66677
    # script is modern enough.
Packit b66677
    exit 0
Packit b66677
    ;;
Packit b66677
Packit b66677
  --run)
Packit b66677
    # Back-compat with the calling convention used by older automake.
Packit b66677
    shift
Packit b66677
    ;;
Packit b66677
Packit b66677
  -h|--h|--he|--hel|--help)
Packit b66677
    echo "\
Packit b66677
$0 [OPTION]... PROGRAM [ARGUMENT]...
Packit b66677
Packit b66677
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
Packit b66677
to PROGRAM being missing or too old.
Packit b66677
Packit b66677
Options:
Packit b66677
  -h, --help      display this help and exit
Packit b66677
  -v, --version   output version information and exit
Packit b66677
Packit b66677
Supported PROGRAM values:
Packit b66677
  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
Packit b66677
  bison     yacc      flex         lex       help2man
Packit b66677
Packit b66677
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
Packit b66677
'g' are ignored when checking the name.
Packit b66677
Packit b66677
Send bug reports to <bug-automake@gnu.org>."
Packit b66677
    exit $?
Packit b66677
    ;;
Packit b66677
Packit b66677
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
Packit b66677
    echo "missing $scriptversion (GNU Automake)"
Packit b66677
    exit $?
Packit b66677
    ;;
Packit b66677
Packit b66677
  -*)
Packit b66677
    echo 1>&2 "$0: unknown '$1' option"
Packit b66677
    echo 1>&2 "Try '$0 --help' for more information"
Packit b66677
    exit 1
Packit b66677
    ;;
Packit b66677
Packit b66677
esac
Packit b66677
Packit b66677
# Run the given program, remember its exit status.
Packit b66677
"$@"; st=$?
Packit b66677
Packit b66677
# If it succeeded, we are done.
Packit b66677
test $st -eq 0 && exit 0
Packit b66677
Packit b66677
# Also exit now if we it failed (or wasn't found), and '--version' was
Packit b66677
# passed; such an option is passed most likely to detect whether the
Packit b66677
# program is present and works.
Packit b66677
case $2 in --version|--help) exit $st;; esac
Packit b66677
Packit b66677
# Exit code 63 means version mismatch.  This often happens when the user
Packit b66677
# tries to use an ancient version of a tool on a file that requires a
Packit b66677
# minimum version.
Packit b66677
if test $st -eq 63; then
Packit b66677
  msg="probably too old"
Packit b66677
elif test $st -eq 127; then
Packit b66677
  # Program was missing.
Packit b66677
  msg="missing on your system"
Packit b66677
else
Packit b66677
  # Program was found and executed, but failed.  Give up.
Packit b66677
  exit $st
Packit b66677
fi
Packit b66677
Packit b66677
perl_URL=http://www.perl.org/
Packit b66677
flex_URL=http://flex.sourceforge.net/
Packit b66677
gnu_software_URL=http://www.gnu.org/software
Packit b66677
Packit b66677
program_details ()
Packit b66677
{
Packit b66677
  case $1 in
Packit b66677
    aclocal|automake)
Packit b66677
      echo "The '$1' program is part of the GNU Automake package:"
Packit b66677
      echo "<$gnu_software_URL/automake>"
Packit b66677
      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
Packit b66677
      echo "<$gnu_software_URL/autoconf>"
Packit b66677
      echo "<$gnu_software_URL/m4/>"
Packit b66677
      echo "<$perl_URL>"
Packit b66677
      ;;
Packit b66677
    autoconf|autom4te|autoheader)
Packit b66677
      echo "The '$1' program is part of the GNU Autoconf package:"
Packit b66677
      echo "<$gnu_software_URL/autoconf/>"
Packit b66677
      echo "It also requires GNU m4 and Perl in order to run:"
Packit b66677
      echo "<$gnu_software_URL/m4/>"
Packit b66677
      echo "<$perl_URL>"
Packit b66677
      ;;
Packit b66677
  esac
Packit b66677
}
Packit b66677
Packit b66677
give_advice ()
Packit b66677
{
Packit b66677
  # Normalize program name to check for.
Packit b66677
  normalized_program=`echo "$1" | sed '
Packit b66677
    s/^gnu-//; t
Packit b66677
    s/^gnu//; t
Packit b66677
    s/^g//; t'`
Packit b66677
Packit b66677
  printf '%s\n' "'$1' is $msg."
Packit b66677
Packit b66677
  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
Packit b66677
  case $normalized_program in
Packit b66677
    autoconf*)
Packit b66677
      echo "You should only need it if you modified 'configure.ac',"
Packit b66677
      echo "or m4 files included by it."
Packit b66677
      program_details 'autoconf'
Packit b66677
      ;;
Packit b66677
    autoheader*)
Packit b66677
      echo "You should only need it if you modified 'acconfig.h' or"
Packit b66677
      echo "$configure_deps."
Packit b66677
      program_details 'autoheader'
Packit b66677
      ;;
Packit b66677
    automake*)
Packit b66677
      echo "You should only need it if you modified 'Makefile.am' or"
Packit b66677
      echo "$configure_deps."
Packit b66677
      program_details 'automake'
Packit b66677
      ;;
Packit b66677
    aclocal*)
Packit b66677
      echo "You should only need it if you modified 'acinclude.m4' or"
Packit b66677
      echo "$configure_deps."
Packit b66677
      program_details 'aclocal'
Packit b66677
      ;;
Packit b66677
   autom4te*)
Packit b66677
      echo "You might have modified some maintainer files that require"
Packit b66677
      echo "the 'autom4te' program to be rebuilt."
Packit b66677
      program_details 'autom4te'
Packit b66677
      ;;
Packit b66677
    bison*|yacc*)
Packit b66677
      echo "You should only need it if you modified a '.y' file."
Packit b66677
      echo "You may want to install the GNU Bison package:"
Packit b66677
      echo "<$gnu_software_URL/bison/>"
Packit b66677
      ;;
Packit b66677
    lex*|flex*)
Packit b66677
      echo "You should only need it if you modified a '.l' file."
Packit b66677
      echo "You may want to install the Fast Lexical Analyzer package:"
Packit b66677
      echo "<$flex_URL>"
Packit b66677
      ;;
Packit b66677
    help2man*)
Packit b66677
      echo "You should only need it if you modified a dependency" \
Packit b66677
           "of a man page."
Packit b66677
      echo "You may want to install the GNU Help2man package:"
Packit b66677
      echo "<$gnu_software_URL/help2man/>"
Packit b66677
    ;;
Packit b66677
    makeinfo*)
Packit b66677
      echo "You should only need it if you modified a '.texi' file, or"
Packit b66677
      echo "any other file indirectly affecting the aspect of the manual."
Packit b66677
      echo "You might want to install the Texinfo package:"
Packit b66677
      echo "<$gnu_software_URL/texinfo/>"
Packit b66677
      echo "The spurious makeinfo call might also be the consequence of"
Packit b66677
      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
Packit b66677
      echo "want to install GNU make:"
Packit b66677
      echo "<$gnu_software_URL/make/>"
Packit b66677
      ;;
Packit b66677
    *)
Packit b66677
      echo "You might have modified some files without having the proper"
Packit b66677
      echo "tools for further handling them.  Check the 'README' file, it"
Packit b66677
      echo "often tells you about the needed prerequisites for installing"
Packit b66677
      echo "this package.  You may also peek at any GNU archive site, in"
Packit b66677
      echo "case some other package contains this missing '$1' program."
Packit b66677
      ;;
Packit b66677
  esac
Packit b66677
}
Packit b66677
Packit b66677
give_advice "$1" | sed -e '1s/^/WARNING: /' \
Packit b66677
                       -e '2,$s/^/         /' >&2
Packit b66677
Packit b66677
# Propagate the correct exit status (expected to be 127 for a program
Packit b66677
# not found, 63 for a program that failed due to version mismatch).
Packit b66677
exit $st
Packit b66677
Packit b66677
# Local variables:
Packit b66677
# eval: (add-hook 'write-file-hooks 'time-stamp)
Packit b66677
# time-stamp-start: "scriptversion="
Packit b66677
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit b66677
# time-stamp-time-zone: "UTC"
Packit b66677
# time-stamp-end: "; # UTC"
Packit b66677
# End: