Blame build-aux/missing

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