12de962bdSlukem#! /bin/sh 2*e670fd5cSchristos# Common wrapper for a few potentially missing GNU programs. 32de962bdSlukem 4*e670fd5cSchristosscriptversion=2013-10-28.13; # UTC 52de962bdSlukem 6*e670fd5cSchristos# Copyright (C) 1996-2014 Free Software Foundation, Inc. 7*e670fd5cSchristos# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 82de962bdSlukem 92de962bdSlukem# This program is free software; you can redistribute it and/or modify 102de962bdSlukem# it under the terms of the GNU General Public License as published by 112de962bdSlukem# the Free Software Foundation; either version 2, or (at your option) 122de962bdSlukem# any later version. 132de962bdSlukem 142de962bdSlukem# This program is distributed in the hope that it will be useful, 152de962bdSlukem# but WITHOUT ANY WARRANTY; without even the implied warranty of 162de962bdSlukem# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 172de962bdSlukem# GNU General Public License for more details. 182de962bdSlukem 192de962bdSlukem# You should have received a copy of the GNU General Public License 20*e670fd5cSchristos# along with this program. If not, see <http://www.gnu.org/licenses/>. 212de962bdSlukem 222de962bdSlukem# As a special exception to the GNU General Public License, if you 232de962bdSlukem# distribute this file as part of a program that contains a 242de962bdSlukem# configuration script generated by Autoconf, you may include it under 252de962bdSlukem# the same distribution terms that you use for the rest of that program. 262de962bdSlukem 272de962bdSlukemif test $# -eq 0; then 28*e670fd5cSchristos echo 1>&2 "Try '$0 --help' for more information" 292de962bdSlukem exit 1 302de962bdSlukemfi 312de962bdSlukem 32*e670fd5cSchristoscase $1 in 332de962bdSlukem 34*e670fd5cSchristos --is-lightweight) 35*e670fd5cSchristos # Used by our autoconf macros to check whether the available missing 36*e670fd5cSchristos # script is modern enough. 37*e670fd5cSchristos exit 0 38*e670fd5cSchristos ;; 392de962bdSlukem 402de962bdSlukem --run) 41*e670fd5cSchristos # Back-compat with the calling convention used by older automake. 422de962bdSlukem shift 432de962bdSlukem ;; 442de962bdSlukem 452de962bdSlukem -h|--h|--he|--hel|--help) 462de962bdSlukem echo "\ 472de962bdSlukem$0 [OPTION]... PROGRAM [ARGUMENT]... 482de962bdSlukem 49*e670fd5cSchristosRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50*e670fd5cSchristosto PROGRAM being missing or too old. 512de962bdSlukem 522de962bdSlukemOptions: 532de962bdSlukem -h, --help display this help and exit 542de962bdSlukem -v, --version output version information and exit 552de962bdSlukem 562de962bdSlukemSupported PROGRAM values: 57*e670fd5cSchristos aclocal autoconf autoheader autom4te automake makeinfo 58*e670fd5cSchristos bison yacc flex lex help2man 59*e670fd5cSchristos 60*e670fd5cSchristosVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61*e670fd5cSchristos'g' are ignored when checking the name. 622de962bdSlukem 632de962bdSlukemSend bug reports to <bug-automake@gnu.org>." 642de962bdSlukem exit $? 652de962bdSlukem ;; 662de962bdSlukem 672de962bdSlukem -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 682de962bdSlukem echo "missing $scriptversion (GNU Automake)" 692de962bdSlukem exit $? 702de962bdSlukem ;; 712de962bdSlukem 722de962bdSlukem -*) 73*e670fd5cSchristos echo 1>&2 "$0: unknown '$1' option" 74*e670fd5cSchristos echo 1>&2 "Try '$0 --help' for more information" 752de962bdSlukem exit 1 762de962bdSlukem ;; 772de962bdSlukem 782de962bdSlukemesac 792de962bdSlukem 80*e670fd5cSchristos# Run the given program, remember its exit status. 81*e670fd5cSchristos"$@"; st=$? 822de962bdSlukem 83*e670fd5cSchristos# If it succeeded, we are done. 84*e670fd5cSchristostest $st -eq 0 && exit 0 85*e670fd5cSchristos 86*e670fd5cSchristos# Also exit now if we it failed (or wasn't found), and '--version' was 87*e670fd5cSchristos# passed; such an option is passed most likely to detect whether the 88*e670fd5cSchristos# program is present and works. 89*e670fd5cSchristoscase $2 in --version|--help) exit $st;; esac 90*e670fd5cSchristos 91*e670fd5cSchristos# Exit code 63 means version mismatch. This often happens when the user 92*e670fd5cSchristos# tries to use an ancient version of a tool on a file that requires a 93*e670fd5cSchristos# minimum version. 94*e670fd5cSchristosif test $st -eq 63; then 95*e670fd5cSchristos msg="probably too old" 96*e670fd5cSchristoselif test $st -eq 127; then 97*e670fd5cSchristos # Program was missing. 98*e670fd5cSchristos msg="missing on your system" 99*e670fd5cSchristoselse 100*e670fd5cSchristos # Program was found and executed, but failed. Give up. 101*e670fd5cSchristos exit $st 1022de962bdSlukemfi 1032de962bdSlukem 104*e670fd5cSchristosperl_URL=http://www.perl.org/ 105*e670fd5cSchristosflex_URL=http://flex.sourceforge.net/ 106*e670fd5cSchristosgnu_software_URL=http://www.gnu.org/software 107*e670fd5cSchristos 108*e670fd5cSchristosprogram_details () 109*e670fd5cSchristos{ 110*e670fd5cSchristos case $1 in 111*e670fd5cSchristos aclocal|automake) 112*e670fd5cSchristos echo "The '$1' program is part of the GNU Automake package:" 113*e670fd5cSchristos echo "<$gnu_software_URL/automake>" 114*e670fd5cSchristos echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115*e670fd5cSchristos echo "<$gnu_software_URL/autoconf>" 116*e670fd5cSchristos echo "<$gnu_software_URL/m4/>" 117*e670fd5cSchristos echo "<$perl_URL>" 118*e670fd5cSchristos ;; 119*e670fd5cSchristos autoconf|autom4te|autoheader) 120*e670fd5cSchristos echo "The '$1' program is part of the GNU Autoconf package:" 121*e670fd5cSchristos echo "<$gnu_software_URL/autoconf/>" 122*e670fd5cSchristos echo "It also requires GNU m4 and Perl in order to run:" 123*e670fd5cSchristos echo "<$gnu_software_URL/m4/>" 124*e670fd5cSchristos echo "<$perl_URL>" 1252de962bdSlukem ;; 1262de962bdSlukem esac 127*e670fd5cSchristos} 1282de962bdSlukem 129*e670fd5cSchristosgive_advice () 130*e670fd5cSchristos{ 131*e670fd5cSchristos # Normalize program name to check for. 132*e670fd5cSchristos normalized_program=`echo "$1" | sed ' 133*e670fd5cSchristos s/^gnu-//; t 134*e670fd5cSchristos s/^gnu//; t 135*e670fd5cSchristos s/^g//; t'` 136*e670fd5cSchristos 137*e670fd5cSchristos printf '%s\n' "'$1' is $msg." 138*e670fd5cSchristos 139*e670fd5cSchristos configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140*e670fd5cSchristos case $normalized_program in 141*e670fd5cSchristos autoconf*) 142*e670fd5cSchristos echo "You should only need it if you modified 'configure.ac'," 143*e670fd5cSchristos echo "or m4 files included by it." 144*e670fd5cSchristos program_details 'autoconf' 1452de962bdSlukem ;; 146*e670fd5cSchristos autoheader*) 147*e670fd5cSchristos echo "You should only need it if you modified 'acconfig.h' or" 148*e670fd5cSchristos echo "$configure_deps." 149*e670fd5cSchristos program_details 'autoheader' 1502de962bdSlukem ;; 1512de962bdSlukem automake*) 152*e670fd5cSchristos echo "You should only need it if you modified 'Makefile.am' or" 153*e670fd5cSchristos echo "$configure_deps." 154*e670fd5cSchristos program_details 'automake' 1552de962bdSlukem ;; 156*e670fd5cSchristos aclocal*) 157*e670fd5cSchristos echo "You should only need it if you modified 'acinclude.m4' or" 158*e670fd5cSchristos echo "$configure_deps." 159*e670fd5cSchristos program_details 'aclocal' 1602de962bdSlukem ;; 161*e670fd5cSchristos autom4te*) 162*e670fd5cSchristos echo "You might have modified some maintainer files that require" 163*e670fd5cSchristos echo "the 'autom4te' program to be rebuilt." 164*e670fd5cSchristos program_details 'autom4te' 1652de962bdSlukem ;; 166*e670fd5cSchristos bison*|yacc*) 167*e670fd5cSchristos echo "You should only need it if you modified a '.y' file." 168*e670fd5cSchristos echo "You may want to install the GNU Bison package:" 169*e670fd5cSchristos echo "<$gnu_software_URL/bison/>" 1702de962bdSlukem ;; 171*e670fd5cSchristos lex*|flex*) 172*e670fd5cSchristos echo "You should only need it if you modified a '.l' file." 173*e670fd5cSchristos echo "You may want to install the Fast Lexical Analyzer package:" 174*e670fd5cSchristos echo "<$flex_URL>" 1752de962bdSlukem ;; 176*e670fd5cSchristos help2man*) 177*e670fd5cSchristos echo "You should only need it if you modified a dependency" \ 178*e670fd5cSchristos "of a man page." 179*e670fd5cSchristos echo "You may want to install the GNU Help2man package:" 180*e670fd5cSchristos echo "<$gnu_software_URL/help2man/>" 1812de962bdSlukem ;; 182*e670fd5cSchristos makeinfo*) 183*e670fd5cSchristos echo "You should only need it if you modified a '.texi' file, or" 184*e670fd5cSchristos echo "any other file indirectly affecting the aspect of the manual." 185*e670fd5cSchristos echo "You might want to install the Texinfo package:" 186*e670fd5cSchristos echo "<$gnu_software_URL/texinfo/>" 187*e670fd5cSchristos echo "The spurious makeinfo call might also be the consequence of" 188*e670fd5cSchristos echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189*e670fd5cSchristos echo "want to install GNU make:" 190*e670fd5cSchristos echo "<$gnu_software_URL/make/>" 1912de962bdSlukem ;; 1922de962bdSlukem *) 193*e670fd5cSchristos echo "You might have modified some files without having the proper" 194*e670fd5cSchristos echo "tools for further handling them. Check the 'README' file, it" 195*e670fd5cSchristos echo "often tells you about the needed prerequisites for installing" 196*e670fd5cSchristos echo "this package. You may also peek at any GNU archive site, in" 197*e670fd5cSchristos echo "case some other package contains this missing '$1' program." 1982de962bdSlukem ;; 1992de962bdSlukem esac 200*e670fd5cSchristos} 2012de962bdSlukem 202*e670fd5cSchristosgive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203*e670fd5cSchristos -e '2,$s/^/ /' >&2 204*e670fd5cSchristos 205*e670fd5cSchristos# Propagate the correct exit status (expected to be 127 for a program 206*e670fd5cSchristos# not found, 63 for a program that failed due to version mismatch). 207*e670fd5cSchristosexit $st 2082de962bdSlukem 2092de962bdSlukem# Local variables: 2102de962bdSlukem# eval: (add-hook 'write-file-hooks 'time-stamp) 2112de962bdSlukem# time-stamp-start: "scriptversion=" 2122de962bdSlukem# time-stamp-format: "%:y-%02m-%02d.%02H" 213*e670fd5cSchristos# time-stamp-time-zone: "UTC" 214*e670fd5cSchristos# time-stamp-end: "; # UTC" 2152de962bdSlukem# End: 216