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