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