missing revision 74a3f230
1b3307321Smrg#! /bin/sh
274a3f230Smrg# Common wrapper for a few potentially missing GNU programs.
3afe13c8eSmrg
474a3f230Smrgscriptversion=2012-06-26.16; # UTC
5afe13c8eSmrg
674a3f230Smrg# Copyright (C) 1996-2013 Free Software Foundation, Inc.
774a3f230Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8b3307321Smrg
9b3307321Smrg# This program is free software; you can redistribute it and/or modify
10b3307321Smrg# it under the terms of the GNU General Public License as published by
11b3307321Smrg# the Free Software Foundation; either version 2, or (at your option)
12b3307321Smrg# any later version.
13b3307321Smrg
14b3307321Smrg# This program is distributed in the hope that it will be useful,
15b3307321Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16b3307321Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17b3307321Smrg# GNU General Public License for more details.
18b3307321Smrg
19b3307321Smrg# You should have received a copy of the GNU General Public License
205e358ecaSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21b3307321Smrg
22b3307321Smrg# As a special exception to the GNU General Public License, if you
23b3307321Smrg# distribute this file as part of a program that contains a
24b3307321Smrg# configuration script generated by Autoconf, you may include it under
25b3307321Smrg# the same distribution terms that you use for the rest of that program.
26b3307321Smrg
27b3307321Smrgif test $# -eq 0; then
2874a3f230Smrg  echo 1>&2 "Try '$0 --help' for more information"
29b3307321Smrg  exit 1
30b3307321Smrgfi
31b3307321Smrg
3274a3f230Smrgcase $1 in
33b3307321Smrg
3474a3f230Smrg  --is-lightweight)
3574a3f230Smrg    # Used by our autoconf macros to check whether the available missing
3674a3f230Smrg    # script is modern enough.
3774a3f230Smrg    exit 0
3874a3f230Smrg    ;;
39afe13c8eSmrg
4074a3f230Smrg  --run)
4174a3f230Smrg    # Back-compat with the calling convention used by older automake.
4274a3f230Smrg    shift
4374a3f230Smrg    ;;
44b3307321Smrg
45b3307321Smrg  -h|--h|--he|--hel|--help)
46b3307321Smrg    echo "\
47b3307321Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48b3307321Smrg
4974a3f230SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5074a3f230Smrgto PROGRAM being missing or too old.
51b3307321Smrg
52b3307321SmrgOptions:
53b3307321Smrg  -h, --help      display this help and exit
54b3307321Smrg  -v, --version   output version information and exit
55b3307321Smrg
56b3307321SmrgSupported PROGRAM values:
5774a3f230Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5874a3f230Smrg  bison     yacc      flex         lex       help2man
59afe13c8eSmrg
6074a3f230SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6174a3f230Smrg'g' are ignored when checking the name.
625e358ecaSmrg
63afe13c8eSmrgSend bug reports to <bug-automake@gnu.org>."
64afe13c8eSmrg    exit $?
65b3307321Smrg    ;;
66b3307321Smrg
67b3307321Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68afe13c8eSmrg    echo "missing $scriptversion (GNU Automake)"
69afe13c8eSmrg    exit $?
70b3307321Smrg    ;;
71b3307321Smrg
72b3307321Smrg  -*)
7374a3f230Smrg    echo 1>&2 "$0: unknown '$1' option"
7474a3f230Smrg    echo 1>&2 "Try '$0 --help' for more information"
75b3307321Smrg    exit 1
76b3307321Smrg    ;;
77b3307321Smrg
78afe13c8eSmrgesac
79afe13c8eSmrg
8074a3f230Smrg# Run the given program, remember its exit status.
8174a3f230Smrg"$@"; st=$?
8274a3f230Smrg
8374a3f230Smrg# If it succeeded, we are done.
8474a3f230Smrgtest $st -eq 0 && exit 0
8574a3f230Smrg
8674a3f230Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
8774a3f230Smrg# passed; such an option is passed most likely to detect whether the
8874a3f230Smrg# program is present and works.
8974a3f230Smrgcase $2 in --version|--help) exit $st;; esac
9074a3f230Smrg
9174a3f230Smrg# Exit code 63 means version mismatch.  This often happens when the user
9274a3f230Smrg# tries to use an ancient version of a tool on a file that requires a
9374a3f230Smrg# minimum version.
9474a3f230Smrgif test $st -eq 63; then
9574a3f230Smrg  msg="probably too old"
9674a3f230Smrgelif test $st -eq 127; then
9774a3f230Smrg  # Program was missing.
9874a3f230Smrg  msg="missing on your system"
9974a3f230Smrgelse
10074a3f230Smrg  # Program was found and executed, but failed.  Give up.
10174a3f230Smrg  exit $st
10274a3f230Smrgfi
103b3307321Smrg
10474a3f230Smrgperl_URL=http://www.perl.org/
10574a3f230Smrgflex_URL=http://flex.sourceforge.net/
10674a3f230Smrggnu_software_URL=http://www.gnu.org/software
10774a3f230Smrg
10874a3f230Smrgprogram_details ()
10974a3f230Smrg{
11074a3f230Smrg  case $1 in
11174a3f230Smrg    aclocal|automake)
11274a3f230Smrg      echo "The '$1' program is part of the GNU Automake package:"
11374a3f230Smrg      echo "<$gnu_software_URL/automake>"
11474a3f230Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11574a3f230Smrg      echo "<$gnu_software_URL/autoconf>"
11674a3f230Smrg      echo "<$gnu_software_URL/m4/>"
11774a3f230Smrg      echo "<$perl_URL>"
11874a3f230Smrg      ;;
11974a3f230Smrg    autoconf|autom4te|autoheader)
12074a3f230Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
12174a3f230Smrg      echo "<$gnu_software_URL/autoconf/>"
12274a3f230Smrg      echo "It also requires GNU m4 and Perl in order to run:"
12374a3f230Smrg      echo "<$gnu_software_URL/m4/>"
12474a3f230Smrg      echo "<$perl_URL>"
12574a3f230Smrg      ;;
12674a3f230Smrg  esac
12774a3f230Smrg}
12874a3f230Smrg
12974a3f230Smrggive_advice ()
13074a3f230Smrg{
13174a3f230Smrg  # Normalize program name to check for.
13274a3f230Smrg  normalized_program=`echo "$1" | sed '
13374a3f230Smrg    s/^gnu-//; t
13474a3f230Smrg    s/^gnu//; t
13574a3f230Smrg    s/^g//; t'`
13674a3f230Smrg
13774a3f230Smrg  printf '%s\n' "'$1' is $msg."
13874a3f230Smrg
13974a3f230Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14074a3f230Smrg  case $normalized_program in
14174a3f230Smrg    autoconf*)
14274a3f230Smrg      echo "You should only need it if you modified 'configure.ac',"
14374a3f230Smrg      echo "or m4 files included by it."
14474a3f230Smrg      program_details 'autoconf'
14574a3f230Smrg      ;;
14674a3f230Smrg    autoheader*)
14774a3f230Smrg      echo "You should only need it if you modified 'acconfig.h' or"
14874a3f230Smrg      echo "$configure_deps."
14974a3f230Smrg      program_details 'autoheader'
15074a3f230Smrg      ;;
15174a3f230Smrg    automake*)
15274a3f230Smrg      echo "You should only need it if you modified 'Makefile.am' or"
15374a3f230Smrg      echo "$configure_deps."
15474a3f230Smrg      program_details 'automake'
15574a3f230Smrg      ;;
15674a3f230Smrg    aclocal*)
15774a3f230Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
15874a3f230Smrg      echo "$configure_deps."
15974a3f230Smrg      program_details 'aclocal'
16074a3f230Smrg      ;;
16174a3f230Smrg   autom4te*)
16274a3f230Smrg      echo "You might have modified some maintainer files that require"
16374a3f230Smrg      echo "the 'automa4te' program to be rebuilt."
16474a3f230Smrg      program_details 'autom4te'
16574a3f230Smrg      ;;
16674a3f230Smrg    bison*|yacc*)
16774a3f230Smrg      echo "You should only need it if you modified a '.y' file."
16874a3f230Smrg      echo "You may want to install the GNU Bison package:"
16974a3f230Smrg      echo "<$gnu_software_URL/bison/>"
17074a3f230Smrg      ;;
17174a3f230Smrg    lex*|flex*)
17274a3f230Smrg      echo "You should only need it if you modified a '.l' file."
17374a3f230Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
17474a3f230Smrg      echo "<$flex_URL>"
17574a3f230Smrg      ;;
17674a3f230Smrg    help2man*)
17774a3f230Smrg      echo "You should only need it if you modified a dependency" \
17874a3f230Smrg           "of a man page."
17974a3f230Smrg      echo "You may want to install the GNU Help2man package:"
18074a3f230Smrg      echo "<$gnu_software_URL/help2man/>"
18174a3f230Smrg    ;;
18274a3f230Smrg    makeinfo*)
18374a3f230Smrg      echo "You should only need it if you modified a '.texi' file, or"
18474a3f230Smrg      echo "any other file indirectly affecting the aspect of the manual."
18574a3f230Smrg      echo "You might want to install the Texinfo package:"
18674a3f230Smrg      echo "<$gnu_software_URL/texinfo/>"
18774a3f230Smrg      echo "The spurious makeinfo call might also be the consequence of"
18874a3f230Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18974a3f230Smrg      echo "want to install GNU make:"
19074a3f230Smrg      echo "<$gnu_software_URL/make/>"
19174a3f230Smrg      ;;
19274a3f230Smrg    *)
19374a3f230Smrg      echo "You might have modified some files without having the proper"
19474a3f230Smrg      echo "tools for further handling them.  Check the 'README' file, it"
19574a3f230Smrg      echo "often tells you about the needed prerequisites for installing"
19674a3f230Smrg      echo "this package.  You may also peek at any GNU archive site, in"
19774a3f230Smrg      echo "case some other package contains this missing '$1' program."
19874a3f230Smrg      ;;
19974a3f230Smrg  esac
20074a3f230Smrg}
20174a3f230Smrg
20274a3f230Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20374a3f230Smrg                       -e '2,$s/^/         /' >&2
20474a3f230Smrg
20574a3f230Smrg# Propagate the correct exit status (expected to be 127 for a program
20674a3f230Smrg# not found, 63 for a program that failed due to version mismatch).
20774a3f230Smrgexit $st
208afe13c8eSmrg
209afe13c8eSmrg# Local variables:
210afe13c8eSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
211afe13c8eSmrg# time-stamp-start: "scriptversion="
212afe13c8eSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
2135e358ecaSmrg# time-stamp-time-zone: "UTC"
2145e358ecaSmrg# time-stamp-end: "; # UTC"
215afe13c8eSmrg# End:
216