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