Blame missing

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