missing revision 31637056
1a253d6aeSmrg#! /bin/sh
257ee1794Smrg# Common wrapper for a few potentially missing GNU programs.
3a253d6aeSmrg
431637056Smrgscriptversion=2013-10-28.13; # UTC
5a253d6aeSmrg
657ee1794Smrg# Copyright (C) 1996-2013 Free Software Foundation, Inc.
757ee1794Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8a253d6aeSmrg
9a253d6aeSmrg# This program is free software; you can redistribute it and/or modify
10a253d6aeSmrg# it under the terms of the GNU General Public License as published by
11a253d6aeSmrg# the Free Software Foundation; either version 2, or (at your option)
12a253d6aeSmrg# any later version.
13a253d6aeSmrg
14a253d6aeSmrg# This program is distributed in the hope that it will be useful,
15a253d6aeSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16a253d6aeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17a253d6aeSmrg# GNU General Public License for more details.
18a253d6aeSmrg
19a253d6aeSmrg# You should have received a copy of the GNU General Public License
2025b89263Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21a253d6aeSmrg
22a253d6aeSmrg# As a special exception to the GNU General Public License, if you
23a253d6aeSmrg# distribute this file as part of a program that contains a
24a253d6aeSmrg# configuration script generated by Autoconf, you may include it under
25a253d6aeSmrg# the same distribution terms that you use for the rest of that program.
26a253d6aeSmrg
27a253d6aeSmrgif test $# -eq 0; then
2857ee1794Smrg  echo 1>&2 "Try '$0 --help' for more information"
29a253d6aeSmrg  exit 1
30a253d6aeSmrgfi
31a253d6aeSmrg
3257ee1794Smrgcase $1 in
33a253d6aeSmrg
3457ee1794Smrg  --is-lightweight)
3557ee1794Smrg    # Used by our autoconf macros to check whether the available missing
3657ee1794Smrg    # script is modern enough.
3757ee1794Smrg    exit 0
3857ee1794Smrg    ;;
39a253d6aeSmrg
4057ee1794Smrg  --run)
4157ee1794Smrg    # Back-compat with the calling convention used by older automake.
4257ee1794Smrg    shift
4357ee1794Smrg    ;;
44a253d6aeSmrg
45a253d6aeSmrg  -h|--h|--he|--hel|--help)
46a253d6aeSmrg    echo "\
47a253d6aeSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48a253d6aeSmrg
4957ee1794SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5057ee1794Smrgto PROGRAM being missing or too old.
51a253d6aeSmrg
52a253d6aeSmrgOptions:
53a253d6aeSmrg  -h, --help      display this help and exit
54a253d6aeSmrg  -v, --version   output version information and exit
55a253d6aeSmrg
56a253d6aeSmrgSupported PROGRAM values:
5757ee1794Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5857ee1794Smrg  bison     yacc      flex         lex       help2man
59a253d6aeSmrg
6057ee1794SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6157ee1794Smrg'g' are ignored when checking the name.
6225b89263Smrg
63a253d6aeSmrgSend bug reports to <bug-automake@gnu.org>."
64a253d6aeSmrg    exit $?
65a253d6aeSmrg    ;;
66a253d6aeSmrg
67a253d6aeSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68a253d6aeSmrg    echo "missing $scriptversion (GNU Automake)"
69a253d6aeSmrg    exit $?
70a253d6aeSmrg    ;;
71a253d6aeSmrg
72a253d6aeSmrg  -*)
7357ee1794Smrg    echo 1>&2 "$0: unknown '$1' option"
7457ee1794Smrg    echo 1>&2 "Try '$0 --help' for more information"
75a253d6aeSmrg    exit 1
76a253d6aeSmrg    ;;
77a253d6aeSmrg
78a253d6aeSmrgesac
79a253d6aeSmrg
8057ee1794Smrg# Run the given program, remember its exit status.
8157ee1794Smrg"$@"; st=$?
8257ee1794Smrg
8357ee1794Smrg# If it succeeded, we are done.
8457ee1794Smrgtest $st -eq 0 && exit 0
8557ee1794Smrg
8657ee1794Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
8757ee1794Smrg# passed; such an option is passed most likely to detect whether the
8857ee1794Smrg# program is present and works.
8957ee1794Smrgcase $2 in --version|--help) exit $st;; esac
9057ee1794Smrg
9157ee1794Smrg# Exit code 63 means version mismatch.  This often happens when the user
9257ee1794Smrg# tries to use an ancient version of a tool on a file that requires a
9357ee1794Smrg# minimum version.
9457ee1794Smrgif test $st -eq 63; then
9557ee1794Smrg  msg="probably too old"
9657ee1794Smrgelif test $st -eq 127; then
9757ee1794Smrg  # Program was missing.
9857ee1794Smrg  msg="missing on your system"
9957ee1794Smrgelse
10057ee1794Smrg  # Program was found and executed, but failed.  Give up.
10157ee1794Smrg  exit $st
10257ee1794Smrgfi
103a253d6aeSmrg
10457ee1794Smrgperl_URL=http://www.perl.org/
10557ee1794Smrgflex_URL=http://flex.sourceforge.net/
10657ee1794Smrggnu_software_URL=http://www.gnu.org/software
10757ee1794Smrg
10857ee1794Smrgprogram_details ()
10957ee1794Smrg{
11057ee1794Smrg  case $1 in
11157ee1794Smrg    aclocal|automake)
11257ee1794Smrg      echo "The '$1' program is part of the GNU Automake package:"
11357ee1794Smrg      echo "<$gnu_software_URL/automake>"
11457ee1794Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11557ee1794Smrg      echo "<$gnu_software_URL/autoconf>"
11657ee1794Smrg      echo "<$gnu_software_URL/m4/>"
11757ee1794Smrg      echo "<$perl_URL>"
11857ee1794Smrg      ;;
11957ee1794Smrg    autoconf|autom4te|autoheader)
12057ee1794Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
12157ee1794Smrg      echo "<$gnu_software_URL/autoconf/>"
12257ee1794Smrg      echo "It also requires GNU m4 and Perl in order to run:"
12357ee1794Smrg      echo "<$gnu_software_URL/m4/>"
12457ee1794Smrg      echo "<$perl_URL>"
12557ee1794Smrg      ;;
12657ee1794Smrg  esac
12757ee1794Smrg}
12857ee1794Smrg
12957ee1794Smrggive_advice ()
13057ee1794Smrg{
13157ee1794Smrg  # Normalize program name to check for.
13257ee1794Smrg  normalized_program=`echo "$1" | sed '
13357ee1794Smrg    s/^gnu-//; t
13457ee1794Smrg    s/^gnu//; t
13557ee1794Smrg    s/^g//; t'`
13657ee1794Smrg
13757ee1794Smrg  printf '%s\n' "'$1' is $msg."
13857ee1794Smrg
13957ee1794Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14057ee1794Smrg  case $normalized_program in
14157ee1794Smrg    autoconf*)
14257ee1794Smrg      echo "You should only need it if you modified 'configure.ac',"
14357ee1794Smrg      echo "or m4 files included by it."
14457ee1794Smrg      program_details 'autoconf'
14557ee1794Smrg      ;;
14657ee1794Smrg    autoheader*)
14757ee1794Smrg      echo "You should only need it if you modified 'acconfig.h' or"
14857ee1794Smrg      echo "$configure_deps."
14957ee1794Smrg      program_details 'autoheader'
15057ee1794Smrg      ;;
15157ee1794Smrg    automake*)
15257ee1794Smrg      echo "You should only need it if you modified 'Makefile.am' or"
15357ee1794Smrg      echo "$configure_deps."
15457ee1794Smrg      program_details 'automake'
15557ee1794Smrg      ;;
15657ee1794Smrg    aclocal*)
15757ee1794Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
15857ee1794Smrg      echo "$configure_deps."
15957ee1794Smrg      program_details 'aclocal'
16057ee1794Smrg      ;;
16157ee1794Smrg   autom4te*)
16257ee1794Smrg      echo "You might have modified some maintainer files that require"
16331637056Smrg      echo "the 'autom4te' program to be rebuilt."
16457ee1794Smrg      program_details 'autom4te'
16557ee1794Smrg      ;;
16657ee1794Smrg    bison*|yacc*)
16757ee1794Smrg      echo "You should only need it if you modified a '.y' file."
16857ee1794Smrg      echo "You may want to install the GNU Bison package:"
16957ee1794Smrg      echo "<$gnu_software_URL/bison/>"
17057ee1794Smrg      ;;
17157ee1794Smrg    lex*|flex*)
17257ee1794Smrg      echo "You should only need it if you modified a '.l' file."
17357ee1794Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
17457ee1794Smrg      echo "<$flex_URL>"
17557ee1794Smrg      ;;
17657ee1794Smrg    help2man*)
17757ee1794Smrg      echo "You should only need it if you modified a dependency" \
17857ee1794Smrg           "of a man page."
17957ee1794Smrg      echo "You may want to install the GNU Help2man package:"
18057ee1794Smrg      echo "<$gnu_software_URL/help2man/>"
18157ee1794Smrg    ;;
18257ee1794Smrg    makeinfo*)
18357ee1794Smrg      echo "You should only need it if you modified a '.texi' file, or"
18457ee1794Smrg      echo "any other file indirectly affecting the aspect of the manual."
18557ee1794Smrg      echo "You might want to install the Texinfo package:"
18657ee1794Smrg      echo "<$gnu_software_URL/texinfo/>"
18757ee1794Smrg      echo "The spurious makeinfo call might also be the consequence of"
18857ee1794Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18957ee1794Smrg      echo "want to install GNU make:"
19057ee1794Smrg      echo "<$gnu_software_URL/make/>"
19157ee1794Smrg      ;;
19257ee1794Smrg    *)
19357ee1794Smrg      echo "You might have modified some files without having the proper"
19457ee1794Smrg      echo "tools for further handling them.  Check the 'README' file, it"
19557ee1794Smrg      echo "often tells you about the needed prerequisites for installing"
19657ee1794Smrg      echo "this package.  You may also peek at any GNU archive site, in"
19757ee1794Smrg      echo "case some other package contains this missing '$1' program."
19857ee1794Smrg      ;;
19957ee1794Smrg  esac
20057ee1794Smrg}
20157ee1794Smrg
20257ee1794Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20357ee1794Smrg                       -e '2,$s/^/         /' >&2
20457ee1794Smrg
20557ee1794Smrg# Propagate the correct exit status (expected to be 127 for a program
20657ee1794Smrg# not found, 63 for a program that failed due to version mismatch).
20757ee1794Smrgexit $st
208a253d6aeSmrg
209a253d6aeSmrg# Local variables:
210a253d6aeSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
211a253d6aeSmrg# time-stamp-start: "scriptversion="
212a253d6aeSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
21325b89263Smrg# time-stamp-time-zone: "UTC"
21425b89263Smrg# time-stamp-end: "; # UTC"
215a253d6aeSmrg# End:
216