Blame missing

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