Blame build-aux/missing

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