Blame missing

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