Blame missing

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