Blame missing

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