Blame missing

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