Blame missing

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