Blame missing

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