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