Blame missing

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