1267843Sdelphij#! /bin/sh
2267843Sdelphij# Common wrapper for a few potentially missing GNU programs.
3267843Sdelphij
4284778Sdelphijscriptversion=2013-10-28.13; # UTC
5267843Sdelphij
6284778Sdelphij# Copyright (C) 1996-2014 Free Software Foundation, Inc.
7267843Sdelphij# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8267843Sdelphij
9267843Sdelphij# This program is free software; you can redistribute it and/or modify
10267843Sdelphij# it under the terms of the GNU General Public License as published by
11267843Sdelphij# the Free Software Foundation; either version 2, or (at your option)
12267843Sdelphij# any later version.
13267843Sdelphij
14267843Sdelphij# This program is distributed in the hope that it will be useful,
15267843Sdelphij# but WITHOUT ANY WARRANTY; without even the implied warranty of
16267843Sdelphij# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17267843Sdelphij# GNU General Public License for more details.
18267843Sdelphij
19267843Sdelphij# You should have received a copy of the GNU General Public License
20267843Sdelphij# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21267843Sdelphij
22267843Sdelphij# As a special exception to the GNU General Public License, if you
23267843Sdelphij# distribute this file as part of a program that contains a
24267843Sdelphij# configuration script generated by Autoconf, you may include it under
25267843Sdelphij# the same distribution terms that you use for the rest of that program.
26267843Sdelphij
27267843Sdelphijif test $# -eq 0; then
28267843Sdelphij  echo 1>&2 "Try '$0 --help' for more information"
29267843Sdelphij  exit 1
30267843Sdelphijfi
31267843Sdelphij
32267843Sdelphijcase $1 in
33267843Sdelphij
34267843Sdelphij  --is-lightweight)
35267843Sdelphij    # Used by our autoconf macros to check whether the available missing
36267843Sdelphij    # script is modern enough.
37267843Sdelphij    exit 0
38267843Sdelphij    ;;
39267843Sdelphij
40267843Sdelphij  --run)
41267843Sdelphij    # Back-compat with the calling convention used by older automake.
42267843Sdelphij    shift
43267843Sdelphij    ;;
44267843Sdelphij
45267843Sdelphij  -h|--h|--he|--hel|--help)
46267843Sdelphij    echo "\
47267843Sdelphij$0 [OPTION]... PROGRAM [ARGUMENT]...
48267843Sdelphij
49267843SdelphijRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50267843Sdelphijto PROGRAM being missing or too old.
51267843Sdelphij
52267843SdelphijOptions:
53267843Sdelphij  -h, --help      display this help and exit
54267843Sdelphij  -v, --version   output version information and exit
55267843Sdelphij
56267843SdelphijSupported PROGRAM values:
57267843Sdelphij  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58267843Sdelphij  bison     yacc      flex         lex       help2man
59267843Sdelphij
60267843SdelphijVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61267843Sdelphij'g' are ignored when checking the name.
62267843Sdelphij
63267843SdelphijSend bug reports to <bug-automake@gnu.org>."
64267843Sdelphij    exit $?
65267843Sdelphij    ;;
66267843Sdelphij
67267843Sdelphij  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68267843Sdelphij    echo "missing $scriptversion (GNU Automake)"
69267843Sdelphij    exit $?
70267843Sdelphij    ;;
71267843Sdelphij
72267843Sdelphij  -*)
73267843Sdelphij    echo 1>&2 "$0: unknown '$1' option"
74267843Sdelphij    echo 1>&2 "Try '$0 --help' for more information"
75267843Sdelphij    exit 1
76267843Sdelphij    ;;
77267843Sdelphij
78267843Sdelphijesac
79267843Sdelphij
80267843Sdelphij# Run the given program, remember its exit status.
81267843Sdelphij"$@"; st=$?
82267843Sdelphij
83267843Sdelphij# If it succeeded, we are done.
84267843Sdelphijtest $st -eq 0 && exit 0
85267843Sdelphij
86267843Sdelphij# Also exit now if we it failed (or wasn't found), and '--version' was
87267843Sdelphij# passed; such an option is passed most likely to detect whether the
88267843Sdelphij# program is present and works.
89267843Sdelphijcase $2 in --version|--help) exit $st;; esac
90267843Sdelphij
91267843Sdelphij# Exit code 63 means version mismatch.  This often happens when the user
92267843Sdelphij# tries to use an ancient version of a tool on a file that requires a
93267843Sdelphij# minimum version.
94267843Sdelphijif test $st -eq 63; then
95267843Sdelphij  msg="probably too old"
96267843Sdelphijelif test $st -eq 127; then
97267843Sdelphij  # Program was missing.
98267843Sdelphij  msg="missing on your system"
99267843Sdelphijelse
100267843Sdelphij  # Program was found and executed, but failed.  Give up.
101267843Sdelphij  exit $st
102267843Sdelphijfi
103267843Sdelphij
104267843Sdelphijperl_URL=http://www.perl.org/
105267843Sdelphijflex_URL=http://flex.sourceforge.net/
106267843Sdelphijgnu_software_URL=http://www.gnu.org/software
107267843Sdelphij
108267843Sdelphijprogram_details ()
109267843Sdelphij{
110267843Sdelphij  case $1 in
111267843Sdelphij    aclocal|automake)
112267843Sdelphij      echo "The '$1' program is part of the GNU Automake package:"
113267843Sdelphij      echo "<$gnu_software_URL/automake>"
114267843Sdelphij      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115267843Sdelphij      echo "<$gnu_software_URL/autoconf>"
116267843Sdelphij      echo "<$gnu_software_URL/m4/>"
117267843Sdelphij      echo "<$perl_URL>"
118267843Sdelphij      ;;
119267843Sdelphij    autoconf|autom4te|autoheader)
120267843Sdelphij      echo "The '$1' program is part of the GNU Autoconf package:"
121267843Sdelphij      echo "<$gnu_software_URL/autoconf/>"
122267843Sdelphij      echo "It also requires GNU m4 and Perl in order to run:"
123267843Sdelphij      echo "<$gnu_software_URL/m4/>"
124267843Sdelphij      echo "<$perl_URL>"
125267843Sdelphij      ;;
126267843Sdelphij  esac
127267843Sdelphij}
128267843Sdelphij
129267843Sdelphijgive_advice ()
130267843Sdelphij{
131267843Sdelphij  # Normalize program name to check for.
132267843Sdelphij  normalized_program=`echo "$1" | sed '
133267843Sdelphij    s/^gnu-//; t
134267843Sdelphij    s/^gnu//; t
135267843Sdelphij    s/^g//; t'`
136267843Sdelphij
137267843Sdelphij  printf '%s\n' "'$1' is $msg."
138267843Sdelphij
139267843Sdelphij  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140267843Sdelphij  case $normalized_program in
141267843Sdelphij    autoconf*)
142267843Sdelphij      echo "You should only need it if you modified 'configure.ac',"
143267843Sdelphij      echo "or m4 files included by it."
144267843Sdelphij      program_details 'autoconf'
145267843Sdelphij      ;;
146267843Sdelphij    autoheader*)
147267843Sdelphij      echo "You should only need it if you modified 'acconfig.h' or"
148267843Sdelphij      echo "$configure_deps."
149267843Sdelphij      program_details 'autoheader'
150267843Sdelphij      ;;
151267843Sdelphij    automake*)
152267843Sdelphij      echo "You should only need it if you modified 'Makefile.am' or"
153267843Sdelphij      echo "$configure_deps."
154267843Sdelphij      program_details 'automake'
155267843Sdelphij      ;;
156267843Sdelphij    aclocal*)
157267843Sdelphij      echo "You should only need it if you modified 'acinclude.m4' or"
158267843Sdelphij      echo "$configure_deps."
159267843Sdelphij      program_details 'aclocal'
160267843Sdelphij      ;;
161267843Sdelphij   autom4te*)
162267843Sdelphij      echo "You might have modified some maintainer files that require"
163284778Sdelphij      echo "the 'autom4te' program to be rebuilt."
164267843Sdelphij      program_details 'autom4te'
165267843Sdelphij      ;;
166267843Sdelphij    bison*|yacc*)
167267843Sdelphij      echo "You should only need it if you modified a '.y' file."
168267843Sdelphij      echo "You may want to install the GNU Bison package:"
169267843Sdelphij      echo "<$gnu_software_URL/bison/>"
170267843Sdelphij      ;;
171267843Sdelphij    lex*|flex*)
172267843Sdelphij      echo "You should only need it if you modified a '.l' file."
173267843Sdelphij      echo "You may want to install the Fast Lexical Analyzer package:"
174267843Sdelphij      echo "<$flex_URL>"
175267843Sdelphij      ;;
176267843Sdelphij    help2man*)
177267843Sdelphij      echo "You should only need it if you modified a dependency" \
178267843Sdelphij           "of a man page."
179267843Sdelphij      echo "You may want to install the GNU Help2man package:"
180267843Sdelphij      echo "<$gnu_software_URL/help2man/>"
181267843Sdelphij    ;;
182267843Sdelphij    makeinfo*)
183267843Sdelphij      echo "You should only need it if you modified a '.texi' file, or"
184267843Sdelphij      echo "any other file indirectly affecting the aspect of the manual."
185267843Sdelphij      echo "You might want to install the Texinfo package:"
186267843Sdelphij      echo "<$gnu_software_URL/texinfo/>"
187267843Sdelphij      echo "The spurious makeinfo call might also be the consequence of"
188267843Sdelphij      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189267843Sdelphij      echo "want to install GNU make:"
190267843Sdelphij      echo "<$gnu_software_URL/make/>"
191267843Sdelphij      ;;
192267843Sdelphij    *)
193267843Sdelphij      echo "You might have modified some files without having the proper"
194267843Sdelphij      echo "tools for further handling them.  Check the 'README' file, it"
195267843Sdelphij      echo "often tells you about the needed prerequisites for installing"
196267843Sdelphij      echo "this package.  You may also peek at any GNU archive site, in"
197267843Sdelphij      echo "case some other package contains this missing '$1' program."
198267843Sdelphij      ;;
199267843Sdelphij  esac
200267843Sdelphij}
201267843Sdelphij
202267843Sdelphijgive_advice "$1" | sed -e '1s/^/WARNING: /' \
203267843Sdelphij                       -e '2,$s/^/         /' >&2
204267843Sdelphij
205267843Sdelphij# Propagate the correct exit status (expected to be 127 for a program
206267843Sdelphij# not found, 63 for a program that failed due to version mismatch).
207267843Sdelphijexit $st
208267843Sdelphij
209267843Sdelphij# Local variables:
210267843Sdelphij# eval: (add-hook 'write-file-hooks 'time-stamp)
211267843Sdelphij# time-stamp-start: "scriptversion="
212267843Sdelphij# time-stamp-format: "%:y-%02m-%02d.%02H"
213267843Sdelphij# time-stamp-time-zone: "UTC"
214267843Sdelphij# time-stamp-end: "; # UTC"
215267843Sdelphij# End:
216