1659607e0Smrg#! /bin/sh 2370b807fSmrg# Common wrapper for a few potentially missing GNU programs. 3659607e0Smrg 4370b807fSmrgscriptversion=2018-03-07.03; # UTC 5659607e0Smrg 6370b807fSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7370b807fSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8659607e0Smrg 9659607e0Smrg# This program is free software; you can redistribute it and/or modify 10659607e0Smrg# it under the terms of the GNU General Public License as published by 11659607e0Smrg# the Free Software Foundation; either version 2, or (at your option) 12659607e0Smrg# any later version. 13659607e0Smrg 14659607e0Smrg# This program is distributed in the hope that it will be useful, 15659607e0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16659607e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17659607e0Smrg# GNU General Public License for more details. 18659607e0Smrg 19659607e0Smrg# You should have received a copy of the GNU General Public License 20370b807fSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21659607e0Smrg 22659607e0Smrg# As a special exception to the GNU General Public License, if you 23659607e0Smrg# distribute this file as part of a program that contains a 24659607e0Smrg# configuration script generated by Autoconf, you may include it under 25659607e0Smrg# the same distribution terms that you use for the rest of that program. 26659607e0Smrg 27659607e0Smrgif test $# -eq 0; then 28a73597f9Smrg echo 1>&2 "Try '$0 --help' for more information" 29659607e0Smrg exit 1 30659607e0Smrgfi 31659607e0Smrg 32370b807fSmrgcase $1 in 33659607e0Smrg 34370b807fSmrg --is-lightweight) 35370b807fSmrg # Used by our autoconf macros to check whether the available missing 36370b807fSmrg # script is modern enough. 37370b807fSmrg exit 0 38370b807fSmrg ;; 39e4da38afSmrg 40370b807fSmrg --run) 41370b807fSmrg # Back-compat with the calling convention used by older automake. 42370b807fSmrg shift 43370b807fSmrg ;; 44659607e0Smrg 45659607e0Smrg -h|--h|--he|--hel|--help) 46659607e0Smrg echo "\ 47659607e0Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48659607e0Smrg 49370b807fSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50370b807fSmrgto PROGRAM being missing or too old. 51659607e0Smrg 52659607e0SmrgOptions: 53659607e0Smrg -h, --help display this help and exit 54659607e0Smrg -v, --version output version information and exit 55659607e0Smrg 56659607e0SmrgSupported PROGRAM values: 57370b807fSmrg aclocal autoconf autoheader autom4te automake makeinfo 58370b807fSmrg bison yacc flex lex help2man 59659607e0Smrg 60a73597f9SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61a73597f9Smrg'g' are ignored when checking the name. 62b73be646Smrg 63659607e0SmrgSend bug reports to <bug-automake@gnu.org>." 64659607e0Smrg exit $? 65659607e0Smrg ;; 66659607e0Smrg 67659607e0Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68659607e0Smrg echo "missing $scriptversion (GNU Automake)" 69659607e0Smrg exit $? 70659607e0Smrg ;; 71659607e0Smrg 72659607e0Smrg -*) 73370b807fSmrg echo 1>&2 "$0: unknown '$1' option" 74a73597f9Smrg echo 1>&2 "Try '$0 --help' for more information" 75659607e0Smrg exit 1 76659607e0Smrg ;; 77659607e0Smrg 78659607e0Smrgesac 79659607e0Smrg 80370b807fSmrg# Run the given program, remember its exit status. 81370b807fSmrg"$@"; st=$? 82370b807fSmrg 83370b807fSmrg# If it succeeded, we are done. 84370b807fSmrgtest $st -eq 0 && exit 0 85370b807fSmrg 86370b807fSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87370b807fSmrg# passed; such an option is passed most likely to detect whether the 88370b807fSmrg# program is present and works. 89370b807fSmrgcase $2 in --version|--help) exit $st;; esac 90370b807fSmrg 91370b807fSmrg# Exit code 63 means version mismatch. This often happens when the user 92370b807fSmrg# tries to use an ancient version of a tool on a file that requires a 93370b807fSmrg# minimum version. 94370b807fSmrgif test $st -eq 63; then 95370b807fSmrg msg="probably too old" 96370b807fSmrgelif test $st -eq 127; then 97370b807fSmrg # Program was missing. 98370b807fSmrg msg="missing on your system" 99370b807fSmrgelse 100370b807fSmrg # Program was found and executed, but failed. Give up. 101370b807fSmrg exit $st 102370b807fSmrgfi 103e4da38afSmrg 104370b807fSmrgperl_URL=https://www.perl.org/ 105370b807fSmrgflex_URL=https://github.com/westes/flex 106370b807fSmrggnu_software_URL=https://www.gnu.org/software 107370b807fSmrg 108370b807fSmrgprogram_details () 109370b807fSmrg{ 110370b807fSmrg case $1 in 111370b807fSmrg aclocal|automake) 112370b807fSmrg echo "The '$1' program is part of the GNU Automake package:" 113370b807fSmrg echo "<$gnu_software_URL/automake>" 114370b807fSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115370b807fSmrg echo "<$gnu_software_URL/autoconf>" 116370b807fSmrg echo "<$gnu_software_URL/m4/>" 117370b807fSmrg echo "<$perl_URL>" 118370b807fSmrg ;; 119370b807fSmrg autoconf|autom4te|autoheader) 120370b807fSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121370b807fSmrg echo "<$gnu_software_URL/autoconf/>" 122370b807fSmrg echo "It also requires GNU m4 and Perl in order to run:" 123370b807fSmrg echo "<$gnu_software_URL/m4/>" 124370b807fSmrg echo "<$perl_URL>" 125370b807fSmrg ;; 126370b807fSmrg esac 127370b807fSmrg} 128370b807fSmrg 129370b807fSmrggive_advice () 130370b807fSmrg{ 131370b807fSmrg # Normalize program name to check for. 132370b807fSmrg normalized_program=`echo "$1" | sed ' 133370b807fSmrg s/^gnu-//; t 134370b807fSmrg s/^gnu//; t 135370b807fSmrg s/^g//; t'` 136370b807fSmrg 137370b807fSmrg printf '%s\n' "'$1' is $msg." 138370b807fSmrg 139370b807fSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140370b807fSmrg case $normalized_program in 141370b807fSmrg autoconf*) 142370b807fSmrg echo "You should only need it if you modified 'configure.ac'," 143370b807fSmrg echo "or m4 files included by it." 144370b807fSmrg program_details 'autoconf' 145370b807fSmrg ;; 146370b807fSmrg autoheader*) 147370b807fSmrg echo "You should only need it if you modified 'acconfig.h' or" 148370b807fSmrg echo "$configure_deps." 149370b807fSmrg program_details 'autoheader' 150370b807fSmrg ;; 151370b807fSmrg automake*) 152370b807fSmrg echo "You should only need it if you modified 'Makefile.am' or" 153370b807fSmrg echo "$configure_deps." 154370b807fSmrg program_details 'automake' 155370b807fSmrg ;; 156370b807fSmrg aclocal*) 157370b807fSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158370b807fSmrg echo "$configure_deps." 159370b807fSmrg program_details 'aclocal' 160370b807fSmrg ;; 161370b807fSmrg autom4te*) 162370b807fSmrg echo "You might have modified some maintainer files that require" 163370b807fSmrg echo "the 'autom4te' program to be rebuilt." 164370b807fSmrg program_details 'autom4te' 165370b807fSmrg ;; 166370b807fSmrg bison*|yacc*) 167370b807fSmrg echo "You should only need it if you modified a '.y' file." 168370b807fSmrg echo "You may want to install the GNU Bison package:" 169370b807fSmrg echo "<$gnu_software_URL/bison/>" 170370b807fSmrg ;; 171370b807fSmrg lex*|flex*) 172370b807fSmrg echo "You should only need it if you modified a '.l' file." 173370b807fSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174370b807fSmrg echo "<$flex_URL>" 175370b807fSmrg ;; 176370b807fSmrg help2man*) 177370b807fSmrg echo "You should only need it if you modified a dependency" \ 178370b807fSmrg "of a man page." 179370b807fSmrg echo "You may want to install the GNU Help2man package:" 180370b807fSmrg echo "<$gnu_software_URL/help2man/>" 181e4da38afSmrg ;; 182370b807fSmrg makeinfo*) 183370b807fSmrg echo "You should only need it if you modified a '.texi' file, or" 184370b807fSmrg echo "any other file indirectly affecting the aspect of the manual." 185370b807fSmrg echo "You might want to install the Texinfo package:" 186370b807fSmrg echo "<$gnu_software_URL/texinfo/>" 187370b807fSmrg echo "The spurious makeinfo call might also be the consequence of" 188370b807fSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189370b807fSmrg echo "want to install GNU make:" 190370b807fSmrg echo "<$gnu_software_URL/make/>" 191370b807fSmrg ;; 192370b807fSmrg *) 193370b807fSmrg echo "You might have modified some files without having the proper" 194370b807fSmrg echo "tools for further handling them. Check the 'README' file, it" 195370b807fSmrg echo "often tells you about the needed prerequisites for installing" 196370b807fSmrg echo "this package. You may also peek at any GNU archive site, in" 197370b807fSmrg echo "case some other package contains this missing '$1' program." 198370b807fSmrg ;; 199370b807fSmrg esac 200370b807fSmrg} 201370b807fSmrg 202370b807fSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203370b807fSmrg -e '2,$s/^/ /' >&2 204370b807fSmrg 205370b807fSmrg# Propagate the correct exit status (expected to be 127 for a program 206370b807fSmrg# not found, 63 for a program that failed due to version mismatch). 207370b807fSmrgexit $st 208659607e0Smrg 209659607e0Smrg# Local variables: 210370b807fSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 211659607e0Smrg# time-stamp-start: "scriptversion=" 212659607e0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213370b807fSmrg# time-stamp-time-zone: "UTC0" 214b73be646Smrg# time-stamp-end: "; # UTC" 215659607e0Smrg# End: 216