Blame missing

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