missing revision 68af480f
197e8a2e8Smrg#! /bin/sh
268af480fSmrg# Common wrapper for a few potentially missing GNU programs.
3d7accfefSmrg
468af480fSmrgscriptversion=2012-06-26.16; # UTC
5d7accfefSmrg
668af480fSmrg# Copyright (C) 1996-2013 Free Software Foundation, Inc.
768af480fSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
897e8a2e8Smrg
997e8a2e8Smrg# This program is free software; you can redistribute it and/or modify
1097e8a2e8Smrg# it under the terms of the GNU General Public License as published by
1197e8a2e8Smrg# the Free Software Foundation; either version 2, or (at your option)
1297e8a2e8Smrg# any later version.
1397e8a2e8Smrg
1497e8a2e8Smrg# This program is distributed in the hope that it will be useful,
1597e8a2e8Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1697e8a2e8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1797e8a2e8Smrg# GNU General Public License for more details.
1897e8a2e8Smrg
1997e8a2e8Smrg# You should have received a copy of the GNU General Public License
20d7accfefSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2197e8a2e8Smrg
2297e8a2e8Smrg# As a special exception to the GNU General Public License, if you
2397e8a2e8Smrg# distribute this file as part of a program that contains a
2497e8a2e8Smrg# configuration script generated by Autoconf, you may include it under
2597e8a2e8Smrg# the same distribution terms that you use for the rest of that program.
2697e8a2e8Smrg
2797e8a2e8Smrgif test $# -eq 0; then
2868af480fSmrg  echo 1>&2 "Try '$0 --help' for more information"
2997e8a2e8Smrg  exit 1
3097e8a2e8Smrgfi
3197e8a2e8Smrg
3268af480fSmrgcase $1 in
3397e8a2e8Smrg
3468af480fSmrg  --is-lightweight)
3568af480fSmrg    # Used by our autoconf macros to check whether the available missing
3668af480fSmrg    # script is modern enough.
3768af480fSmrg    exit 0
3868af480fSmrg    ;;
39d7accfefSmrg
4068af480fSmrg  --run)
4168af480fSmrg    # Back-compat with the calling convention used by older automake.
4268af480fSmrg    shift
4368af480fSmrg    ;;
4497e8a2e8Smrg
4597e8a2e8Smrg  -h|--h|--he|--hel|--help)
4697e8a2e8Smrg    echo "\
4797e8a2e8Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4897e8a2e8Smrg
4968af480fSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5068af480fSmrgto PROGRAM being missing or too old.
5197e8a2e8Smrg
5297e8a2e8SmrgOptions:
5397e8a2e8Smrg  -h, --help      display this help and exit
5497e8a2e8Smrg  -v, --version   output version information and exit
5597e8a2e8Smrg
5697e8a2e8SmrgSupported PROGRAM values:
5768af480fSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5868af480fSmrg  bison     yacc      flex         lex       help2man
59d7accfefSmrg
6068af480fSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6168af480fSmrg'g' are ignored when checking the name.
62d7accfefSmrg
63d7accfefSmrgSend bug reports to <bug-automake@gnu.org>."
64d7accfefSmrg    exit $?
6597e8a2e8Smrg    ;;
6697e8a2e8Smrg
6797e8a2e8Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68d7accfefSmrg    echo "missing $scriptversion (GNU Automake)"
69d7accfefSmrg    exit $?
7097e8a2e8Smrg    ;;
7197e8a2e8Smrg
7297e8a2e8Smrg  -*)
7368af480fSmrg    echo 1>&2 "$0: unknown '$1' option"
7468af480fSmrg    echo 1>&2 "Try '$0 --help' for more information"
7597e8a2e8Smrg    exit 1
7697e8a2e8Smrg    ;;
7797e8a2e8Smrg
78d7accfefSmrgesac
79d7accfefSmrg
8068af480fSmrg# Run the given program, remember its exit status.
8168af480fSmrg"$@"; st=$?
8268af480fSmrg
8368af480fSmrg# If it succeeded, we are done.
8468af480fSmrgtest $st -eq 0 && exit 0
8568af480fSmrg
8668af480fSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
8768af480fSmrg# passed; such an option is passed most likely to detect whether the
8868af480fSmrg# program is present and works.
8968af480fSmrgcase $2 in --version|--help) exit $st;; esac
9068af480fSmrg
9168af480fSmrg# Exit code 63 means version mismatch.  This often happens when the user
9268af480fSmrg# tries to use an ancient version of a tool on a file that requires a
9368af480fSmrg# minimum version.
9468af480fSmrgif test $st -eq 63; then
9568af480fSmrg  msg="probably too old"
9668af480fSmrgelif test $st -eq 127; then
9768af480fSmrg  # Program was missing.
9868af480fSmrg  msg="missing on your system"
9968af480fSmrgelse
10068af480fSmrg  # Program was found and executed, but failed.  Give up.
10168af480fSmrg  exit $st
10268af480fSmrgfi
10397e8a2e8Smrg
10468af480fSmrgperl_URL=http://www.perl.org/
10568af480fSmrgflex_URL=http://flex.sourceforge.net/
10668af480fSmrggnu_software_URL=http://www.gnu.org/software
10768af480fSmrg
10868af480fSmrgprogram_details ()
10968af480fSmrg{
11068af480fSmrg  case $1 in
11168af480fSmrg    aclocal|automake)
11268af480fSmrg      echo "The '$1' program is part of the GNU Automake package:"
11368af480fSmrg      echo "<$gnu_software_URL/automake>"
11468af480fSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11568af480fSmrg      echo "<$gnu_software_URL/autoconf>"
11668af480fSmrg      echo "<$gnu_software_URL/m4/>"
11768af480fSmrg      echo "<$perl_URL>"
11868af480fSmrg      ;;
11968af480fSmrg    autoconf|autom4te|autoheader)
12068af480fSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
12168af480fSmrg      echo "<$gnu_software_URL/autoconf/>"
12268af480fSmrg      echo "It also requires GNU m4 and Perl in order to run:"
12368af480fSmrg      echo "<$gnu_software_URL/m4/>"
12468af480fSmrg      echo "<$perl_URL>"
12568af480fSmrg      ;;
12668af480fSmrg  esac
12768af480fSmrg}
12868af480fSmrg
12968af480fSmrggive_advice ()
13068af480fSmrg{
13168af480fSmrg  # Normalize program name to check for.
13268af480fSmrg  normalized_program=`echo "$1" | sed '
13368af480fSmrg    s/^gnu-//; t
13468af480fSmrg    s/^gnu//; t
13568af480fSmrg    s/^g//; t'`
13668af480fSmrg
13768af480fSmrg  printf '%s\n' "'$1' is $msg."
13868af480fSmrg
13968af480fSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14068af480fSmrg  case $normalized_program in
14168af480fSmrg    autoconf*)
14268af480fSmrg      echo "You should only need it if you modified 'configure.ac',"
14368af480fSmrg      echo "or m4 files included by it."
14468af480fSmrg      program_details 'autoconf'
14568af480fSmrg      ;;
14668af480fSmrg    autoheader*)
14768af480fSmrg      echo "You should only need it if you modified 'acconfig.h' or"
14868af480fSmrg      echo "$configure_deps."
14968af480fSmrg      program_details 'autoheader'
15068af480fSmrg      ;;
15168af480fSmrg    automake*)
15268af480fSmrg      echo "You should only need it if you modified 'Makefile.am' or"
15368af480fSmrg      echo "$configure_deps."
15468af480fSmrg      program_details 'automake'
15568af480fSmrg      ;;
15668af480fSmrg    aclocal*)
15768af480fSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
15868af480fSmrg      echo "$configure_deps."
15968af480fSmrg      program_details 'aclocal'
16068af480fSmrg      ;;
16168af480fSmrg   autom4te*)
16268af480fSmrg      echo "You might have modified some maintainer files that require"
16368af480fSmrg      echo "the 'automa4te' program to be rebuilt."
16468af480fSmrg      program_details 'autom4te'
16568af480fSmrg      ;;
16668af480fSmrg    bison*|yacc*)
16768af480fSmrg      echo "You should only need it if you modified a '.y' file."
16868af480fSmrg      echo "You may want to install the GNU Bison package:"
16968af480fSmrg      echo "<$gnu_software_URL/bison/>"
17068af480fSmrg      ;;
17168af480fSmrg    lex*|flex*)
17268af480fSmrg      echo "You should only need it if you modified a '.l' file."
17368af480fSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
17468af480fSmrg      echo "<$flex_URL>"
17568af480fSmrg      ;;
17668af480fSmrg    help2man*)
17768af480fSmrg      echo "You should only need it if you modified a dependency" \
17868af480fSmrg           "of a man page."
17968af480fSmrg      echo "You may want to install the GNU Help2man package:"
18068af480fSmrg      echo "<$gnu_software_URL/help2man/>"
18168af480fSmrg    ;;
18268af480fSmrg    makeinfo*)
18368af480fSmrg      echo "You should only need it if you modified a '.texi' file, or"
18468af480fSmrg      echo "any other file indirectly affecting the aspect of the manual."
18568af480fSmrg      echo "You might want to install the Texinfo package:"
18668af480fSmrg      echo "<$gnu_software_URL/texinfo/>"
18768af480fSmrg      echo "The spurious makeinfo call might also be the consequence of"
18868af480fSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18968af480fSmrg      echo "want to install GNU make:"
19068af480fSmrg      echo "<$gnu_software_URL/make/>"
19168af480fSmrg      ;;
19268af480fSmrg    *)
19368af480fSmrg      echo "You might have modified some files without having the proper"
19468af480fSmrg      echo "tools for further handling them.  Check the 'README' file, it"
19568af480fSmrg      echo "often tells you about the needed prerequisites for installing"
19668af480fSmrg      echo "this package.  You may also peek at any GNU archive site, in"
19768af480fSmrg      echo "case some other package contains this missing '$1' program."
19868af480fSmrg      ;;
19968af480fSmrg  esac
20068af480fSmrg}
20168af480fSmrg
20268af480fSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20368af480fSmrg                       -e '2,$s/^/         /' >&2
20468af480fSmrg
20568af480fSmrg# Propagate the correct exit status (expected to be 127 for a program
20668af480fSmrg# not found, 63 for a program that failed due to version mismatch).
20768af480fSmrgexit $st
208d7accfefSmrg
209d7accfefSmrg# Local variables:
210d7accfefSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
211d7accfefSmrg# time-stamp-start: "scriptversion="
212d7accfefSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213d7accfefSmrg# time-stamp-time-zone: "UTC"
214d7accfefSmrg# time-stamp-end: "; # UTC"
215d7accfefSmrg# End:
216