blob: db98974ff5d59295d7e0edfec2eb2069dc78ef1a [file] [log] [blame]
The Android Open Source Project893912b2009-03-03 19:30:05 -08001#! /bin/sh
Chris Craikb50c2172013-07-29 15:28:30 -07002# Common wrapper for a few potentially missing GNU programs.
The Android Open Source Project893912b2009-03-03 19:30:05 -08003
Sireesh Tripurarib478e662014-05-09 15:15:10 +05304scriptversion=2013-10-28.13; # UTC
The Android Open Source Project893912b2009-03-03 19:30:05 -08005
Sireesh Tripurarib478e662014-05-09 15:15:10 +05306# Copyright (C) 1996-2013 Free Software Foundation, Inc.
Chris Craikb50c2172013-07-29 15:28:30 -07007# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
The Android Open Source Project893912b2009-03-03 19:30:05 -08008
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2, or (at your option)
12# any later version.
13
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18
19# You should have received a copy of the GNU General Public License
Patrick Scott5f6bd842010-06-28 16:55:16 -040020# along with this program. If not, see <http://www.gnu.org/licenses/>.
The Android Open Source Project893912b2009-03-03 19:30:05 -080021
22# As a special exception to the GNU General Public License, if you
23# distribute this file as part of a program that contains a
24# configuration script generated by Autoconf, you may include it under
25# the same distribution terms that you use for the rest of that program.
26
27if test $# -eq 0; then
Chris Craikb50c2172013-07-29 15:28:30 -070028 echo 1>&2 "Try '$0 --help' for more information"
The Android Open Source Project893912b2009-03-03 19:30:05 -080029 exit 1
30fi
31
The Android Open Source Project893912b2009-03-03 19:30:05 -080032case $1 in
Chris Craikb50c2172013-07-29 15:28:30 -070033
34 --is-lightweight)
35 # Used by our autoconf macros to check whether the available missing
36 # script is modern enough.
37 exit 0
38 ;;
39
40 --run)
41 # Back-compat with the calling convention used by older automake.
42 shift
43 ;;
The Android Open Source Project893912b2009-03-03 19:30:05 -080044
45 -h|--h|--he|--hel|--help)
46 echo "\
47$0 [OPTION]... PROGRAM [ARGUMENT]...
48
Chris Craikb50c2172013-07-29 15:28:30 -070049Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
50to PROGRAM being missing or too old.
The Android Open Source Project893912b2009-03-03 19:30:05 -080051
52Options:
53 -h, --help display this help and exit
54 -v, --version output version information and exit
The Android Open Source Project893912b2009-03-03 19:30:05 -080055
56Supported PROGRAM values:
Chris Craikb50c2172013-07-29 15:28:30 -070057 aclocal autoconf autoheader autom4te automake makeinfo
58 bison yacc flex lex help2man
The Android Open Source Project893912b2009-03-03 19:30:05 -080059
Chris Craikb50c2172013-07-29 15:28:30 -070060Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
61'g' are ignored when checking the name.
Patrick Scott5f6bd842010-06-28 16:55:16 -040062
The Android Open Source Project893912b2009-03-03 19:30:05 -080063Send bug reports to <bug-automake@gnu.org>."
64 exit $?
65 ;;
66
67 -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68 echo "missing $scriptversion (GNU Automake)"
69 exit $?
70 ;;
71
72 -*)
Chris Craikb50c2172013-07-29 15:28:30 -070073 echo 1>&2 "$0: unknown '$1' option"
74 echo 1>&2 "Try '$0 --help' for more information"
The Android Open Source Project893912b2009-03-03 19:30:05 -080075 exit 1
76 ;;
77
78esac
79
Chris Craikb50c2172013-07-29 15:28:30 -070080# Run the given program, remember its exit status.
81"$@"; st=$?
Patrick Scott5f6bd842010-06-28 16:55:16 -040082
Chris Craikb50c2172013-07-29 15:28:30 -070083# If it succeeded, we are done.
84test $st -eq 0 && exit 0
85
86# Also exit now if we it failed (or wasn't found), and '--version' was
87# passed; such an option is passed most likely to detect whether the
88# program is present and works.
89case $2 in --version|--help) exit $st;; esac
90
91# Exit code 63 means version mismatch. This often happens when the user
92# tries to use an ancient version of a tool on a file that requires a
93# minimum version.
94if test $st -eq 63; then
95 msg="probably too old"
96elif test $st -eq 127; then
97 # Program was missing.
98 msg="missing on your system"
99else
100 # Program was found and executed, but failed. Give up.
101 exit $st
102fi
103
104perl_URL=http://www.perl.org/
105flex_URL=http://flex.sourceforge.net/
106gnu_software_URL=http://www.gnu.org/software
107
108program_details ()
109{
110 case $1 in
111 aclocal|automake)
112 echo "The '$1' program is part of the GNU Automake package:"
113 echo "<$gnu_software_URL/automake>"
114 echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
115 echo "<$gnu_software_URL/autoconf>"
116 echo "<$gnu_software_URL/m4/>"
117 echo "<$perl_URL>"
118 ;;
119 autoconf|autom4te|autoheader)
120 echo "The '$1' program is part of the GNU Autoconf package:"
121 echo "<$gnu_software_URL/autoconf/>"
122 echo "It also requires GNU m4 and Perl in order to run:"
123 echo "<$gnu_software_URL/m4/>"
124 echo "<$perl_URL>"
125 ;;
126 esac
127}
128
129give_advice ()
130{
131 # Normalize program name to check for.
132 normalized_program=`echo "$1" | sed '
133 s/^gnu-//; t
134 s/^gnu//; t
135 s/^g//; t'`
136
137 printf '%s\n' "'$1' is $msg."
138
139 configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
140 case $normalized_program in
141 autoconf*)
142 echo "You should only need it if you modified 'configure.ac',"
143 echo "or m4 files included by it."
144 program_details 'autoconf'
145 ;;
146 autoheader*)
147 echo "You should only need it if you modified 'acconfig.h' or"
148 echo "$configure_deps."
149 program_details 'autoheader'
150 ;;
151 automake*)
152 echo "You should only need it if you modified 'Makefile.am' or"
153 echo "$configure_deps."
154 program_details 'automake'
155 ;;
156 aclocal*)
157 echo "You should only need it if you modified 'acinclude.m4' or"
158 echo "$configure_deps."
159 program_details 'aclocal'
160 ;;
161 autom4te*)
162 echo "You might have modified some maintainer files that require"
Sireesh Tripurarib478e662014-05-09 15:15:10 +0530163 echo "the 'autom4te' program to be rebuilt."
Chris Craikb50c2172013-07-29 15:28:30 -0700164 program_details 'autom4te'
165 ;;
166 bison*|yacc*)
167 echo "You should only need it if you modified a '.y' file."
168 echo "You may want to install the GNU Bison package:"
169 echo "<$gnu_software_URL/bison/>"
170 ;;
171 lex*|flex*)
172 echo "You should only need it if you modified a '.l' file."
173 echo "You may want to install the Fast Lexical Analyzer package:"
174 echo "<$flex_URL>"
175 ;;
176 help2man*)
177 echo "You should only need it if you modified a dependency" \
178 "of a man page."
179 echo "You may want to install the GNU Help2man package:"
180 echo "<$gnu_software_URL/help2man/>"
The Android Open Source Project893912b2009-03-03 19:30:05 -0800181 ;;
Chris Craikb50c2172013-07-29 15:28:30 -0700182 makeinfo*)
183 echo "You should only need it if you modified a '.texi' file, or"
184 echo "any other file indirectly affecting the aspect of the manual."
185 echo "You might want to install the Texinfo package:"
186 echo "<$gnu_software_URL/texinfo/>"
187 echo "The spurious makeinfo call might also be the consequence of"
188 echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
189 echo "want to install GNU make:"
190 echo "<$gnu_software_URL/make/>"
191 ;;
192 *)
193 echo "You might have modified some files without having the proper"
194 echo "tools for further handling them. Check the 'README' file, it"
195 echo "often tells you about the needed prerequisites for installing"
196 echo "this package. You may also peek at any GNU archive site, in"
197 echo "case some other package contains this missing '$1' program."
198 ;;
199 esac
200}
The Android Open Source Project893912b2009-03-03 19:30:05 -0800201
Chris Craikb50c2172013-07-29 15:28:30 -0700202give_advice "$1" | sed -e '1s/^/WARNING: /' \
203 -e '2,$s/^/ /' >&2
The Android Open Source Project893912b2009-03-03 19:30:05 -0800204
Chris Craikb50c2172013-07-29 15:28:30 -0700205# Propagate the correct exit status (expected to be 127 for a program
206# not found, 63 for a program that failed due to version mismatch).
207exit $st
The Android Open Source Project893912b2009-03-03 19:30:05 -0800208
209# Local variables:
210# eval: (add-hook 'write-file-hooks 'time-stamp)
211# time-stamp-start: "scriptversion="
212# time-stamp-format: "%:y-%02m-%02d.%02H"
Patrick Scott5f6bd842010-06-28 16:55:16 -0400213# time-stamp-time-zone: "UTC"
214# time-stamp-end: "; # UTC"
The Android Open Source Project893912b2009-03-03 19:30:05 -0800215# End: