1603fc0a3Smrg#! /bin/sh 2603fc0a3Smrg# Common wrapper for a few potentially missing GNU programs. 3603fc0a3Smrg 4603fc0a3Smrgscriptversion=2018-03-07.03; # UTC 5603fc0a3Smrg 6603fc0a3Smrg# Copyright (C) 1996-2018 Free Software Foundation, Inc. 7603fc0a3Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8603fc0a3Smrg 9603fc0a3Smrg# This program is free software; you can redistribute it and/or modify 10603fc0a3Smrg# it under the terms of the GNU General Public License as published by 11603fc0a3Smrg# the Free Software Foundation; either version 2, or (at your option) 12603fc0a3Smrg# any later version. 13603fc0a3Smrg 14603fc0a3Smrg# This program is distributed in the hope that it will be useful, 15603fc0a3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16603fc0a3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17603fc0a3Smrg# GNU General Public License for more details. 18603fc0a3Smrg 19603fc0a3Smrg# You should have received a copy of the GNU General Public License 20603fc0a3Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21603fc0a3Smrg 22603fc0a3Smrg# As a special exception to the GNU General Public License, if you 23603fc0a3Smrg# distribute this file as part of a program that contains a 24603fc0a3Smrg# configuration script generated by Autoconf, you may include it under 25603fc0a3Smrg# the same distribution terms that you use for the rest of that program. 26603fc0a3Smrg 27603fc0a3Smrgif test $# -eq 0; then 28603fc0a3Smrg echo 1>&2 "Try '$0 --help' for more information" 29603fc0a3Smrg exit 1 30603fc0a3Smrgfi 31603fc0a3Smrg 32603fc0a3Smrgcase $1 in 33603fc0a3Smrg 34603fc0a3Smrg --is-lightweight) 35603fc0a3Smrg # Used by our autoconf macros to check whether the available missing 36603fc0a3Smrg # script is modern enough. 37603fc0a3Smrg exit 0 38603fc0a3Smrg ;; 39603fc0a3Smrg 40603fc0a3Smrg --run) 41603fc0a3Smrg # Back-compat with the calling convention used by older automake. 42603fc0a3Smrg shift 43603fc0a3Smrg ;; 44603fc0a3Smrg 45603fc0a3Smrg -h|--h|--he|--hel|--help) 46603fc0a3Smrg echo "\ 47603fc0a3Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48603fc0a3Smrg 49603fc0a3SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50603fc0a3Smrgto PROGRAM being missing or too old. 51603fc0a3Smrg 52603fc0a3SmrgOptions: 53603fc0a3Smrg -h, --help display this help and exit 54603fc0a3Smrg -v, --version output version information and exit 55603fc0a3Smrg 56603fc0a3SmrgSupported PROGRAM values: 57603fc0a3Smrg aclocal autoconf autoheader autom4te automake makeinfo 58603fc0a3Smrg bison yacc flex lex help2man 59603fc0a3Smrg 60603fc0a3SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61603fc0a3Smrg'g' are ignored when checking the name. 62603fc0a3Smrg 63603fc0a3SmrgSend bug reports to <bug-automake@gnu.org>." 64603fc0a3Smrg exit $? 65603fc0a3Smrg ;; 66603fc0a3Smrg 67603fc0a3Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68603fc0a3Smrg echo "missing $scriptversion (GNU Automake)" 69603fc0a3Smrg exit $? 70603fc0a3Smrg ;; 71603fc0a3Smrg 72603fc0a3Smrg -*) 73603fc0a3Smrg echo 1>&2 "$0: unknown '$1' option" 74603fc0a3Smrg echo 1>&2 "Try '$0 --help' for more information" 75603fc0a3Smrg exit 1 76603fc0a3Smrg ;; 77603fc0a3Smrg 78603fc0a3Smrgesac 79603fc0a3Smrg 80603fc0a3Smrg# Run the given program, remember its exit status. 81603fc0a3Smrg"$@"; st=$? 82603fc0a3Smrg 83603fc0a3Smrg# If it succeeded, we are done. 84603fc0a3Smrgtest $st -eq 0 && exit 0 85603fc0a3Smrg 86603fc0a3Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87603fc0a3Smrg# passed; such an option is passed most likely to detect whether the 88603fc0a3Smrg# program is present and works. 89603fc0a3Smrgcase $2 in --version|--help) exit $st;; esac 90603fc0a3Smrg 91603fc0a3Smrg# Exit code 63 means version mismatch. This often happens when the user 92603fc0a3Smrg# tries to use an ancient version of a tool on a file that requires a 93603fc0a3Smrg# minimum version. 94603fc0a3Smrgif test $st -eq 63; then 95603fc0a3Smrg msg="probably too old" 96603fc0a3Smrgelif test $st -eq 127; then 97603fc0a3Smrg # Program was missing. 98603fc0a3Smrg msg="missing on your system" 99603fc0a3Smrgelse 100603fc0a3Smrg # Program was found and executed, but failed. Give up. 101603fc0a3Smrg exit $st 102603fc0a3Smrgfi 103603fc0a3Smrg 104603fc0a3Smrgperl_URL=https://www.perl.org/ 105603fc0a3Smrgflex_URL=https://github.com/westes/flex 106603fc0a3Smrggnu_software_URL=https://www.gnu.org/software 107603fc0a3Smrg 108603fc0a3Smrgprogram_details () 109603fc0a3Smrg{ 110603fc0a3Smrg case $1 in 111603fc0a3Smrg aclocal|automake) 112603fc0a3Smrg echo "The '$1' program is part of the GNU Automake package:" 113603fc0a3Smrg echo "<$gnu_software_URL/automake>" 114603fc0a3Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115603fc0a3Smrg echo "<$gnu_software_URL/autoconf>" 116603fc0a3Smrg echo "<$gnu_software_URL/m4/>" 117603fc0a3Smrg echo "<$perl_URL>" 118603fc0a3Smrg ;; 119603fc0a3Smrg autoconf|autom4te|autoheader) 120603fc0a3Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121603fc0a3Smrg echo "<$gnu_software_URL/autoconf/>" 122603fc0a3Smrg echo "It also requires GNU m4 and Perl in order to run:" 123603fc0a3Smrg echo "<$gnu_software_URL/m4/>" 124603fc0a3Smrg echo "<$perl_URL>" 125603fc0a3Smrg ;; 126603fc0a3Smrg esac 127603fc0a3Smrg} 128603fc0a3Smrg 129603fc0a3Smrggive_advice () 130603fc0a3Smrg{ 131603fc0a3Smrg # Normalize program name to check for. 132603fc0a3Smrg normalized_program=`echo "$1" | sed ' 133603fc0a3Smrg s/^gnu-//; t 134603fc0a3Smrg s/^gnu//; t 135603fc0a3Smrg s/^g//; t'` 136603fc0a3Smrg 137603fc0a3Smrg printf '%s\n' "'$1' is $msg." 138603fc0a3Smrg 139603fc0a3Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140603fc0a3Smrg case $normalized_program in 141603fc0a3Smrg autoconf*) 142603fc0a3Smrg echo "You should only need it if you modified 'configure.ac'," 143603fc0a3Smrg echo "or m4 files included by it." 144603fc0a3Smrg program_details 'autoconf' 145603fc0a3Smrg ;; 146603fc0a3Smrg autoheader*) 147603fc0a3Smrg echo "You should only need it if you modified 'acconfig.h' or" 148603fc0a3Smrg echo "$configure_deps." 149603fc0a3Smrg program_details 'autoheader' 150603fc0a3Smrg ;; 151603fc0a3Smrg automake*) 152603fc0a3Smrg echo "You should only need it if you modified 'Makefile.am' or" 153603fc0a3Smrg echo "$configure_deps." 154603fc0a3Smrg program_details 'automake' 155603fc0a3Smrg ;; 156603fc0a3Smrg aclocal*) 157603fc0a3Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158603fc0a3Smrg echo "$configure_deps." 159603fc0a3Smrg program_details 'aclocal' 160603fc0a3Smrg ;; 161603fc0a3Smrg autom4te*) 162603fc0a3Smrg echo "You might have modified some maintainer files that require" 163603fc0a3Smrg echo "the 'autom4te' program to be rebuilt." 164603fc0a3Smrg program_details 'autom4te' 165603fc0a3Smrg ;; 166603fc0a3Smrg bison*|yacc*) 167603fc0a3Smrg echo "You should only need it if you modified a '.y' file." 168603fc0a3Smrg echo "You may want to install the GNU Bison package:" 169603fc0a3Smrg echo "<$gnu_software_URL/bison/>" 170603fc0a3Smrg ;; 171603fc0a3Smrg lex*|flex*) 172603fc0a3Smrg echo "You should only need it if you modified a '.l' file." 173603fc0a3Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174603fc0a3Smrg echo "<$flex_URL>" 175603fc0a3Smrg ;; 176603fc0a3Smrg help2man*) 177603fc0a3Smrg echo "You should only need it if you modified a dependency" \ 178603fc0a3Smrg "of a man page." 179603fc0a3Smrg echo "You may want to install the GNU Help2man package:" 180603fc0a3Smrg echo "<$gnu_software_URL/help2man/>" 181603fc0a3Smrg ;; 182603fc0a3Smrg makeinfo*) 183603fc0a3Smrg echo "You should only need it if you modified a '.texi' file, or" 184603fc0a3Smrg echo "any other file indirectly affecting the aspect of the manual." 185603fc0a3Smrg echo "You might want to install the Texinfo package:" 186603fc0a3Smrg echo "<$gnu_software_URL/texinfo/>" 187603fc0a3Smrg echo "The spurious makeinfo call might also be the consequence of" 188603fc0a3Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189603fc0a3Smrg echo "want to install GNU make:" 190603fc0a3Smrg echo "<$gnu_software_URL/make/>" 191603fc0a3Smrg ;; 192603fc0a3Smrg *) 193603fc0a3Smrg echo "You might have modified some files without having the proper" 194603fc0a3Smrg echo "tools for further handling them. Check the 'README' file, it" 195603fc0a3Smrg echo "often tells you about the needed prerequisites for installing" 196603fc0a3Smrg echo "this package. You may also peek at any GNU archive site, in" 197603fc0a3Smrg echo "case some other package contains this missing '$1' program." 198603fc0a3Smrg ;; 199603fc0a3Smrg esac 200603fc0a3Smrg} 201603fc0a3Smrg 202603fc0a3Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203603fc0a3Smrg -e '2,$s/^/ /' >&2 204603fc0a3Smrg 205603fc0a3Smrg# Propagate the correct exit status (expected to be 127 for a program 206603fc0a3Smrg# not found, 63 for a program that failed due to version mismatch). 207603fc0a3Smrgexit $st 208603fc0a3Smrg 209603fc0a3Smrg# Local variables: 210603fc0a3Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211603fc0a3Smrg# time-stamp-start: "scriptversion=" 212603fc0a3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213603fc0a3Smrg# time-stamp-time-zone: "UTC0" 214603fc0a3Smrg# time-stamp-end: "; # UTC" 215603fc0a3Smrg# End: 216