Blame build-aux/missing

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