Blame missing

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