Blame missing

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