Blame missing

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