1*7ab6e6acSAndroid Build Coastguard Worker#! /bin/sh 2*7ab6e6acSAndroid Build Coastguard Worker# Common wrapper for a few potentially missing GNU programs. 3*7ab6e6acSAndroid Build Coastguard Worker 4*7ab6e6acSAndroid Build Coastguard Workerscriptversion=2018-03-07.03; # UTC 5*7ab6e6acSAndroid Build Coastguard Worker 6*7ab6e6acSAndroid Build Coastguard Worker# Copyright (C) 1996-2020 Free Software Foundation, Inc. 7*7ab6e6acSAndroid Build Coastguard Worker# Originally written by Fran,cois Pinard <[email protected]>, 1996. 8*7ab6e6acSAndroid Build Coastguard Worker 9*7ab6e6acSAndroid Build Coastguard Worker# This program is free software; you can redistribute it and/or modify 10*7ab6e6acSAndroid Build Coastguard Worker# it under the terms of the GNU General Public License as published by 11*7ab6e6acSAndroid Build Coastguard Worker# the Free Software Foundation; either version 2, or (at your option) 12*7ab6e6acSAndroid Build Coastguard Worker# any later version. 13*7ab6e6acSAndroid Build Coastguard Worker 14*7ab6e6acSAndroid Build Coastguard Worker# This program is distributed in the hope that it will be useful, 15*7ab6e6acSAndroid Build Coastguard Worker# but WITHOUT ANY WARRANTY; without even the implied warranty of 16*7ab6e6acSAndroid Build Coastguard Worker# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*7ab6e6acSAndroid Build Coastguard Worker# GNU General Public License for more details. 18*7ab6e6acSAndroid Build Coastguard Worker 19*7ab6e6acSAndroid Build Coastguard Worker# You should have received a copy of the GNU General Public License 20*7ab6e6acSAndroid Build Coastguard Worker# along with this program. If not, see <https://www.gnu.org/licenses/>. 21*7ab6e6acSAndroid Build Coastguard Worker 22*7ab6e6acSAndroid Build Coastguard Worker# As a special exception to the GNU General Public License, if you 23*7ab6e6acSAndroid Build Coastguard Worker# distribute this file as part of a program that contains a 24*7ab6e6acSAndroid Build Coastguard Worker# configuration script generated by Autoconf, you may include it under 25*7ab6e6acSAndroid Build Coastguard Worker# the same distribution terms that you use for the rest of that program. 26*7ab6e6acSAndroid Build Coastguard Worker 27*7ab6e6acSAndroid Build Coastguard Workerif test $# -eq 0; then 28*7ab6e6acSAndroid Build Coastguard Worker echo 1>&2 "Try '$0 --help' for more information" 29*7ab6e6acSAndroid Build Coastguard Worker exit 1 30*7ab6e6acSAndroid Build Coastguard Workerfi 31*7ab6e6acSAndroid Build Coastguard Worker 32*7ab6e6acSAndroid Build Coastguard Workercase $1 in 33*7ab6e6acSAndroid Build Coastguard Worker 34*7ab6e6acSAndroid Build Coastguard Worker --is-lightweight) 35*7ab6e6acSAndroid Build Coastguard Worker # Used by our autoconf macros to check whether the available missing 36*7ab6e6acSAndroid Build Coastguard Worker # script is modern enough. 37*7ab6e6acSAndroid Build Coastguard Worker exit 0 38*7ab6e6acSAndroid Build Coastguard Worker ;; 39*7ab6e6acSAndroid Build Coastguard Worker 40*7ab6e6acSAndroid Build Coastguard Worker --run) 41*7ab6e6acSAndroid Build Coastguard Worker # Back-compat with the calling convention used by older automake. 42*7ab6e6acSAndroid Build Coastguard Worker shift 43*7ab6e6acSAndroid Build Coastguard Worker ;; 44*7ab6e6acSAndroid Build Coastguard Worker 45*7ab6e6acSAndroid Build Coastguard Worker -h|--h|--he|--hel|--help) 46*7ab6e6acSAndroid Build Coastguard Worker echo "\ 47*7ab6e6acSAndroid Build Coastguard Worker$0 [OPTION]... PROGRAM [ARGUMENT]... 48*7ab6e6acSAndroid Build Coastguard Worker 49*7ab6e6acSAndroid Build Coastguard WorkerRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50*7ab6e6acSAndroid Build Coastguard Workerto PROGRAM being missing or too old. 51*7ab6e6acSAndroid Build Coastguard Worker 52*7ab6e6acSAndroid Build Coastguard WorkerOptions: 53*7ab6e6acSAndroid Build Coastguard Worker -h, --help display this help and exit 54*7ab6e6acSAndroid Build Coastguard Worker -v, --version output version information and exit 55*7ab6e6acSAndroid Build Coastguard Worker 56*7ab6e6acSAndroid Build Coastguard WorkerSupported PROGRAM values: 57*7ab6e6acSAndroid Build Coastguard Worker aclocal autoconf autoheader autom4te automake makeinfo 58*7ab6e6acSAndroid Build Coastguard Worker bison yacc flex lex help2man 59*7ab6e6acSAndroid Build Coastguard Worker 60*7ab6e6acSAndroid Build Coastguard WorkerVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61*7ab6e6acSAndroid Build Coastguard Worker'g' are ignored when checking the name. 62*7ab6e6acSAndroid Build Coastguard Worker 63*7ab6e6acSAndroid Build Coastguard WorkerSend bug reports to <[email protected]>." 64*7ab6e6acSAndroid Build Coastguard Worker exit $? 65*7ab6e6acSAndroid Build Coastguard Worker ;; 66*7ab6e6acSAndroid Build Coastguard Worker 67*7ab6e6acSAndroid Build Coastguard Worker -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68*7ab6e6acSAndroid Build Coastguard Worker echo "missing $scriptversion (GNU Automake)" 69*7ab6e6acSAndroid Build Coastguard Worker exit $? 70*7ab6e6acSAndroid Build Coastguard Worker ;; 71*7ab6e6acSAndroid Build Coastguard Worker 72*7ab6e6acSAndroid Build Coastguard Worker -*) 73*7ab6e6acSAndroid Build Coastguard Worker echo 1>&2 "$0: unknown '$1' option" 74*7ab6e6acSAndroid Build Coastguard Worker echo 1>&2 "Try '$0 --help' for more information" 75*7ab6e6acSAndroid Build Coastguard Worker exit 1 76*7ab6e6acSAndroid Build Coastguard Worker ;; 77*7ab6e6acSAndroid Build Coastguard Worker 78*7ab6e6acSAndroid Build Coastguard Workeresac 79*7ab6e6acSAndroid Build Coastguard Worker 80*7ab6e6acSAndroid Build Coastguard Worker# Run the given program, remember its exit status. 81*7ab6e6acSAndroid Build Coastguard Worker"$@"; st=$? 82*7ab6e6acSAndroid Build Coastguard Worker 83*7ab6e6acSAndroid Build Coastguard Worker# If it succeeded, we are done. 84*7ab6e6acSAndroid Build Coastguard Workertest $st -eq 0 && exit 0 85*7ab6e6acSAndroid Build Coastguard Worker 86*7ab6e6acSAndroid Build Coastguard Worker# Also exit now if we it failed (or wasn't found), and '--version' was 87*7ab6e6acSAndroid Build Coastguard Worker# passed; such an option is passed most likely to detect whether the 88*7ab6e6acSAndroid Build Coastguard Worker# program is present and works. 89*7ab6e6acSAndroid Build Coastguard Workercase $2 in --version|--help) exit $st;; esac 90*7ab6e6acSAndroid Build Coastguard Worker 91*7ab6e6acSAndroid Build Coastguard Worker# Exit code 63 means version mismatch. This often happens when the user 92*7ab6e6acSAndroid Build Coastguard Worker# tries to use an ancient version of a tool on a file that requires a 93*7ab6e6acSAndroid Build Coastguard Worker# minimum version. 94*7ab6e6acSAndroid Build Coastguard Workerif test $st -eq 63; then 95*7ab6e6acSAndroid Build Coastguard Worker msg="probably too old" 96*7ab6e6acSAndroid Build Coastguard Workerelif test $st -eq 127; then 97*7ab6e6acSAndroid Build Coastguard Worker # Program was missing. 98*7ab6e6acSAndroid Build Coastguard Worker msg="missing on your system" 99*7ab6e6acSAndroid Build Coastguard Workerelse 100*7ab6e6acSAndroid Build Coastguard Worker # Program was found and executed, but failed. Give up. 101*7ab6e6acSAndroid Build Coastguard Worker exit $st 102*7ab6e6acSAndroid Build Coastguard Workerfi 103*7ab6e6acSAndroid Build Coastguard Worker 104*7ab6e6acSAndroid Build Coastguard Workerperl_URL=https://www.perl.org/ 105*7ab6e6acSAndroid Build Coastguard Workerflex_URL=https://github.com/westes/flex 106*7ab6e6acSAndroid Build Coastguard Workergnu_software_URL=https://www.gnu.org/software 107*7ab6e6acSAndroid Build Coastguard Worker 108*7ab6e6acSAndroid Build Coastguard Workerprogram_details () 109*7ab6e6acSAndroid Build Coastguard Worker{ 110*7ab6e6acSAndroid Build Coastguard Worker case $1 in 111*7ab6e6acSAndroid Build Coastguard Worker aclocal|automake) 112*7ab6e6acSAndroid Build Coastguard Worker echo "The '$1' program is part of the GNU Automake package:" 113*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/automake>" 114*7ab6e6acSAndroid Build Coastguard Worker echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/autoconf>" 116*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/m4/>" 117*7ab6e6acSAndroid Build Coastguard Worker echo "<$perl_URL>" 118*7ab6e6acSAndroid Build Coastguard Worker ;; 119*7ab6e6acSAndroid Build Coastguard Worker autoconf|autom4te|autoheader) 120*7ab6e6acSAndroid Build Coastguard Worker echo "The '$1' program is part of the GNU Autoconf package:" 121*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/autoconf/>" 122*7ab6e6acSAndroid Build Coastguard Worker echo "It also requires GNU m4 and Perl in order to run:" 123*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/m4/>" 124*7ab6e6acSAndroid Build Coastguard Worker echo "<$perl_URL>" 125*7ab6e6acSAndroid Build Coastguard Worker ;; 126*7ab6e6acSAndroid Build Coastguard Worker esac 127*7ab6e6acSAndroid Build Coastguard Worker} 128*7ab6e6acSAndroid Build Coastguard Worker 129*7ab6e6acSAndroid Build Coastguard Workergive_advice () 130*7ab6e6acSAndroid Build Coastguard Worker{ 131*7ab6e6acSAndroid Build Coastguard Worker # Normalize program name to check for. 132*7ab6e6acSAndroid Build Coastguard Worker normalized_program=`echo "$1" | sed ' 133*7ab6e6acSAndroid Build Coastguard Worker s/^gnu-//; t 134*7ab6e6acSAndroid Build Coastguard Worker s/^gnu//; t 135*7ab6e6acSAndroid Build Coastguard Worker s/^g//; t'` 136*7ab6e6acSAndroid Build Coastguard Worker 137*7ab6e6acSAndroid Build Coastguard Worker printf '%s\n' "'$1' is $msg." 138*7ab6e6acSAndroid Build Coastguard Worker 139*7ab6e6acSAndroid Build Coastguard Worker configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140*7ab6e6acSAndroid Build Coastguard Worker case $normalized_program in 141*7ab6e6acSAndroid Build Coastguard Worker autoconf*) 142*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified 'configure.ac'," 143*7ab6e6acSAndroid Build Coastguard Worker echo "or m4 files included by it." 144*7ab6e6acSAndroid Build Coastguard Worker program_details 'autoconf' 145*7ab6e6acSAndroid Build Coastguard Worker ;; 146*7ab6e6acSAndroid Build Coastguard Worker autoheader*) 147*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified 'acconfig.h' or" 148*7ab6e6acSAndroid Build Coastguard Worker echo "$configure_deps." 149*7ab6e6acSAndroid Build Coastguard Worker program_details 'autoheader' 150*7ab6e6acSAndroid Build Coastguard Worker ;; 151*7ab6e6acSAndroid Build Coastguard Worker automake*) 152*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified 'Makefile.am' or" 153*7ab6e6acSAndroid Build Coastguard Worker echo "$configure_deps." 154*7ab6e6acSAndroid Build Coastguard Worker program_details 'automake' 155*7ab6e6acSAndroid Build Coastguard Worker ;; 156*7ab6e6acSAndroid Build Coastguard Worker aclocal*) 157*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified 'acinclude.m4' or" 158*7ab6e6acSAndroid Build Coastguard Worker echo "$configure_deps." 159*7ab6e6acSAndroid Build Coastguard Worker program_details 'aclocal' 160*7ab6e6acSAndroid Build Coastguard Worker ;; 161*7ab6e6acSAndroid Build Coastguard Worker autom4te*) 162*7ab6e6acSAndroid Build Coastguard Worker echo "You might have modified some maintainer files that require" 163*7ab6e6acSAndroid Build Coastguard Worker echo "the 'autom4te' program to be rebuilt." 164*7ab6e6acSAndroid Build Coastguard Worker program_details 'autom4te' 165*7ab6e6acSAndroid Build Coastguard Worker ;; 166*7ab6e6acSAndroid Build Coastguard Worker bison*|yacc*) 167*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified a '.y' file." 168*7ab6e6acSAndroid Build Coastguard Worker echo "You may want to install the GNU Bison package:" 169*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/bison/>" 170*7ab6e6acSAndroid Build Coastguard Worker ;; 171*7ab6e6acSAndroid Build Coastguard Worker lex*|flex*) 172*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified a '.l' file." 173*7ab6e6acSAndroid Build Coastguard Worker echo "You may want to install the Fast Lexical Analyzer package:" 174*7ab6e6acSAndroid Build Coastguard Worker echo "<$flex_URL>" 175*7ab6e6acSAndroid Build Coastguard Worker ;; 176*7ab6e6acSAndroid Build Coastguard Worker help2man*) 177*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified a dependency" \ 178*7ab6e6acSAndroid Build Coastguard Worker "of a man page." 179*7ab6e6acSAndroid Build Coastguard Worker echo "You may want to install the GNU Help2man package:" 180*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/help2man/>" 181*7ab6e6acSAndroid Build Coastguard Worker ;; 182*7ab6e6acSAndroid Build Coastguard Worker makeinfo*) 183*7ab6e6acSAndroid Build Coastguard Worker echo "You should only need it if you modified a '.texi' file, or" 184*7ab6e6acSAndroid Build Coastguard Worker echo "any other file indirectly affecting the aspect of the manual." 185*7ab6e6acSAndroid Build Coastguard Worker echo "You might want to install the Texinfo package:" 186*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/texinfo/>" 187*7ab6e6acSAndroid Build Coastguard Worker echo "The spurious makeinfo call might also be the consequence of" 188*7ab6e6acSAndroid Build Coastguard Worker echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189*7ab6e6acSAndroid Build Coastguard Worker echo "want to install GNU make:" 190*7ab6e6acSAndroid Build Coastguard Worker echo "<$gnu_software_URL/make/>" 191*7ab6e6acSAndroid Build Coastguard Worker ;; 192*7ab6e6acSAndroid Build Coastguard Worker *) 193*7ab6e6acSAndroid Build Coastguard Worker echo "You might have modified some files without having the proper" 194*7ab6e6acSAndroid Build Coastguard Worker echo "tools for further handling them. Check the 'README' file, it" 195*7ab6e6acSAndroid Build Coastguard Worker echo "often tells you about the needed prerequisites for installing" 196*7ab6e6acSAndroid Build Coastguard Worker echo "this package. You may also peek at any GNU archive site, in" 197*7ab6e6acSAndroid Build Coastguard Worker echo "case some other package contains this missing '$1' program." 198*7ab6e6acSAndroid Build Coastguard Worker ;; 199*7ab6e6acSAndroid Build Coastguard Worker esac 200*7ab6e6acSAndroid Build Coastguard Worker} 201*7ab6e6acSAndroid Build Coastguard Worker 202*7ab6e6acSAndroid Build Coastguard Workergive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203*7ab6e6acSAndroid Build Coastguard Worker -e '2,$s/^/ /' >&2 204*7ab6e6acSAndroid Build Coastguard Worker 205*7ab6e6acSAndroid Build Coastguard Worker# Propagate the correct exit status (expected to be 127 for a program 206*7ab6e6acSAndroid Build Coastguard Worker# not found, 63 for a program that failed due to version mismatch). 207*7ab6e6acSAndroid Build Coastguard Workerexit $st 208*7ab6e6acSAndroid Build Coastguard Worker 209*7ab6e6acSAndroid Build Coastguard Worker# Local variables: 210*7ab6e6acSAndroid Build Coastguard Worker# eval: (add-hook 'before-save-hook 'time-stamp) 211*7ab6e6acSAndroid Build Coastguard Worker# time-stamp-start: "scriptversion=" 212*7ab6e6acSAndroid Build Coastguard Worker# time-stamp-format: "%:y-%02m-%02d.%02H" 213*7ab6e6acSAndroid Build Coastguard Worker# time-stamp-time-zone: "UTC0" 214*7ab6e6acSAndroid Build Coastguard Worker# time-stamp-end: "; # UTC" 215*7ab6e6acSAndroid Build Coastguard Worker# End: 216