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