missing revision fe2ac8d7
19027f4a0Smrg#! /bin/sh
2fe2ac8d7Smrg# Common wrapper for a few potentially missing GNU programs.
39027f4a0Smrg
4fe2ac8d7Smrgscriptversion=2012-06-26.16; # UTC
59027f4a0Smrg
6fe2ac8d7Smrg# Copyright (C) 1996-2013 Free Software Foundation, Inc.
7fe2ac8d7Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
89027f4a0Smrg
99027f4a0Smrg# This program is free software; you can redistribute it and/or modify
109027f4a0Smrg# it under the terms of the GNU General Public License as published by
119027f4a0Smrg# the Free Software Foundation; either version 2, or (at your option)
129027f4a0Smrg# any later version.
139027f4a0Smrg
149027f4a0Smrg# This program is distributed in the hope that it will be useful,
159027f4a0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
169027f4a0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
179027f4a0Smrg# GNU General Public License for more details.
189027f4a0Smrg
199027f4a0Smrg# You should have received a copy of the GNU General Public License
203a72f200Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
219027f4a0Smrg
229027f4a0Smrg# As a special exception to the GNU General Public License, if you
239027f4a0Smrg# distribute this file as part of a program that contains a
249027f4a0Smrg# configuration script generated by Autoconf, you may include it under
259027f4a0Smrg# the same distribution terms that you use for the rest of that program.
269027f4a0Smrg
279027f4a0Smrgif test $# -eq 0; then
28fe2ac8d7Smrg  echo 1>&2 "Try '$0 --help' for more information"
299027f4a0Smrg  exit 1
309027f4a0Smrgfi
319027f4a0Smrg
32fe2ac8d7Smrgcase $1 in
339027f4a0Smrg
34fe2ac8d7Smrg  --is-lightweight)
35fe2ac8d7Smrg    # Used by our autoconf macros to check whether the available missing
36fe2ac8d7Smrg    # script is modern enough.
37fe2ac8d7Smrg    exit 0
38fe2ac8d7Smrg    ;;
399027f4a0Smrg
40fe2ac8d7Smrg  --run)
41fe2ac8d7Smrg    # Back-compat with the calling convention used by older automake.
42fe2ac8d7Smrg    shift
43fe2ac8d7Smrg    ;;
449027f4a0Smrg
459027f4a0Smrg  -h|--h|--he|--hel|--help)
469027f4a0Smrg    echo "\
479027f4a0Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
489027f4a0Smrg
49fe2ac8d7SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50fe2ac8d7Smrgto PROGRAM being missing or too old.
519027f4a0Smrg
529027f4a0SmrgOptions:
539027f4a0Smrg  -h, --help      display this help and exit
549027f4a0Smrg  -v, --version   output version information and exit
559027f4a0Smrg
569027f4a0SmrgSupported PROGRAM values:
57fe2ac8d7Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
58fe2ac8d7Smrg  bison     yacc      flex         lex       help2man
599027f4a0Smrg
60fe2ac8d7SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61fe2ac8d7Smrg'g' are ignored when checking the name.
623a72f200Smrg
639027f4a0SmrgSend bug reports to <bug-automake@gnu.org>."
649027f4a0Smrg    exit $?
659027f4a0Smrg    ;;
669027f4a0Smrg
679027f4a0Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
689027f4a0Smrg    echo "missing $scriptversion (GNU Automake)"
699027f4a0Smrg    exit $?
709027f4a0Smrg    ;;
719027f4a0Smrg
729027f4a0Smrg  -*)
73fe2ac8d7Smrg    echo 1>&2 "$0: unknown '$1' option"
74fe2ac8d7Smrg    echo 1>&2 "Try '$0 --help' for more information"
759027f4a0Smrg    exit 1
769027f4a0Smrg    ;;
779027f4a0Smrg
789027f4a0Smrgesac
799027f4a0Smrg
80fe2ac8d7Smrg# Run the given program, remember its exit status.
81fe2ac8d7Smrg"$@"; st=$?
82fe2ac8d7Smrg
83fe2ac8d7Smrg# If it succeeded, we are done.
84fe2ac8d7Smrgtest $st -eq 0 && exit 0
85fe2ac8d7Smrg
86fe2ac8d7Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
87fe2ac8d7Smrg# passed; such an option is passed most likely to detect whether the
88fe2ac8d7Smrg# program is present and works.
89fe2ac8d7Smrgcase $2 in --version|--help) exit $st;; esac
90fe2ac8d7Smrg
91fe2ac8d7Smrg# Exit code 63 means version mismatch.  This often happens when the user
92fe2ac8d7Smrg# tries to use an ancient version of a tool on a file that requires a
93fe2ac8d7Smrg# minimum version.
94fe2ac8d7Smrgif test $st -eq 63; then
95fe2ac8d7Smrg  msg="probably too old"
96fe2ac8d7Smrgelif test $st -eq 127; then
97fe2ac8d7Smrg  # Program was missing.
98fe2ac8d7Smrg  msg="missing on your system"
99fe2ac8d7Smrgelse
100fe2ac8d7Smrg  # Program was found and executed, but failed.  Give up.
101fe2ac8d7Smrg  exit $st
102fe2ac8d7Smrgfi
1039027f4a0Smrg
104fe2ac8d7Smrgperl_URL=http://www.perl.org/
105fe2ac8d7Smrgflex_URL=http://flex.sourceforge.net/
106fe2ac8d7Smrggnu_software_URL=http://www.gnu.org/software
107fe2ac8d7Smrg
108fe2ac8d7Smrgprogram_details ()
109fe2ac8d7Smrg{
110fe2ac8d7Smrg  case $1 in
111fe2ac8d7Smrg    aclocal|automake)
112fe2ac8d7Smrg      echo "The '$1' program is part of the GNU Automake package:"
113fe2ac8d7Smrg      echo "<$gnu_software_URL/automake>"
114fe2ac8d7Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115fe2ac8d7Smrg      echo "<$gnu_software_URL/autoconf>"
116fe2ac8d7Smrg      echo "<$gnu_software_URL/m4/>"
117fe2ac8d7Smrg      echo "<$perl_URL>"
118fe2ac8d7Smrg      ;;
119fe2ac8d7Smrg    autoconf|autom4te|autoheader)
120fe2ac8d7Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
121fe2ac8d7Smrg      echo "<$gnu_software_URL/autoconf/>"
122fe2ac8d7Smrg      echo "It also requires GNU m4 and Perl in order to run:"
123fe2ac8d7Smrg      echo "<$gnu_software_URL/m4/>"
124fe2ac8d7Smrg      echo "<$perl_URL>"
125fe2ac8d7Smrg      ;;
126fe2ac8d7Smrg  esac
127fe2ac8d7Smrg}
128fe2ac8d7Smrg
129fe2ac8d7Smrggive_advice ()
130fe2ac8d7Smrg{
131fe2ac8d7Smrg  # Normalize program name to check for.
132fe2ac8d7Smrg  normalized_program=`echo "$1" | sed '
133fe2ac8d7Smrg    s/^gnu-//; t
134fe2ac8d7Smrg    s/^gnu//; t
135fe2ac8d7Smrg    s/^g//; t'`
136fe2ac8d7Smrg
137fe2ac8d7Smrg  printf '%s\n' "'$1' is $msg."
138fe2ac8d7Smrg
139fe2ac8d7Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140fe2ac8d7Smrg  case $normalized_program in
141fe2ac8d7Smrg    autoconf*)
142fe2ac8d7Smrg      echo "You should only need it if you modified 'configure.ac',"
143fe2ac8d7Smrg      echo "or m4 files included by it."
144fe2ac8d7Smrg      program_details 'autoconf'
145fe2ac8d7Smrg      ;;
146fe2ac8d7Smrg    autoheader*)
147fe2ac8d7Smrg      echo "You should only need it if you modified 'acconfig.h' or"
148fe2ac8d7Smrg      echo "$configure_deps."
149fe2ac8d7Smrg      program_details 'autoheader'
150fe2ac8d7Smrg      ;;
151fe2ac8d7Smrg    automake*)
152fe2ac8d7Smrg      echo "You should only need it if you modified 'Makefile.am' or"
153fe2ac8d7Smrg      echo "$configure_deps."
154fe2ac8d7Smrg      program_details 'automake'
155fe2ac8d7Smrg      ;;
156fe2ac8d7Smrg    aclocal*)
157fe2ac8d7Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
158fe2ac8d7Smrg      echo "$configure_deps."
159fe2ac8d7Smrg      program_details 'aclocal'
160fe2ac8d7Smrg      ;;
161fe2ac8d7Smrg   autom4te*)
162fe2ac8d7Smrg      echo "You might have modified some maintainer files that require"
163fe2ac8d7Smrg      echo "the 'automa4te' program to be rebuilt."
164fe2ac8d7Smrg      program_details 'autom4te'
165fe2ac8d7Smrg      ;;
166fe2ac8d7Smrg    bison*|yacc*)
167fe2ac8d7Smrg      echo "You should only need it if you modified a '.y' file."
168fe2ac8d7Smrg      echo "You may want to install the GNU Bison package:"
169fe2ac8d7Smrg      echo "<$gnu_software_URL/bison/>"
170fe2ac8d7Smrg      ;;
171fe2ac8d7Smrg    lex*|flex*)
172fe2ac8d7Smrg      echo "You should only need it if you modified a '.l' file."
173fe2ac8d7Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
174fe2ac8d7Smrg      echo "<$flex_URL>"
175fe2ac8d7Smrg      ;;
176fe2ac8d7Smrg    help2man*)
177fe2ac8d7Smrg      echo "You should only need it if you modified a dependency" \
178fe2ac8d7Smrg           "of a man page."
179fe2ac8d7Smrg      echo "You may want to install the GNU Help2man package:"
180fe2ac8d7Smrg      echo "<$gnu_software_URL/help2man/>"
181fe2ac8d7Smrg    ;;
182fe2ac8d7Smrg    makeinfo*)
183fe2ac8d7Smrg      echo "You should only need it if you modified a '.texi' file, or"
184fe2ac8d7Smrg      echo "any other file indirectly affecting the aspect of the manual."
185fe2ac8d7Smrg      echo "You might want to install the Texinfo package:"
186fe2ac8d7Smrg      echo "<$gnu_software_URL/texinfo/>"
187fe2ac8d7Smrg      echo "The spurious makeinfo call might also be the consequence of"
188fe2ac8d7Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189fe2ac8d7Smrg      echo "want to install GNU make:"
190fe2ac8d7Smrg      echo "<$gnu_software_URL/make/>"
191fe2ac8d7Smrg      ;;
192fe2ac8d7Smrg    *)
193fe2ac8d7Smrg      echo "You might have modified some files without having the proper"
194fe2ac8d7Smrg      echo "tools for further handling them.  Check the 'README' file, it"
195fe2ac8d7Smrg      echo "often tells you about the needed prerequisites for installing"
196fe2ac8d7Smrg      echo "this package.  You may also peek at any GNU archive site, in"
197fe2ac8d7Smrg      echo "case some other package contains this missing '$1' program."
198fe2ac8d7Smrg      ;;
199fe2ac8d7Smrg  esac
200fe2ac8d7Smrg}
201fe2ac8d7Smrg
202fe2ac8d7Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
203fe2ac8d7Smrg                       -e '2,$s/^/         /' >&2
204fe2ac8d7Smrg
205fe2ac8d7Smrg# Propagate the correct exit status (expected to be 127 for a program
206fe2ac8d7Smrg# not found, 63 for a program that failed due to version mismatch).
207fe2ac8d7Smrgexit $st
2089027f4a0Smrg
2099027f4a0Smrg# Local variables:
2109027f4a0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
2119027f4a0Smrg# time-stamp-start: "scriptversion="
2129027f4a0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
2133a72f200Smrg# time-stamp-time-zone: "UTC"
2143a72f200Smrg# time-stamp-end: "; # UTC"
2159027f4a0Smrg# End:
216