1251883Speter#! /bin/sh 2298161Sbapt# Common wrapper for a few potentially missing GNU programs. 3251883Speter 4298161Sbaptscriptversion=2013-10-28.13; # UTC 5251883Speter 6298161Sbapt# Copyright (C) 1996-2014 Free Software Foundation, Inc. 7298161Sbapt# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8251883Speter 9251883Speter# This program is free software; you can redistribute it and/or modify 10251883Speter# it under the terms of the GNU General Public License as published by 11251883Speter# the Free Software Foundation; either version 2, or (at your option) 12251883Speter# any later version. 13251883Speter 14251883Speter# This program is distributed in the hope that it will be useful, 15251883Speter# but WITHOUT ANY WARRANTY; without even the implied warranty of 16251883Speter# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17251883Speter# GNU General Public License for more details. 18251883Speter 19251883Speter# You should have received a copy of the GNU General Public License 20269851Speter# along with this program. If not, see <http://www.gnu.org/licenses/>. 21251883Speter 22251883Speter# As a special exception to the GNU General Public License, if you 23251883Speter# distribute this file as part of a program that contains a 24251883Speter# configuration script generated by Autoconf, you may include it under 25251883Speter# the same distribution terms that you use for the rest of that program. 26251883Speter 27251883Speterif test $# -eq 0; then 28298161Sbapt echo 1>&2 "Try '$0 --help' for more information" 29251883Speter exit 1 30251883Speterfi 31251883Speter 32298161Sbaptcase $1 in 33251883Speter 34298161Sbapt --is-lightweight) 35298161Sbapt # Used by our autoconf macros to check whether the available missing 36298161Sbapt # script is modern enough. 37298161Sbapt exit 0 38298161Sbapt ;; 39251883Speter 40298161Sbapt --run) 41298161Sbapt # Back-compat with the calling convention used by older automake. 42298161Sbapt shift 43298161Sbapt ;; 44251883Speter 45251883Speter -h|--h|--he|--hel|--help) 46251883Speter echo "\ 47251883Speter$0 [OPTION]... PROGRAM [ARGUMENT]... 48251883Speter 49298161SbaptRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50298161Sbaptto PROGRAM being missing or too old. 51251883Speter 52251883SpeterOptions: 53251883Speter -h, --help display this help and exit 54251883Speter -v, --version output version information and exit 55251883Speter 56251883SpeterSupported PROGRAM values: 57298161Sbapt aclocal autoconf autoheader autom4te automake makeinfo 58298161Sbapt bison yacc flex lex help2man 59251883Speter 60298161SbaptVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61298161Sbapt'g' are ignored when checking the name. 62269851Speter 63251883SpeterSend bug reports to <bug-automake@gnu.org>." 64251883Speter exit $? 65251883Speter ;; 66251883Speter 67251883Speter -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68251883Speter echo "missing $scriptversion (GNU Automake)" 69251883Speter exit $? 70251883Speter ;; 71251883Speter 72251883Speter -*) 73298161Sbapt echo 1>&2 "$0: unknown '$1' option" 74298161Sbapt echo 1>&2 "Try '$0 --help' for more information" 75251883Speter exit 1 76251883Speter ;; 77251883Speter 78251883Speteresac 79251883Speter 80298161Sbapt# Run the given program, remember its exit status. 81298161Sbapt"$@"; st=$? 82269851Speter 83298161Sbapt# If it succeeded, we are done. 84298161Sbapttest $st -eq 0 && exit 0 85251883Speter 86298161Sbapt# Also exit now if we it failed (or wasn't found), and '--version' was 87298161Sbapt# passed; such an option is passed most likely to detect whether the 88298161Sbapt# program is present and works. 89298161Sbaptcase $2 in --version|--help) exit $st;; esac 90251883Speter 91298161Sbapt# Exit code 63 means version mismatch. This often happens when the user 92298161Sbapt# tries to use an ancient version of a tool on a file that requires a 93298161Sbapt# minimum version. 94298161Sbaptif test $st -eq 63; then 95298161Sbapt msg="probably too old" 96298161Sbaptelif test $st -eq 127; then 97298161Sbapt # Program was missing. 98298161Sbapt msg="missing on your system" 99298161Sbaptelse 100298161Sbapt # Program was found and executed, but failed. Give up. 101298161Sbapt exit $st 102298161Sbaptfi 103251883Speter 104298161Sbaptperl_URL=http://www.perl.org/ 105298161Sbaptflex_URL=http://flex.sourceforge.net/ 106298161Sbaptgnu_software_URL=http://www.gnu.org/software 107251883Speter 108298161Sbaptprogram_details () 109298161Sbapt{ 110298161Sbapt case $1 in 111298161Sbapt aclocal|automake) 112298161Sbapt echo "The '$1' program is part of the GNU Automake package:" 113298161Sbapt echo "<$gnu_software_URL/automake>" 114298161Sbapt echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115298161Sbapt echo "<$gnu_software_URL/autoconf>" 116298161Sbapt echo "<$gnu_software_URL/m4/>" 117298161Sbapt echo "<$perl_URL>" 118298161Sbapt ;; 119298161Sbapt autoconf|autom4te|autoheader) 120298161Sbapt echo "The '$1' program is part of the GNU Autoconf package:" 121298161Sbapt echo "<$gnu_software_URL/autoconf/>" 122298161Sbapt echo "It also requires GNU m4 and Perl in order to run:" 123298161Sbapt echo "<$gnu_software_URL/m4/>" 124298161Sbapt echo "<$perl_URL>" 125298161Sbapt ;; 126298161Sbapt esac 127298161Sbapt} 128251883Speter 129298161Sbaptgive_advice () 130298161Sbapt{ 131298161Sbapt # Normalize program name to check for. 132298161Sbapt normalized_program=`echo "$1" | sed ' 133298161Sbapt s/^gnu-//; t 134298161Sbapt s/^gnu//; t 135298161Sbapt s/^g//; t'` 136251883Speter 137298161Sbapt printf '%s\n' "'$1' is $msg." 138251883Speter 139298161Sbapt configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140298161Sbapt case $normalized_program in 141298161Sbapt autoconf*) 142298161Sbapt echo "You should only need it if you modified 'configure.ac'," 143298161Sbapt echo "or m4 files included by it." 144298161Sbapt program_details 'autoconf' 145298161Sbapt ;; 146298161Sbapt autoheader*) 147298161Sbapt echo "You should only need it if you modified 'acconfig.h' or" 148298161Sbapt echo "$configure_deps." 149298161Sbapt program_details 'autoheader' 150298161Sbapt ;; 151298161Sbapt automake*) 152298161Sbapt echo "You should only need it if you modified 'Makefile.am' or" 153298161Sbapt echo "$configure_deps." 154298161Sbapt program_details 'automake' 155298161Sbapt ;; 156298161Sbapt aclocal*) 157298161Sbapt echo "You should only need it if you modified 'acinclude.m4' or" 158298161Sbapt echo "$configure_deps." 159298161Sbapt program_details 'aclocal' 160298161Sbapt ;; 161298161Sbapt autom4te*) 162298161Sbapt echo "You might have modified some maintainer files that require" 163298161Sbapt echo "the 'autom4te' program to be rebuilt." 164298161Sbapt program_details 'autom4te' 165298161Sbapt ;; 166298161Sbapt bison*|yacc*) 167298161Sbapt echo "You should only need it if you modified a '.y' file." 168298161Sbapt echo "You may want to install the GNU Bison package:" 169298161Sbapt echo "<$gnu_software_URL/bison/>" 170298161Sbapt ;; 171298161Sbapt lex*|flex*) 172298161Sbapt echo "You should only need it if you modified a '.l' file." 173298161Sbapt echo "You may want to install the Fast Lexical Analyzer package:" 174298161Sbapt echo "<$flex_URL>" 175298161Sbapt ;; 176298161Sbapt help2man*) 177298161Sbapt echo "You should only need it if you modified a dependency" \ 178298161Sbapt "of a man page." 179298161Sbapt echo "You may want to install the GNU Help2man package:" 180298161Sbapt echo "<$gnu_software_URL/help2man/>" 181251883Speter ;; 182298161Sbapt makeinfo*) 183298161Sbapt echo "You should only need it if you modified a '.texi' file, or" 184298161Sbapt echo "any other file indirectly affecting the aspect of the manual." 185298161Sbapt echo "You might want to install the Texinfo package:" 186298161Sbapt echo "<$gnu_software_URL/texinfo/>" 187298161Sbapt echo "The spurious makeinfo call might also be the consequence of" 188298161Sbapt echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189298161Sbapt echo "want to install GNU make:" 190298161Sbapt echo "<$gnu_software_URL/make/>" 191298161Sbapt ;; 192298161Sbapt *) 193298161Sbapt echo "You might have modified some files without having the proper" 194298161Sbapt echo "tools for further handling them. Check the 'README' file, it" 195298161Sbapt echo "often tells you about the needed prerequisites for installing" 196298161Sbapt echo "this package. You may also peek at any GNU archive site, in" 197298161Sbapt echo "case some other package contains this missing '$1' program." 198298161Sbapt ;; 199298161Sbapt esac 200298161Sbapt} 201251883Speter 202298161Sbaptgive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203298161Sbapt -e '2,$s/^/ /' >&2 204251883Speter 205298161Sbapt# Propagate the correct exit status (expected to be 127 for a program 206298161Sbapt# not found, 63 for a program that failed due to version mismatch). 207298161Sbaptexit $st 208251883Speter 209251883Speter# Local variables: 210251883Speter# eval: (add-hook 'write-file-hooks 'time-stamp) 211251883Speter# time-stamp-start: "scriptversion=" 212251883Speter# time-stamp-format: "%:y-%02m-%02d.%02H" 213269851Speter# time-stamp-time-zone: "UTC" 214269851Speter# time-stamp-end: "; # UTC" 215251883Speter# End: 216