Blame config/missing

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