Blame build-aux/missing

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