Blame missing

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