Blame missing

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