missing revision e7c933f3
1cbeba4aeSmrg#! /bin/sh
2e7c933f3Smrg# Common wrapper for a few potentially missing GNU programs.
37bd0f98dSmrg
4e7c933f3Smrgscriptversion=2013-10-28.13; # UTC
57bd0f98dSmrg
6e7c933f3Smrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
7e7c933f3Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8cbeba4aeSmrg
9cbeba4aeSmrg# This program is free software; you can redistribute it and/or modify
10cbeba4aeSmrg# it under the terms of the GNU General Public License as published by
11cbeba4aeSmrg# the Free Software Foundation; either version 2, or (at your option)
12cbeba4aeSmrg# any later version.
13cbeba4aeSmrg
14cbeba4aeSmrg# This program is distributed in the hope that it will be useful,
15cbeba4aeSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16cbeba4aeSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17cbeba4aeSmrg# GNU General Public License for more details.
18cbeba4aeSmrg
19cbeba4aeSmrg# You should have received a copy of the GNU General Public License
207bd0f98dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21cbeba4aeSmrg
22cbeba4aeSmrg# As a special exception to the GNU General Public License, if you
23cbeba4aeSmrg# distribute this file as part of a program that contains a
24cbeba4aeSmrg# configuration script generated by Autoconf, you may include it under
25cbeba4aeSmrg# the same distribution terms that you use for the rest of that program.
26cbeba4aeSmrg
27cbeba4aeSmrgif test $# -eq 0; then
28e7c933f3Smrg  echo 1>&2 "Try '$0 --help' for more information"
29cbeba4aeSmrg  exit 1
30cbeba4aeSmrgfi
31cbeba4aeSmrg
32e7c933f3Smrgcase $1 in
33cbeba4aeSmrg
34e7c933f3Smrg  --is-lightweight)
35e7c933f3Smrg    # Used by our autoconf macros to check whether the available missing
36e7c933f3Smrg    # script is modern enough.
37e7c933f3Smrg    exit 0
38e7c933f3Smrg    ;;
397bd0f98dSmrg
40e7c933f3Smrg  --run)
41e7c933f3Smrg    # Back-compat with the calling convention used by older automake.
42e7c933f3Smrg    shift
43e7c933f3Smrg    ;;
44cbeba4aeSmrg
45cbeba4aeSmrg  -h|--h|--he|--hel|--help)
46cbeba4aeSmrg    echo "\
47cbeba4aeSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48cbeba4aeSmrg
49e7c933f3SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50e7c933f3Smrgto PROGRAM being missing or too old.
51cbeba4aeSmrg
52cbeba4aeSmrgOptions:
53cbeba4aeSmrg  -h, --help      display this help and exit
54cbeba4aeSmrg  -v, --version   output version information and exit
55cbeba4aeSmrg
56cbeba4aeSmrgSupported PROGRAM values:
57e7c933f3Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58e7c933f3Smrg  bison     yacc      flex         lex       help2man
597bd0f98dSmrg
60e7c933f3SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61e7c933f3Smrg'g' are ignored when checking the name.
627bd0f98dSmrg
637bd0f98dSmrgSend bug reports to <bug-automake@gnu.org>."
647bd0f98dSmrg    exit $?
65cbeba4aeSmrg    ;;
66cbeba4aeSmrg
67cbeba4aeSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
687bd0f98dSmrg    echo "missing $scriptversion (GNU Automake)"
697bd0f98dSmrg    exit $?
70cbeba4aeSmrg    ;;
71cbeba4aeSmrg
72cbeba4aeSmrg  -*)
73e7c933f3Smrg    echo 1>&2 "$0: unknown '$1' option"
74e7c933f3Smrg    echo 1>&2 "Try '$0 --help' for more information"
75cbeba4aeSmrg    exit 1
76cbeba4aeSmrg    ;;
77cbeba4aeSmrg
787bd0f98dSmrgesac
797bd0f98dSmrg
80e7c933f3Smrg# Run the given program, remember its exit status.
81e7c933f3Smrg"$@"; st=$?
82e7c933f3Smrg
83e7c933f3Smrg# If it succeeded, we are done.
84e7c933f3Smrgtest $st -eq 0 && exit 0
85e7c933f3Smrg
86e7c933f3Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
87e7c933f3Smrg# passed; such an option is passed most likely to detect whether the
88e7c933f3Smrg# program is present and works.
89e7c933f3Smrgcase $2 in --version|--help) exit $st;; esac
90e7c933f3Smrg
91e7c933f3Smrg# Exit code 63 means version mismatch.  This often happens when the user
92e7c933f3Smrg# tries to use an ancient version of a tool on a file that requires a
93e7c933f3Smrg# minimum version.
94e7c933f3Smrgif test $st -eq 63; then
95e7c933f3Smrg  msg="probably too old"
96e7c933f3Smrgelif test $st -eq 127; then
97e7c933f3Smrg  # Program was missing.
98e7c933f3Smrg  msg="missing on your system"
99e7c933f3Smrgelse
100e7c933f3Smrg  # Program was found and executed, but failed.  Give up.
101e7c933f3Smrg  exit $st
102e7c933f3Smrgfi
103cbeba4aeSmrg
104e7c933f3Smrgperl_URL=http://www.perl.org/
105e7c933f3Smrgflex_URL=http://flex.sourceforge.net/
106e7c933f3Smrggnu_software_URL=http://www.gnu.org/software
107e7c933f3Smrg
108e7c933f3Smrgprogram_details ()
109e7c933f3Smrg{
110e7c933f3Smrg  case $1 in
111e7c933f3Smrg    aclocal|automake)
112e7c933f3Smrg      echo "The '$1' program is part of the GNU Automake package:"
113e7c933f3Smrg      echo "<$gnu_software_URL/automake>"
114e7c933f3Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115e7c933f3Smrg      echo "<$gnu_software_URL/autoconf>"
116e7c933f3Smrg      echo "<$gnu_software_URL/m4/>"
117e7c933f3Smrg      echo "<$perl_URL>"
118e7c933f3Smrg      ;;
119e7c933f3Smrg    autoconf|autom4te|autoheader)
120e7c933f3Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
121e7c933f3Smrg      echo "<$gnu_software_URL/autoconf/>"
122e7c933f3Smrg      echo "It also requires GNU m4 and Perl in order to run:"
123e7c933f3Smrg      echo "<$gnu_software_URL/m4/>"
124e7c933f3Smrg      echo "<$perl_URL>"
125e7c933f3Smrg      ;;
126e7c933f3Smrg  esac
127e7c933f3Smrg}
128e7c933f3Smrg
129e7c933f3Smrggive_advice ()
130e7c933f3Smrg{
131e7c933f3Smrg  # Normalize program name to check for.
132e7c933f3Smrg  normalized_program=`echo "$1" | sed '
133e7c933f3Smrg    s/^gnu-//; t
134e7c933f3Smrg    s/^gnu//; t
135e7c933f3Smrg    s/^g//; t'`
136e7c933f3Smrg
137e7c933f3Smrg  printf '%s\n' "'$1' is $msg."
138e7c933f3Smrg
139e7c933f3Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140e7c933f3Smrg  case $normalized_program in
141e7c933f3Smrg    autoconf*)
142e7c933f3Smrg      echo "You should only need it if you modified 'configure.ac',"
143e7c933f3Smrg      echo "or m4 files included by it."
144e7c933f3Smrg      program_details 'autoconf'
145e7c933f3Smrg      ;;
146e7c933f3Smrg    autoheader*)
147e7c933f3Smrg      echo "You should only need it if you modified 'acconfig.h' or"
148e7c933f3Smrg      echo "$configure_deps."
149e7c933f3Smrg      program_details 'autoheader'
150e7c933f3Smrg      ;;
151e7c933f3Smrg    automake*)
152e7c933f3Smrg      echo "You should only need it if you modified 'Makefile.am' or"
153e7c933f3Smrg      echo "$configure_deps."
154e7c933f3Smrg      program_details 'automake'
155e7c933f3Smrg      ;;
156e7c933f3Smrg    aclocal*)
157e7c933f3Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
158e7c933f3Smrg      echo "$configure_deps."
159e7c933f3Smrg      program_details 'aclocal'
160e7c933f3Smrg      ;;
161e7c933f3Smrg   autom4te*)
162e7c933f3Smrg      echo "You might have modified some maintainer files that require"
163e7c933f3Smrg      echo "the 'autom4te' program to be rebuilt."
164e7c933f3Smrg      program_details 'autom4te'
165e7c933f3Smrg      ;;
166e7c933f3Smrg    bison*|yacc*)
167e7c933f3Smrg      echo "You should only need it if you modified a '.y' file."
168e7c933f3Smrg      echo "You may want to install the GNU Bison package:"
169e7c933f3Smrg      echo "<$gnu_software_URL/bison/>"
170e7c933f3Smrg      ;;
171e7c933f3Smrg    lex*|flex*)
172e7c933f3Smrg      echo "You should only need it if you modified a '.l' file."
173e7c933f3Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
174e7c933f3Smrg      echo "<$flex_URL>"
175e7c933f3Smrg      ;;
176e7c933f3Smrg    help2man*)
177e7c933f3Smrg      echo "You should only need it if you modified a dependency" \
178e7c933f3Smrg           "of a man page."
179e7c933f3Smrg      echo "You may want to install the GNU Help2man package:"
180e7c933f3Smrg      echo "<$gnu_software_URL/help2man/>"
181e7c933f3Smrg    ;;
182e7c933f3Smrg    makeinfo*)
183e7c933f3Smrg      echo "You should only need it if you modified a '.texi' file, or"
184e7c933f3Smrg      echo "any other file indirectly affecting the aspect of the manual."
185e7c933f3Smrg      echo "You might want to install the Texinfo package:"
186e7c933f3Smrg      echo "<$gnu_software_URL/texinfo/>"
187e7c933f3Smrg      echo "The spurious makeinfo call might also be the consequence of"
188e7c933f3Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189e7c933f3Smrg      echo "want to install GNU make:"
190e7c933f3Smrg      echo "<$gnu_software_URL/make/>"
191e7c933f3Smrg      ;;
192e7c933f3Smrg    *)
193e7c933f3Smrg      echo "You might have modified some files without having the proper"
194e7c933f3Smrg      echo "tools for further handling them.  Check the 'README' file, it"
195e7c933f3Smrg      echo "often tells you about the needed prerequisites for installing"
196e7c933f3Smrg      echo "this package.  You may also peek at any GNU archive site, in"
197e7c933f3Smrg      echo "case some other package contains this missing '$1' program."
198e7c933f3Smrg      ;;
199e7c933f3Smrg  esac
200e7c933f3Smrg}
201e7c933f3Smrg
202e7c933f3Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203e7c933f3Smrg                       -e '2,$s/^/         /' >&2
204e7c933f3Smrg
205e7c933f3Smrg# Propagate the correct exit status (expected to be 127 for a program
206e7c933f3Smrg# not found, 63 for a program that failed due to version mismatch).
207e7c933f3Smrgexit $st
2087bd0f98dSmrg
2097bd0f98dSmrg# Local variables:
2107bd0f98dSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
2117bd0f98dSmrg# time-stamp-start: "scriptversion="
2127bd0f98dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
2137bd0f98dSmrg# time-stamp-time-zone: "UTC"
2147bd0f98dSmrg# time-stamp-end: "; # UTC"
2157bd0f98dSmrg# End:
216