Blame missing

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