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