123a0898aSmrg#! /bin/sh
2b020570bSmrg# Common wrapper for a few potentially missing GNU programs.
323a0898aSmrg
40145ab54Ssnjscriptversion=2013-10-28.13; # UTC
523a0898aSmrg
6121a5469Smrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
7b020570bSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
823a0898aSmrg
923a0898aSmrg# This program is free software; you can redistribute it and/or modify
1023a0898aSmrg# it under the terms of the GNU General Public License as published by
1123a0898aSmrg# the Free Software Foundation; either version 2, or (at your option)
1223a0898aSmrg# any later version.
1323a0898aSmrg
1423a0898aSmrg# This program is distributed in the hope that it will be useful,
1523a0898aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1623a0898aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1723a0898aSmrg# GNU General Public License for more details.
1823a0898aSmrg
1923a0898aSmrg# You should have received a copy of the GNU General Public License
2041c30155Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2123a0898aSmrg
2223a0898aSmrg# As a special exception to the GNU General Public License, if you
2323a0898aSmrg# distribute this file as part of a program that contains a
2423a0898aSmrg# configuration script generated by Autoconf, you may include it under
2523a0898aSmrg# the same distribution terms that you use for the rest of that program.
2623a0898aSmrg
2723a0898aSmrgif test $# -eq 0; then
28b020570bSmrg  echo 1>&2 "Try '$0 --help' for more information"
2923a0898aSmrg  exit 1
3023a0898aSmrgfi
3123a0898aSmrg
32b020570bSmrgcase $1 in
3323a0898aSmrg
34b020570bSmrg  --is-lightweight)
35b020570bSmrg    # Used by our autoconf macros to check whether the available missing
36b020570bSmrg    # script is modern enough.
37b020570bSmrg    exit 0
38b020570bSmrg    ;;
3923a0898aSmrg
40b020570bSmrg  --run)
41b020570bSmrg    # Back-compat with the calling convention used by older automake.
42b020570bSmrg    shift
43b020570bSmrg    ;;
4423a0898aSmrg
4523a0898aSmrg  -h|--h|--he|--hel|--help)
4623a0898aSmrg    echo "\
4723a0898aSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4823a0898aSmrg
49b020570bSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50b020570bSmrgto PROGRAM being missing or too old.
5123a0898aSmrg
5223a0898aSmrgOptions:
5323a0898aSmrg  -h, --help      display this help and exit
5423a0898aSmrg  -v, --version   output version information and exit
5523a0898aSmrg
5623a0898aSmrgSupported PROGRAM values:
57b020570bSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58b020570bSmrg  bison     yacc      flex         lex       help2man
5923a0898aSmrg
60b020570bSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61b020570bSmrg'g' are ignored when checking the name.
6241c30155Smrg
6323a0898aSmrgSend bug reports to <bug-automake@gnu.org>."
6423a0898aSmrg    exit $?
6523a0898aSmrg    ;;
6623a0898aSmrg
6723a0898aSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6823a0898aSmrg    echo "missing $scriptversion (GNU Automake)"
6923a0898aSmrg    exit $?
7023a0898aSmrg    ;;
7123a0898aSmrg
7223a0898aSmrg  -*)
73b020570bSmrg    echo 1>&2 "$0: unknown '$1' option"
74b020570bSmrg    echo 1>&2 "Try '$0 --help' for more information"
7523a0898aSmrg    exit 1
7623a0898aSmrg    ;;
7723a0898aSmrg
7823a0898aSmrgesac
7923a0898aSmrg
80b020570bSmrg# Run the given program, remember its exit status.
81b020570bSmrg"$@"; st=$?
82b020570bSmrg
83b020570bSmrg# If it succeeded, we are done.
84b020570bSmrgtest $st -eq 0 && exit 0
85b020570bSmrg
86b020570bSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
87b020570bSmrg# passed; such an option is passed most likely to detect whether the
88b020570bSmrg# program is present and works.
89b020570bSmrgcase $2 in --version|--help) exit $st;; esac
90b020570bSmrg
91b020570bSmrg# Exit code 63 means version mismatch.  This often happens when the user
92b020570bSmrg# tries to use an ancient version of a tool on a file that requires a
93b020570bSmrg# minimum version.
94b020570bSmrgif test $st -eq 63; then
95b020570bSmrg  msg="probably too old"
96b020570bSmrgelif test $st -eq 127; then
97b020570bSmrg  # Program was missing.
98b020570bSmrg  msg="missing on your system"
99b020570bSmrgelse
100b020570bSmrg  # Program was found and executed, but failed.  Give up.
101b020570bSmrg  exit $st
102b020570bSmrgfi
10323a0898aSmrg
104b020570bSmrgperl_URL=http://www.perl.org/
105b020570bSmrgflex_URL=http://flex.sourceforge.net/
106b020570bSmrggnu_software_URL=http://www.gnu.org/software
107b020570bSmrg
108b020570bSmrgprogram_details ()
109b020570bSmrg{
110b020570bSmrg  case $1 in
111b020570bSmrg    aclocal|automake)
112b020570bSmrg      echo "The '$1' program is part of the GNU Automake package:"
113b020570bSmrg      echo "<$gnu_software_URL/automake>"
114b020570bSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115b020570bSmrg      echo "<$gnu_software_URL/autoconf>"
116b020570bSmrg      echo "<$gnu_software_URL/m4/>"
117b020570bSmrg      echo "<$perl_URL>"
118b020570bSmrg      ;;
119b020570bSmrg    autoconf|autom4te|autoheader)
120b020570bSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
121b020570bSmrg      echo "<$gnu_software_URL/autoconf/>"
122b020570bSmrg      echo "It also requires GNU m4 and Perl in order to run:"
123b020570bSmrg      echo "<$gnu_software_URL/m4/>"
124b020570bSmrg      echo "<$perl_URL>"
125b020570bSmrg      ;;
126b020570bSmrg  esac
127b020570bSmrg}
128b020570bSmrg
129b020570bSmrggive_advice ()
130b020570bSmrg{
131b020570bSmrg  # Normalize program name to check for.
132b020570bSmrg  normalized_program=`echo "$1" | sed '
133b020570bSmrg    s/^gnu-//; t
134b020570bSmrg    s/^gnu//; t
135b020570bSmrg    s/^g//; t'`
136b020570bSmrg
137b020570bSmrg  printf '%s\n' "'$1' is $msg."
138b020570bSmrg
139b020570bSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140b020570bSmrg  case $normalized_program in
141b020570bSmrg    autoconf*)
142b020570bSmrg      echo "You should only need it if you modified 'configure.ac',"
143b020570bSmrg      echo "or m4 files included by it."
144b020570bSmrg      program_details 'autoconf'
145b020570bSmrg      ;;
146b020570bSmrg    autoheader*)
147b020570bSmrg      echo "You should only need it if you modified 'acconfig.h' or"
148b020570bSmrg      echo "$configure_deps."
149b020570bSmrg      program_details 'autoheader'
150b020570bSmrg      ;;
151b020570bSmrg    automake*)
152b020570bSmrg      echo "You should only need it if you modified 'Makefile.am' or"
153b020570bSmrg      echo "$configure_deps."
154b020570bSmrg      program_details 'automake'
155b020570bSmrg      ;;
156b020570bSmrg    aclocal*)
157b020570bSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
158b020570bSmrg      echo "$configure_deps."
159b020570bSmrg      program_details 'aclocal'
160b020570bSmrg      ;;
161b020570bSmrg   autom4te*)
162b020570bSmrg      echo "You might have modified some maintainer files that require"
1630145ab54Ssnj      echo "the 'autom4te' program to be rebuilt."
164b020570bSmrg      program_details 'autom4te'
165b020570bSmrg      ;;
166b020570bSmrg    bison*|yacc*)
167b020570bSmrg      echo "You should only need it if you modified a '.y' file."
168b020570bSmrg      echo "You may want to install the GNU Bison package:"
169b020570bSmrg      echo "<$gnu_software_URL/bison/>"
170b020570bSmrg      ;;
171b020570bSmrg    lex*|flex*)
172b020570bSmrg      echo "You should only need it if you modified a '.l' file."
173b020570bSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
174b020570bSmrg      echo "<$flex_URL>"
175b020570bSmrg      ;;
176b020570bSmrg    help2man*)
177b020570bSmrg      echo "You should only need it if you modified a dependency" \
178b020570bSmrg           "of a man page."
179b020570bSmrg      echo "You may want to install the GNU Help2man package:"
180b020570bSmrg      echo "<$gnu_software_URL/help2man/>"
181b020570bSmrg    ;;
182b020570bSmrg    makeinfo*)
183b020570bSmrg      echo "You should only need it if you modified a '.texi' file, or"
184b020570bSmrg      echo "any other file indirectly affecting the aspect of the manual."
185b020570bSmrg      echo "You might want to install the Texinfo package:"
186b020570bSmrg      echo "<$gnu_software_URL/texinfo/>"
187b020570bSmrg      echo "The spurious makeinfo call might also be the consequence of"
188b020570bSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189b020570bSmrg      echo "want to install GNU make:"
190b020570bSmrg      echo "<$gnu_software_URL/make/>"
191b020570bSmrg      ;;
192b020570bSmrg    *)
193b020570bSmrg      echo "You might have modified some files without having the proper"
194b020570bSmrg      echo "tools for further handling them.  Check the 'README' file, it"
195b020570bSmrg      echo "often tells you about the needed prerequisites for installing"
196b020570bSmrg      echo "this package.  You may also peek at any GNU archive site, in"
197b020570bSmrg      echo "case some other package contains this missing '$1' program."
198b020570bSmrg      ;;
199b020570bSmrg  esac
200b020570bSmrg}
201b020570bSmrg
202b020570bSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203b020570bSmrg                       -e '2,$s/^/         /' >&2
204b020570bSmrg
205b020570bSmrg# Propagate the correct exit status (expected to be 127 for a program
206b020570bSmrg# not found, 63 for a program that failed due to version mismatch).
207b020570bSmrgexit $st
20823a0898aSmrg
20923a0898aSmrg# Local variables:
21023a0898aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
21123a0898aSmrg# time-stamp-start: "scriptversion="
21223a0898aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
21341c30155Smrg# time-stamp-time-zone: "UTC"
21441c30155Smrg# time-stamp-end: "; # UTC"
21523a0898aSmrg# End:
216