Blame build/missing

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