missing revision 19d64aee
14d9b34d9Smrg#! /bin/sh
219d64aeeSmrg# Common wrapper for a few potentially missing GNU programs.
34d9b34d9Smrg
419d64aeeSmrgscriptversion=2013-10-28.13; # UTC
54d9b34d9Smrg
619d64aeeSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
719d64aeeSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
84d9b34d9Smrg
94d9b34d9Smrg# This program is free software; you can redistribute it and/or modify
104d9b34d9Smrg# it under the terms of the GNU General Public License as published by
114d9b34d9Smrg# the Free Software Foundation; either version 2, or (at your option)
124d9b34d9Smrg# any later version.
134d9b34d9Smrg
144d9b34d9Smrg# This program is distributed in the hope that it will be useful,
154d9b34d9Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
164d9b34d9Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174d9b34d9Smrg# GNU General Public License for more details.
184d9b34d9Smrg
194d9b34d9Smrg# You should have received a copy of the GNU General Public License
208512f934Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
214d9b34d9Smrg
224d9b34d9Smrg# As a special exception to the GNU General Public License, if you
234d9b34d9Smrg# distribute this file as part of a program that contains a
244d9b34d9Smrg# configuration script generated by Autoconf, you may include it under
254d9b34d9Smrg# the same distribution terms that you use for the rest of that program.
264d9b34d9Smrg
274d9b34d9Smrgif test $# -eq 0; then
2819d64aeeSmrg  echo 1>&2 "Try '$0 --help' for more information"
294d9b34d9Smrg  exit 1
304d9b34d9Smrgfi
314d9b34d9Smrg
3219d64aeeSmrgcase $1 in
334d9b34d9Smrg
3419d64aeeSmrg  --is-lightweight)
3519d64aeeSmrg    # Used by our autoconf macros to check whether the available missing
3619d64aeeSmrg    # script is modern enough.
3719d64aeeSmrg    exit 0
3819d64aeeSmrg    ;;
394d9b34d9Smrg
4019d64aeeSmrg  --run)
4119d64aeeSmrg    # Back-compat with the calling convention used by older automake.
4219d64aeeSmrg    shift
4319d64aeeSmrg    ;;
444d9b34d9Smrg
454d9b34d9Smrg  -h|--h|--he|--hel|--help)
464d9b34d9Smrg    echo "\
474d9b34d9Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
484d9b34d9Smrg
4919d64aeeSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5019d64aeeSmrgto PROGRAM being missing or too old.
514d9b34d9Smrg
524d9b34d9SmrgOptions:
534d9b34d9Smrg  -h, --help      display this help and exit
544d9b34d9Smrg  -v, --version   output version information and exit
554d9b34d9Smrg
564d9b34d9SmrgSupported PROGRAM values:
5719d64aeeSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5819d64aeeSmrg  bison     yacc      flex         lex       help2man
594d9b34d9Smrg
6019d64aeeSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6119d64aeeSmrg'g' are ignored when checking the name.
628512f934Smrg
634d9b34d9SmrgSend bug reports to <bug-automake@gnu.org>."
644d9b34d9Smrg    exit $?
654d9b34d9Smrg    ;;
664d9b34d9Smrg
674d9b34d9Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
684d9b34d9Smrg    echo "missing $scriptversion (GNU Automake)"
694d9b34d9Smrg    exit $?
704d9b34d9Smrg    ;;
714d9b34d9Smrg
724d9b34d9Smrg  -*)
7319d64aeeSmrg    echo 1>&2 "$0: unknown '$1' option"
7419d64aeeSmrg    echo 1>&2 "Try '$0 --help' for more information"
754d9b34d9Smrg    exit 1
764d9b34d9Smrg    ;;
774d9b34d9Smrg
784d9b34d9Smrgesac
794d9b34d9Smrg
8019d64aeeSmrg# Run the given program, remember its exit status.
8119d64aeeSmrg"$@"; st=$?
8219d64aeeSmrg
8319d64aeeSmrg# If it succeeded, we are done.
8419d64aeeSmrgtest $st -eq 0 && exit 0
8519d64aeeSmrg
8619d64aeeSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
8719d64aeeSmrg# passed; such an option is passed most likely to detect whether the
8819d64aeeSmrg# program is present and works.
8919d64aeeSmrgcase $2 in --version|--help) exit $st;; esac
9019d64aeeSmrg
9119d64aeeSmrg# Exit code 63 means version mismatch.  This often happens when the user
9219d64aeeSmrg# tries to use an ancient version of a tool on a file that requires a
9319d64aeeSmrg# minimum version.
9419d64aeeSmrgif test $st -eq 63; then
9519d64aeeSmrg  msg="probably too old"
9619d64aeeSmrgelif test $st -eq 127; then
9719d64aeeSmrg  # Program was missing.
9819d64aeeSmrg  msg="missing on your system"
9919d64aeeSmrgelse
10019d64aeeSmrg  # Program was found and executed, but failed.  Give up.
10119d64aeeSmrg  exit $st
10219d64aeeSmrgfi
1034d9b34d9Smrg
10419d64aeeSmrgperl_URL=http://www.perl.org/
10519d64aeeSmrgflex_URL=http://flex.sourceforge.net/
10619d64aeeSmrggnu_software_URL=http://www.gnu.org/software
10719d64aeeSmrg
10819d64aeeSmrgprogram_details ()
10919d64aeeSmrg{
11019d64aeeSmrg  case $1 in
11119d64aeeSmrg    aclocal|automake)
11219d64aeeSmrg      echo "The '$1' program is part of the GNU Automake package:"
11319d64aeeSmrg      echo "<$gnu_software_URL/automake>"
11419d64aeeSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11519d64aeeSmrg      echo "<$gnu_software_URL/autoconf>"
11619d64aeeSmrg      echo "<$gnu_software_URL/m4/>"
11719d64aeeSmrg      echo "<$perl_URL>"
11819d64aeeSmrg      ;;
11919d64aeeSmrg    autoconf|autom4te|autoheader)
12019d64aeeSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
12119d64aeeSmrg      echo "<$gnu_software_URL/autoconf/>"
12219d64aeeSmrg      echo "It also requires GNU m4 and Perl in order to run:"
12319d64aeeSmrg      echo "<$gnu_software_URL/m4/>"
12419d64aeeSmrg      echo "<$perl_URL>"
12519d64aeeSmrg      ;;
12619d64aeeSmrg  esac
12719d64aeeSmrg}
12819d64aeeSmrg
12919d64aeeSmrggive_advice ()
13019d64aeeSmrg{
13119d64aeeSmrg  # Normalize program name to check for.
13219d64aeeSmrg  normalized_program=`echo "$1" | sed '
13319d64aeeSmrg    s/^gnu-//; t
13419d64aeeSmrg    s/^gnu//; t
13519d64aeeSmrg    s/^g//; t'`
13619d64aeeSmrg
13719d64aeeSmrg  printf '%s\n' "'$1' is $msg."
13819d64aeeSmrg
13919d64aeeSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14019d64aeeSmrg  case $normalized_program in
14119d64aeeSmrg    autoconf*)
14219d64aeeSmrg      echo "You should only need it if you modified 'configure.ac',"
14319d64aeeSmrg      echo "or m4 files included by it."
14419d64aeeSmrg      program_details 'autoconf'
14519d64aeeSmrg      ;;
14619d64aeeSmrg    autoheader*)
14719d64aeeSmrg      echo "You should only need it if you modified 'acconfig.h' or"
14819d64aeeSmrg      echo "$configure_deps."
14919d64aeeSmrg      program_details 'autoheader'
15019d64aeeSmrg      ;;
15119d64aeeSmrg    automake*)
15219d64aeeSmrg      echo "You should only need it if you modified 'Makefile.am' or"
15319d64aeeSmrg      echo "$configure_deps."
15419d64aeeSmrg      program_details 'automake'
15519d64aeeSmrg      ;;
15619d64aeeSmrg    aclocal*)
15719d64aeeSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
15819d64aeeSmrg      echo "$configure_deps."
15919d64aeeSmrg      program_details 'aclocal'
16019d64aeeSmrg      ;;
16119d64aeeSmrg   autom4te*)
16219d64aeeSmrg      echo "You might have modified some maintainer files that require"
16319d64aeeSmrg      echo "the 'autom4te' program to be rebuilt."
16419d64aeeSmrg      program_details 'autom4te'
16519d64aeeSmrg      ;;
16619d64aeeSmrg    bison*|yacc*)
16719d64aeeSmrg      echo "You should only need it if you modified a '.y' file."
16819d64aeeSmrg      echo "You may want to install the GNU Bison package:"
16919d64aeeSmrg      echo "<$gnu_software_URL/bison/>"
17019d64aeeSmrg      ;;
17119d64aeeSmrg    lex*|flex*)
17219d64aeeSmrg      echo "You should only need it if you modified a '.l' file."
17319d64aeeSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
17419d64aeeSmrg      echo "<$flex_URL>"
17519d64aeeSmrg      ;;
17619d64aeeSmrg    help2man*)
17719d64aeeSmrg      echo "You should only need it if you modified a dependency" \
17819d64aeeSmrg           "of a man page."
17919d64aeeSmrg      echo "You may want to install the GNU Help2man package:"
18019d64aeeSmrg      echo "<$gnu_software_URL/help2man/>"
18119d64aeeSmrg    ;;
18219d64aeeSmrg    makeinfo*)
18319d64aeeSmrg      echo "You should only need it if you modified a '.texi' file, or"
18419d64aeeSmrg      echo "any other file indirectly affecting the aspect of the manual."
18519d64aeeSmrg      echo "You might want to install the Texinfo package:"
18619d64aeeSmrg      echo "<$gnu_software_URL/texinfo/>"
18719d64aeeSmrg      echo "The spurious makeinfo call might also be the consequence of"
18819d64aeeSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18919d64aeeSmrg      echo "want to install GNU make:"
19019d64aeeSmrg      echo "<$gnu_software_URL/make/>"
19119d64aeeSmrg      ;;
19219d64aeeSmrg    *)
19319d64aeeSmrg      echo "You might have modified some files without having the proper"
19419d64aeeSmrg      echo "tools for further handling them.  Check the 'README' file, it"
19519d64aeeSmrg      echo "often tells you about the needed prerequisites for installing"
19619d64aeeSmrg      echo "this package.  You may also peek at any GNU archive site, in"
19719d64aeeSmrg      echo "case some other package contains this missing '$1' program."
19819d64aeeSmrg      ;;
19919d64aeeSmrg  esac
20019d64aeeSmrg}
20119d64aeeSmrg
20219d64aeeSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20319d64aeeSmrg                       -e '2,$s/^/         /' >&2
20419d64aeeSmrg
20519d64aeeSmrg# Propagate the correct exit status (expected to be 127 for a program
20619d64aeeSmrg# not found, 63 for a program that failed due to version mismatch).
20719d64aeeSmrgexit $st
2084d9b34d9Smrg
2094d9b34d9Smrg# Local variables:
2104d9b34d9Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
2114d9b34d9Smrg# time-stamp-start: "scriptversion="
2124d9b34d9Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
2138512f934Smrg# time-stamp-time-zone: "UTC"
2148512f934Smrg# time-stamp-end: "; # UTC"
2154d9b34d9Smrg# End:
216