Blame missing

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