missing revision 81676fe2
1fc89c0fbSmrg#! /bin/sh
2576bbdfcSmrg# Common wrapper for a few potentially missing GNU programs.
3fc89c0fbSmrg
481676fe2Smrgscriptversion=2013-10-28.13; # UTC
5fc89c0fbSmrg
681676fe2Smrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
7576bbdfcSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8fc89c0fbSmrg
9fc89c0fbSmrg# This program is free software; you can redistribute it and/or modify
10fc89c0fbSmrg# it under the terms of the GNU General Public License as published by
11fc89c0fbSmrg# the Free Software Foundation; either version 2, or (at your option)
12fc89c0fbSmrg# any later version.
13fc89c0fbSmrg
14fc89c0fbSmrg# This program is distributed in the hope that it will be useful,
15fc89c0fbSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16fc89c0fbSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17fc89c0fbSmrg# GNU General Public License for more details.
18fc89c0fbSmrg
19fc89c0fbSmrg# You should have received a copy of the GNU General Public License
2091ec45ceSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21fc89c0fbSmrg
22fc89c0fbSmrg# As a special exception to the GNU General Public License, if you
23fc89c0fbSmrg# distribute this file as part of a program that contains a
24fc89c0fbSmrg# configuration script generated by Autoconf, you may include it under
25fc89c0fbSmrg# the same distribution terms that you use for the rest of that program.
26fc89c0fbSmrg
27fc89c0fbSmrgif test $# -eq 0; then
28576bbdfcSmrg  echo 1>&2 "Try '$0 --help' for more information"
29fc89c0fbSmrg  exit 1
30fc89c0fbSmrgfi
31fc89c0fbSmrg
32576bbdfcSmrgcase $1 in
33fc89c0fbSmrg
34576bbdfcSmrg  --is-lightweight)
35576bbdfcSmrg    # Used by our autoconf macros to check whether the available missing
36576bbdfcSmrg    # script is modern enough.
37576bbdfcSmrg    exit 0
38576bbdfcSmrg    ;;
39fc89c0fbSmrg
40576bbdfcSmrg  --run)
41576bbdfcSmrg    # Back-compat with the calling convention used by older automake.
42576bbdfcSmrg    shift
43576bbdfcSmrg    ;;
44fc89c0fbSmrg
45fc89c0fbSmrg  -h|--h|--he|--hel|--help)
46fc89c0fbSmrg    echo "\
47fc89c0fbSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48fc89c0fbSmrg
49576bbdfcSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50576bbdfcSmrgto PROGRAM being missing or too old.
51fc89c0fbSmrg
52fc89c0fbSmrgOptions:
53fc89c0fbSmrg  -h, --help      display this help and exit
54fc89c0fbSmrg  -v, --version   output version information and exit
55fc89c0fbSmrg
56fc89c0fbSmrgSupported PROGRAM values:
57576bbdfcSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58576bbdfcSmrg  bison     yacc      flex         lex       help2man
59fc89c0fbSmrg
60576bbdfcSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61576bbdfcSmrg'g' are ignored when checking the name.
6291ec45ceSmrg
63fc89c0fbSmrgSend bug reports to <bug-automake@gnu.org>."
64fc89c0fbSmrg    exit $?
65fc89c0fbSmrg    ;;
66fc89c0fbSmrg
67fc89c0fbSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68fc89c0fbSmrg    echo "missing $scriptversion (GNU Automake)"
69fc89c0fbSmrg    exit $?
70fc89c0fbSmrg    ;;
71fc89c0fbSmrg
72fc89c0fbSmrg  -*)
73576bbdfcSmrg    echo 1>&2 "$0: unknown '$1' option"
74576bbdfcSmrg    echo 1>&2 "Try '$0 --help' for more information"
75fc89c0fbSmrg    exit 1
76fc89c0fbSmrg    ;;
77fc89c0fbSmrg
78fc89c0fbSmrgesac
79fc89c0fbSmrg
80576bbdfcSmrg# Run the given program, remember its exit status.
81576bbdfcSmrg"$@"; st=$?
82576bbdfcSmrg
83576bbdfcSmrg# If it succeeded, we are done.
84576bbdfcSmrgtest $st -eq 0 && exit 0
85576bbdfcSmrg
86576bbdfcSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
87576bbdfcSmrg# passed; such an option is passed most likely to detect whether the
88576bbdfcSmrg# program is present and works.
89576bbdfcSmrgcase $2 in --version|--help) exit $st;; esac
90576bbdfcSmrg
91576bbdfcSmrg# Exit code 63 means version mismatch.  This often happens when the user
92576bbdfcSmrg# tries to use an ancient version of a tool on a file that requires a
93576bbdfcSmrg# minimum version.
94576bbdfcSmrgif test $st -eq 63; then
95576bbdfcSmrg  msg="probably too old"
96576bbdfcSmrgelif test $st -eq 127; then
97576bbdfcSmrg  # Program was missing.
98576bbdfcSmrg  msg="missing on your system"
99576bbdfcSmrgelse
100576bbdfcSmrg  # Program was found and executed, but failed.  Give up.
101576bbdfcSmrg  exit $st
102576bbdfcSmrgfi
103fc89c0fbSmrg
104576bbdfcSmrgperl_URL=http://www.perl.org/
105576bbdfcSmrgflex_URL=http://flex.sourceforge.net/
106576bbdfcSmrggnu_software_URL=http://www.gnu.org/software
107576bbdfcSmrg
108576bbdfcSmrgprogram_details ()
109576bbdfcSmrg{
110576bbdfcSmrg  case $1 in
111576bbdfcSmrg    aclocal|automake)
112576bbdfcSmrg      echo "The '$1' program is part of the GNU Automake package:"
113576bbdfcSmrg      echo "<$gnu_software_URL/automake>"
114576bbdfcSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115576bbdfcSmrg      echo "<$gnu_software_URL/autoconf>"
116576bbdfcSmrg      echo "<$gnu_software_URL/m4/>"
117576bbdfcSmrg      echo "<$perl_URL>"
118576bbdfcSmrg      ;;
119576bbdfcSmrg    autoconf|autom4te|autoheader)
120576bbdfcSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
121576bbdfcSmrg      echo "<$gnu_software_URL/autoconf/>"
122576bbdfcSmrg      echo "It also requires GNU m4 and Perl in order to run:"
123576bbdfcSmrg      echo "<$gnu_software_URL/m4/>"
124576bbdfcSmrg      echo "<$perl_URL>"
125576bbdfcSmrg      ;;
126576bbdfcSmrg  esac
127576bbdfcSmrg}
128576bbdfcSmrg
129576bbdfcSmrggive_advice ()
130576bbdfcSmrg{
131576bbdfcSmrg  # Normalize program name to check for.
132576bbdfcSmrg  normalized_program=`echo "$1" | sed '
133576bbdfcSmrg    s/^gnu-//; t
134576bbdfcSmrg    s/^gnu//; t
135576bbdfcSmrg    s/^g//; t'`
136576bbdfcSmrg
137576bbdfcSmrg  printf '%s\n' "'$1' is $msg."
138576bbdfcSmrg
139576bbdfcSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140576bbdfcSmrg  case $normalized_program in
141576bbdfcSmrg    autoconf*)
142576bbdfcSmrg      echo "You should only need it if you modified 'configure.ac',"
143576bbdfcSmrg      echo "or m4 files included by it."
144576bbdfcSmrg      program_details 'autoconf'
145576bbdfcSmrg      ;;
146576bbdfcSmrg    autoheader*)
147576bbdfcSmrg      echo "You should only need it if you modified 'acconfig.h' or"
148576bbdfcSmrg      echo "$configure_deps."
149576bbdfcSmrg      program_details 'autoheader'
150576bbdfcSmrg      ;;
151576bbdfcSmrg    automake*)
152576bbdfcSmrg      echo "You should only need it if you modified 'Makefile.am' or"
153576bbdfcSmrg      echo "$configure_deps."
154576bbdfcSmrg      program_details 'automake'
155576bbdfcSmrg      ;;
156576bbdfcSmrg    aclocal*)
157576bbdfcSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
158576bbdfcSmrg      echo "$configure_deps."
159576bbdfcSmrg      program_details 'aclocal'
160576bbdfcSmrg      ;;
161576bbdfcSmrg   autom4te*)
162576bbdfcSmrg      echo "You might have modified some maintainer files that require"
16381676fe2Smrg      echo "the 'autom4te' program to be rebuilt."
164576bbdfcSmrg      program_details 'autom4te'
165576bbdfcSmrg      ;;
166576bbdfcSmrg    bison*|yacc*)
167576bbdfcSmrg      echo "You should only need it if you modified a '.y' file."
168576bbdfcSmrg      echo "You may want to install the GNU Bison package:"
169576bbdfcSmrg      echo "<$gnu_software_URL/bison/>"
170576bbdfcSmrg      ;;
171576bbdfcSmrg    lex*|flex*)
172576bbdfcSmrg      echo "You should only need it if you modified a '.l' file."
173576bbdfcSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
174576bbdfcSmrg      echo "<$flex_URL>"
175576bbdfcSmrg      ;;
176576bbdfcSmrg    help2man*)
177576bbdfcSmrg      echo "You should only need it if you modified a dependency" \
178576bbdfcSmrg           "of a man page."
179576bbdfcSmrg      echo "You may want to install the GNU Help2man package:"
180576bbdfcSmrg      echo "<$gnu_software_URL/help2man/>"
181576bbdfcSmrg    ;;
182576bbdfcSmrg    makeinfo*)
183576bbdfcSmrg      echo "You should only need it if you modified a '.texi' file, or"
184576bbdfcSmrg      echo "any other file indirectly affecting the aspect of the manual."
185576bbdfcSmrg      echo "You might want to install the Texinfo package:"
186576bbdfcSmrg      echo "<$gnu_software_URL/texinfo/>"
187576bbdfcSmrg      echo "The spurious makeinfo call might also be the consequence of"
188576bbdfcSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189576bbdfcSmrg      echo "want to install GNU make:"
190576bbdfcSmrg      echo "<$gnu_software_URL/make/>"
191576bbdfcSmrg      ;;
192576bbdfcSmrg    *)
193576bbdfcSmrg      echo "You might have modified some files without having the proper"
194576bbdfcSmrg      echo "tools for further handling them.  Check the 'README' file, it"
195576bbdfcSmrg      echo "often tells you about the needed prerequisites for installing"
196576bbdfcSmrg      echo "this package.  You may also peek at any GNU archive site, in"
197576bbdfcSmrg      echo "case some other package contains this missing '$1' program."
198576bbdfcSmrg      ;;
199576bbdfcSmrg  esac
200576bbdfcSmrg}
201576bbdfcSmrg
202576bbdfcSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203576bbdfcSmrg                       -e '2,$s/^/         /' >&2
204576bbdfcSmrg
205576bbdfcSmrg# Propagate the correct exit status (expected to be 127 for a program
206576bbdfcSmrg# not found, 63 for a program that failed due to version mismatch).
207576bbdfcSmrgexit $st
208fc89c0fbSmrg
209fc89c0fbSmrg# Local variables:
210fc89c0fbSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
211fc89c0fbSmrg# time-stamp-start: "scriptversion="
212fc89c0fbSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
21391ec45ceSmrg# time-stamp-time-zone: "UTC"
21491ec45ceSmrg# time-stamp-end: "; # UTC"
215fc89c0fbSmrg# End:
216