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