Blame missing

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