Blame missing

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