132001f49Smrg#! /bin/sh
232001f49Smrg# Common wrapper for a few potentially missing GNU programs.
332001f49Smrg
432001f49Smrgscriptversion=2013-10-28.13; # UTC
532001f49Smrg
67ec3b29aSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
732001f49Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
832001f49Smrg
932001f49Smrg# This program is free software; you can redistribute it and/or modify
1032001f49Smrg# it under the terms of the GNU General Public License as published by
1132001f49Smrg# the Free Software Foundation; either version 2, or (at your option)
1232001f49Smrg# any later version.
1332001f49Smrg
1432001f49Smrg# This program is distributed in the hope that it will be useful,
1532001f49Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1632001f49Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1732001f49Smrg# GNU General Public License for more details.
1832001f49Smrg
1932001f49Smrg# You should have received a copy of the GNU General Public License
2032001f49Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2132001f49Smrg
2232001f49Smrg# As a special exception to the GNU General Public License, if you
2332001f49Smrg# distribute this file as part of a program that contains a
2432001f49Smrg# configuration script generated by Autoconf, you may include it under
2532001f49Smrg# the same distribution terms that you use for the rest of that program.
2632001f49Smrg
2732001f49Smrgif test $# -eq 0; then
2832001f49Smrg  echo 1>&2 "Try '$0 --help' for more information"
2932001f49Smrg  exit 1
3032001f49Smrgfi
3132001f49Smrg
3232001f49Smrgcase $1 in
3332001f49Smrg
3432001f49Smrg  --is-lightweight)
3532001f49Smrg    # Used by our autoconf macros to check whether the available missing
3632001f49Smrg    # script is modern enough.
3732001f49Smrg    exit 0
3832001f49Smrg    ;;
3932001f49Smrg
4032001f49Smrg  --run)
4132001f49Smrg    # Back-compat with the calling convention used by older automake.
4232001f49Smrg    shift
4332001f49Smrg    ;;
4432001f49Smrg
4532001f49Smrg  -h|--h|--he|--hel|--help)
4632001f49Smrg    echo "\
4732001f49Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4832001f49Smrg
4932001f49SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5032001f49Smrgto PROGRAM being missing or too old.
5132001f49Smrg
5232001f49SmrgOptions:
5332001f49Smrg  -h, --help      display this help and exit
5432001f49Smrg  -v, --version   output version information and exit
5532001f49Smrg
5632001f49SmrgSupported PROGRAM values:
5732001f49Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5832001f49Smrg  bison     yacc      flex         lex       help2man
5932001f49Smrg
6032001f49SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6132001f49Smrg'g' are ignored when checking the name.
6232001f49Smrg
6332001f49SmrgSend bug reports to <bug-automake@gnu.org>."
6432001f49Smrg    exit $?
6532001f49Smrg    ;;
6632001f49Smrg
6732001f49Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6832001f49Smrg    echo "missing $scriptversion (GNU Automake)"
6932001f49Smrg    exit $?
7032001f49Smrg    ;;
7132001f49Smrg
7232001f49Smrg  -*)
7332001f49Smrg    echo 1>&2 "$0: unknown '$1' option"
7432001f49Smrg    echo 1>&2 "Try '$0 --help' for more information"
7532001f49Smrg    exit 1
7632001f49Smrg    ;;
7732001f49Smrg
7832001f49Smrgesac
7932001f49Smrg
8032001f49Smrg# Run the given program, remember its exit status.
8132001f49Smrg"$@"; st=$?
8232001f49Smrg
8332001f49Smrg# If it succeeded, we are done.
8432001f49Smrgtest $st -eq 0 && exit 0
8532001f49Smrg
8632001f49Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
8732001f49Smrg# passed; such an option is passed most likely to detect whether the
8832001f49Smrg# program is present and works.
8932001f49Smrgcase $2 in --version|--help) exit $st;; esac
9032001f49Smrg
9132001f49Smrg# Exit code 63 means version mismatch.  This often happens when the user
9232001f49Smrg# tries to use an ancient version of a tool on a file that requires a
9332001f49Smrg# minimum version.
9432001f49Smrgif test $st -eq 63; then
9532001f49Smrg  msg="probably too old"
9632001f49Smrgelif test $st -eq 127; then
9732001f49Smrg  # Program was missing.
9832001f49Smrg  msg="missing on your system"
9932001f49Smrgelse
10032001f49Smrg  # Program was found and executed, but failed.  Give up.
10132001f49Smrg  exit $st
10232001f49Smrgfi
10332001f49Smrg
10432001f49Smrgperl_URL=http://www.perl.org/
10532001f49Smrgflex_URL=http://flex.sourceforge.net/
10632001f49Smrggnu_software_URL=http://www.gnu.org/software
10732001f49Smrg
10832001f49Smrgprogram_details ()
10932001f49Smrg{
11032001f49Smrg  case $1 in
11132001f49Smrg    aclocal|automake)
11232001f49Smrg      echo "The '$1' program is part of the GNU Automake package:"
11332001f49Smrg      echo "<$gnu_software_URL/automake>"
11432001f49Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11532001f49Smrg      echo "<$gnu_software_URL/autoconf>"
11632001f49Smrg      echo "<$gnu_software_URL/m4/>"
11732001f49Smrg      echo "<$perl_URL>"
11832001f49Smrg      ;;
11932001f49Smrg    autoconf|autom4te|autoheader)
12032001f49Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
12132001f49Smrg      echo "<$gnu_software_URL/autoconf/>"
12232001f49Smrg      echo "It also requires GNU m4 and Perl in order to run:"
12332001f49Smrg      echo "<$gnu_software_URL/m4/>"
12432001f49Smrg      echo "<$perl_URL>"
12532001f49Smrg      ;;
12632001f49Smrg  esac
12732001f49Smrg}
12832001f49Smrg
12932001f49Smrggive_advice ()
13032001f49Smrg{
13132001f49Smrg  # Normalize program name to check for.
13232001f49Smrg  normalized_program=`echo "$1" | sed '
13332001f49Smrg    s/^gnu-//; t
13432001f49Smrg    s/^gnu//; t
13532001f49Smrg    s/^g//; t'`
13632001f49Smrg
13732001f49Smrg  printf '%s\n' "'$1' is $msg."
13832001f49Smrg
13932001f49Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14032001f49Smrg  case $normalized_program in
14132001f49Smrg    autoconf*)
14232001f49Smrg      echo "You should only need it if you modified 'configure.ac',"
14332001f49Smrg      echo "or m4 files included by it."
14432001f49Smrg      program_details 'autoconf'
14532001f49Smrg      ;;
14632001f49Smrg    autoheader*)
14732001f49Smrg      echo "You should only need it if you modified 'acconfig.h' or"
14832001f49Smrg      echo "$configure_deps."
14932001f49Smrg      program_details 'autoheader'
15032001f49Smrg      ;;
15132001f49Smrg    automake*)
15232001f49Smrg      echo "You should only need it if you modified 'Makefile.am' or"
15332001f49Smrg      echo "$configure_deps."
15432001f49Smrg      program_details 'automake'
15532001f49Smrg      ;;
15632001f49Smrg    aclocal*)
15732001f49Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
15832001f49Smrg      echo "$configure_deps."
15932001f49Smrg      program_details 'aclocal'
16032001f49Smrg      ;;
16132001f49Smrg   autom4te*)
16232001f49Smrg      echo "You might have modified some maintainer files that require"
16332001f49Smrg      echo "the 'autom4te' program to be rebuilt."
16432001f49Smrg      program_details 'autom4te'
16532001f49Smrg      ;;
16632001f49Smrg    bison*|yacc*)
16732001f49Smrg      echo "You should only need it if you modified a '.y' file."
16832001f49Smrg      echo "You may want to install the GNU Bison package:"
16932001f49Smrg      echo "<$gnu_software_URL/bison/>"
17032001f49Smrg      ;;
17132001f49Smrg    lex*|flex*)
17232001f49Smrg      echo "You should only need it if you modified a '.l' file."
17332001f49Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
17432001f49Smrg      echo "<$flex_URL>"
17532001f49Smrg      ;;
17632001f49Smrg    help2man*)
17732001f49Smrg      echo "You should only need it if you modified a dependency" \
17832001f49Smrg           "of a man page."
17932001f49Smrg      echo "You may want to install the GNU Help2man package:"
18032001f49Smrg      echo "<$gnu_software_URL/help2man/>"
18132001f49Smrg    ;;
18232001f49Smrg    makeinfo*)
18332001f49Smrg      echo "You should only need it if you modified a '.texi' file, or"
18432001f49Smrg      echo "any other file indirectly affecting the aspect of the manual."
18532001f49Smrg      echo "You might want to install the Texinfo package:"
18632001f49Smrg      echo "<$gnu_software_URL/texinfo/>"
18732001f49Smrg      echo "The spurious makeinfo call might also be the consequence of"
18832001f49Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18932001f49Smrg      echo "want to install GNU make:"
19032001f49Smrg      echo "<$gnu_software_URL/make/>"
19132001f49Smrg      ;;
19232001f49Smrg    *)
19332001f49Smrg      echo "You might have modified some files without having the proper"
19432001f49Smrg      echo "tools for further handling them.  Check the 'README' file, it"
19532001f49Smrg      echo "often tells you about the needed prerequisites for installing"
19632001f49Smrg      echo "this package.  You may also peek at any GNU archive site, in"
19732001f49Smrg      echo "case some other package contains this missing '$1' program."
19832001f49Smrg      ;;
19932001f49Smrg  esac
20032001f49Smrg}
20132001f49Smrg
20232001f49Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20332001f49Smrg                       -e '2,$s/^/         /' >&2
20432001f49Smrg
20532001f49Smrg# Propagate the correct exit status (expected to be 127 for a program
20632001f49Smrg# not found, 63 for a program that failed due to version mismatch).
20732001f49Smrgexit $st
20832001f49Smrg
20932001f49Smrg# Local variables:
21032001f49Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
21132001f49Smrg# time-stamp-start: "scriptversion="
21232001f49Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
21332001f49Smrg# time-stamp-time-zone: "UTC"
21432001f49Smrg# time-stamp-end: "; # UTC"
21532001f49Smrg# End:
216