Blame missing

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