Blame missing

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