missing revision eb411b4b
11ab64890Smrg#! /bin/sh
2eb411b4bSmrg# Common wrapper for a few potentially missing GNU programs.
31ab64890Smrg
4eb411b4bSmrgscriptversion=2012-06-26.16; # UTC
51ab64890Smrg
6eb411b4bSmrg# Copyright (C) 1996-2013 Free Software Foundation, Inc.
7eb411b4bSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
81ab64890Smrg
91ab64890Smrg# This program is free software; you can redistribute it and/or modify
101ab64890Smrg# it under the terms of the GNU General Public License as published by
111ab64890Smrg# the Free Software Foundation; either version 2, or (at your option)
121ab64890Smrg# any later version.
131ab64890Smrg
141ab64890Smrg# This program is distributed in the hope that it will be useful,
151ab64890Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
161ab64890Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171ab64890Smrg# GNU General Public License for more details.
181ab64890Smrg
191ab64890Smrg# You should have received a copy of the GNU General Public License
20b4ee4795Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
211ab64890Smrg
221ab64890Smrg# As a special exception to the GNU General Public License, if you
231ab64890Smrg# distribute this file as part of a program that contains a
241ab64890Smrg# configuration script generated by Autoconf, you may include it under
251ab64890Smrg# the same distribution terms that you use for the rest of that program.
261ab64890Smrg
271ab64890Smrgif test $# -eq 0; then
28eb411b4bSmrg  echo 1>&2 "Try '$0 --help' for more information"
291ab64890Smrg  exit 1
301ab64890Smrgfi
311ab64890Smrg
32eb411b4bSmrgcase $1 in
331ab64890Smrg
34eb411b4bSmrg  --is-lightweight)
35eb411b4bSmrg    # Used by our autoconf macros to check whether the available missing
36eb411b4bSmrg    # script is modern enough.
37eb411b4bSmrg    exit 0
38eb411b4bSmrg    ;;
391ab64890Smrg
40eb411b4bSmrg  --run)
41eb411b4bSmrg    # Back-compat with the calling convention used by older automake.
42eb411b4bSmrg    shift
43eb411b4bSmrg    ;;
441ab64890Smrg
451ab64890Smrg  -h|--h|--he|--hel|--help)
461ab64890Smrg    echo "\
471ab64890Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
481ab64890Smrg
49eb411b4bSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50eb411b4bSmrgto PROGRAM being missing or too old.
511ab64890Smrg
521ab64890SmrgOptions:
531ab64890Smrg  -h, --help      display this help and exit
541ab64890Smrg  -v, --version   output version information and exit
551ab64890Smrg
561ab64890SmrgSupported PROGRAM values:
57eb411b4bSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58eb411b4bSmrg  bison     yacc      flex         lex       help2man
591ab64890Smrg
60eb411b4bSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61eb411b4bSmrg'g' are ignored when checking the name.
62b4ee4795Smrg
631ab64890SmrgSend bug reports to <bug-automake@gnu.org>."
641ab64890Smrg    exit $?
651ab64890Smrg    ;;
661ab64890Smrg
671ab64890Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
681ab64890Smrg    echo "missing $scriptversion (GNU Automake)"
691ab64890Smrg    exit $?
701ab64890Smrg    ;;
711ab64890Smrg
721ab64890Smrg  -*)
73eb411b4bSmrg    echo 1>&2 "$0: unknown '$1' option"
74eb411b4bSmrg    echo 1>&2 "Try '$0 --help' for more information"
751ab64890Smrg    exit 1
761ab64890Smrg    ;;
771ab64890Smrg
781ab64890Smrgesac
791ab64890Smrg
80eb411b4bSmrg# Run the given program, remember its exit status.
81eb411b4bSmrg"$@"; st=$?
82eb411b4bSmrg
83eb411b4bSmrg# If it succeeded, we are done.
84eb411b4bSmrgtest $st -eq 0 && exit 0
85eb411b4bSmrg
86eb411b4bSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
87eb411b4bSmrg# passed; such an option is passed most likely to detect whether the
88eb411b4bSmrg# program is present and works.
89eb411b4bSmrgcase $2 in --version|--help) exit $st;; esac
90eb411b4bSmrg
91eb411b4bSmrg# Exit code 63 means version mismatch.  This often happens when the user
92eb411b4bSmrg# tries to use an ancient version of a tool on a file that requires a
93eb411b4bSmrg# minimum version.
94eb411b4bSmrgif test $st -eq 63; then
95eb411b4bSmrg  msg="probably too old"
96eb411b4bSmrgelif test $st -eq 127; then
97eb411b4bSmrg  # Program was missing.
98eb411b4bSmrg  msg="missing on your system"
99eb411b4bSmrgelse
100eb411b4bSmrg  # Program was found and executed, but failed.  Give up.
101eb411b4bSmrg  exit $st
102eb411b4bSmrgfi
1031ab64890Smrg
104eb411b4bSmrgperl_URL=http://www.perl.org/
105eb411b4bSmrgflex_URL=http://flex.sourceforge.net/
106eb411b4bSmrggnu_software_URL=http://www.gnu.org/software
107eb411b4bSmrg
108eb411b4bSmrgprogram_details ()
109eb411b4bSmrg{
110eb411b4bSmrg  case $1 in
111eb411b4bSmrg    aclocal|automake)
112eb411b4bSmrg      echo "The '$1' program is part of the GNU Automake package:"
113eb411b4bSmrg      echo "<$gnu_software_URL/automake>"
114eb411b4bSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115eb411b4bSmrg      echo "<$gnu_software_URL/autoconf>"
116eb411b4bSmrg      echo "<$gnu_software_URL/m4/>"
117eb411b4bSmrg      echo "<$perl_URL>"
118eb411b4bSmrg      ;;
119eb411b4bSmrg    autoconf|autom4te|autoheader)
120eb411b4bSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
121eb411b4bSmrg      echo "<$gnu_software_URL/autoconf/>"
122eb411b4bSmrg      echo "It also requires GNU m4 and Perl in order to run:"
123eb411b4bSmrg      echo "<$gnu_software_URL/m4/>"
124eb411b4bSmrg      echo "<$perl_URL>"
125eb411b4bSmrg      ;;
126eb411b4bSmrg  esac
127eb411b4bSmrg}
128eb411b4bSmrg
129eb411b4bSmrggive_advice ()
130eb411b4bSmrg{
131eb411b4bSmrg  # Normalize program name to check for.
132eb411b4bSmrg  normalized_program=`echo "$1" | sed '
133eb411b4bSmrg    s/^gnu-//; t
134eb411b4bSmrg    s/^gnu//; t
135eb411b4bSmrg    s/^g//; t'`
136eb411b4bSmrg
137eb411b4bSmrg  printf '%s\n' "'$1' is $msg."
138eb411b4bSmrg
139eb411b4bSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140eb411b4bSmrg  case $normalized_program in
141eb411b4bSmrg    autoconf*)
142eb411b4bSmrg      echo "You should only need it if you modified 'configure.ac',"
143eb411b4bSmrg      echo "or m4 files included by it."
144eb411b4bSmrg      program_details 'autoconf'
145eb411b4bSmrg      ;;
146eb411b4bSmrg    autoheader*)
147eb411b4bSmrg      echo "You should only need it if you modified 'acconfig.h' or"
148eb411b4bSmrg      echo "$configure_deps."
149eb411b4bSmrg      program_details 'autoheader'
150eb411b4bSmrg      ;;
151eb411b4bSmrg    automake*)
152eb411b4bSmrg      echo "You should only need it if you modified 'Makefile.am' or"
153eb411b4bSmrg      echo "$configure_deps."
154eb411b4bSmrg      program_details 'automake'
155eb411b4bSmrg      ;;
156eb411b4bSmrg    aclocal*)
157eb411b4bSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
158eb411b4bSmrg      echo "$configure_deps."
159eb411b4bSmrg      program_details 'aclocal'
160eb411b4bSmrg      ;;
161eb411b4bSmrg   autom4te*)
162eb411b4bSmrg      echo "You might have modified some maintainer files that require"
163eb411b4bSmrg      echo "the 'automa4te' program to be rebuilt."
164eb411b4bSmrg      program_details 'autom4te'
165eb411b4bSmrg      ;;
166eb411b4bSmrg    bison*|yacc*)
167eb411b4bSmrg      echo "You should only need it if you modified a '.y' file."
168eb411b4bSmrg      echo "You may want to install the GNU Bison package:"
169eb411b4bSmrg      echo "<$gnu_software_URL/bison/>"
170eb411b4bSmrg      ;;
171eb411b4bSmrg    lex*|flex*)
172eb411b4bSmrg      echo "You should only need it if you modified a '.l' file."
173eb411b4bSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
174eb411b4bSmrg      echo "<$flex_URL>"
175eb411b4bSmrg      ;;
176eb411b4bSmrg    help2man*)
177eb411b4bSmrg      echo "You should only need it if you modified a dependency" \
178eb411b4bSmrg           "of a man page."
179eb411b4bSmrg      echo "You may want to install the GNU Help2man package:"
180eb411b4bSmrg      echo "<$gnu_software_URL/help2man/>"
181eb411b4bSmrg    ;;
182eb411b4bSmrg    makeinfo*)
183eb411b4bSmrg      echo "You should only need it if you modified a '.texi' file, or"
184eb411b4bSmrg      echo "any other file indirectly affecting the aspect of the manual."
185eb411b4bSmrg      echo "You might want to install the Texinfo package:"
186eb411b4bSmrg      echo "<$gnu_software_URL/texinfo/>"
187eb411b4bSmrg      echo "The spurious makeinfo call might also be the consequence of"
188eb411b4bSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189eb411b4bSmrg      echo "want to install GNU make:"
190eb411b4bSmrg      echo "<$gnu_software_URL/make/>"
191eb411b4bSmrg      ;;
192eb411b4bSmrg    *)
193eb411b4bSmrg      echo "You might have modified some files without having the proper"
194eb411b4bSmrg      echo "tools for further handling them.  Check the 'README' file, it"
195eb411b4bSmrg      echo "often tells you about the needed prerequisites for installing"
196eb411b4bSmrg      echo "this package.  You may also peek at any GNU archive site, in"
197eb411b4bSmrg      echo "case some other package contains this missing '$1' program."
198eb411b4bSmrg      ;;
199eb411b4bSmrg  esac
200eb411b4bSmrg}
201eb411b4bSmrg
202eb411b4bSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203eb411b4bSmrg                       -e '2,$s/^/         /' >&2
204eb411b4bSmrg
205eb411b4bSmrg# Propagate the correct exit status (expected to be 127 for a program
206eb411b4bSmrg# not found, 63 for a program that failed due to version mismatch).
207eb411b4bSmrgexit $st
2081ab64890Smrg
2091ab64890Smrg# Local variables:
2101ab64890Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
2111ab64890Smrg# time-stamp-start: "scriptversion="
2121ab64890Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213b4ee4795Smrg# time-stamp-time-zone: "UTC"
214b4ee4795Smrg# time-stamp-end: "; # UTC"
2151ab64890Smrg# End:
216