1fe5e51b7Smrg#! /bin/sh 2493f84f4Smrg# Common wrapper for a few potentially missing GNU programs. 3fe5e51b7Smrg 41e423a8fSmrgscriptversion=2018-03-07.03; # UTC 5fe5e51b7Smrg 61e423a8fSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7493f84f4Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8fe5e51b7Smrg 9fe5e51b7Smrg# This program is free software; you can redistribute it and/or modify 10fe5e51b7Smrg# it under the terms of the GNU General Public License as published by 11fe5e51b7Smrg# the Free Software Foundation; either version 2, or (at your option) 12fe5e51b7Smrg# any later version. 13fe5e51b7Smrg 14fe5e51b7Smrg# This program is distributed in the hope that it will be useful, 15fe5e51b7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16fe5e51b7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17fe5e51b7Smrg# GNU General Public License for more details. 18fe5e51b7Smrg 19fe5e51b7Smrg# You should have received a copy of the GNU General Public License 201e423a8fSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21fe5e51b7Smrg 22fe5e51b7Smrg# As a special exception to the GNU General Public License, if you 23fe5e51b7Smrg# distribute this file as part of a program that contains a 24fe5e51b7Smrg# configuration script generated by Autoconf, you may include it under 25fe5e51b7Smrg# the same distribution terms that you use for the rest of that program. 26fe5e51b7Smrg 27fe5e51b7Smrgif test $# -eq 0; then 28acd6767fSmrg echo 1>&2 "Try '$0 --help' for more information" 29fe5e51b7Smrg exit 1 30fe5e51b7Smrgfi 31fe5e51b7Smrg 32493f84f4Smrgcase $1 in 33fe5e51b7Smrg 34493f84f4Smrg --is-lightweight) 35493f84f4Smrg # Used by our autoconf macros to check whether the available missing 36493f84f4Smrg # script is modern enough. 37493f84f4Smrg exit 0 38493f84f4Smrg ;; 39fe5e51b7Smrg 40493f84f4Smrg --run) 41493f84f4Smrg # Back-compat with the calling convention used by older automake. 42493f84f4Smrg shift 43493f84f4Smrg ;; 44fe5e51b7Smrg 45fe5e51b7Smrg -h|--h|--he|--hel|--help) 46fe5e51b7Smrg echo "\ 47fe5e51b7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48fe5e51b7Smrg 49493f84f4SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50493f84f4Smrgto PROGRAM being missing or too old. 51fe5e51b7Smrg 52fe5e51b7SmrgOptions: 53fe5e51b7Smrg -h, --help display this help and exit 54fe5e51b7Smrg -v, --version output version information and exit 55fe5e51b7Smrg 56fe5e51b7SmrgSupported PROGRAM values: 57493f84f4Smrg aclocal autoconf autoheader autom4te automake makeinfo 58493f84f4Smrg bison yacc flex lex help2man 59fe5e51b7Smrg 60acd6767fSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61acd6767fSmrg'g' are ignored when checking the name. 620bb88ba4Smrg 63fe5e51b7SmrgSend bug reports to <bug-automake@gnu.org>." 64fe5e51b7Smrg exit $? 65fe5e51b7Smrg ;; 66fe5e51b7Smrg 67fe5e51b7Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68fe5e51b7Smrg echo "missing $scriptversion (GNU Automake)" 69fe5e51b7Smrg exit $? 70fe5e51b7Smrg ;; 71fe5e51b7Smrg 72fe5e51b7Smrg -*) 73493f84f4Smrg echo 1>&2 "$0: unknown '$1' option" 74acd6767fSmrg echo 1>&2 "Try '$0 --help' for more information" 75fe5e51b7Smrg exit 1 76fe5e51b7Smrg ;; 77fe5e51b7Smrg 78fe5e51b7Smrgesac 79fe5e51b7Smrg 80493f84f4Smrg# Run the given program, remember its exit status. 81493f84f4Smrg"$@"; st=$? 82493f84f4Smrg 83493f84f4Smrg# If it succeeded, we are done. 84493f84f4Smrgtest $st -eq 0 && exit 0 85493f84f4Smrg 86493f84f4Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87493f84f4Smrg# passed; such an option is passed most likely to detect whether the 88493f84f4Smrg# program is present and works. 89493f84f4Smrgcase $2 in --version|--help) exit $st;; esac 90493f84f4Smrg 91493f84f4Smrg# Exit code 63 means version mismatch. This often happens when the user 92493f84f4Smrg# tries to use an ancient version of a tool on a file that requires a 93493f84f4Smrg# minimum version. 94493f84f4Smrgif test $st -eq 63; then 95493f84f4Smrg msg="probably too old" 96493f84f4Smrgelif test $st -eq 127; then 97493f84f4Smrg # Program was missing. 98493f84f4Smrg msg="missing on your system" 99493f84f4Smrgelse 100493f84f4Smrg # Program was found and executed, but failed. Give up. 101493f84f4Smrg exit $st 102493f84f4Smrgfi 103fe5e51b7Smrg 1041e423a8fSmrgperl_URL=https://www.perl.org/ 1051e423a8fSmrgflex_URL=https://github.com/westes/flex 1061e423a8fSmrggnu_software_URL=https://www.gnu.org/software 107493f84f4Smrg 108493f84f4Smrgprogram_details () 109493f84f4Smrg{ 110493f84f4Smrg case $1 in 111493f84f4Smrg aclocal|automake) 112493f84f4Smrg echo "The '$1' program is part of the GNU Automake package:" 113493f84f4Smrg echo "<$gnu_software_URL/automake>" 114493f84f4Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115493f84f4Smrg echo "<$gnu_software_URL/autoconf>" 116493f84f4Smrg echo "<$gnu_software_URL/m4/>" 117493f84f4Smrg echo "<$perl_URL>" 118493f84f4Smrg ;; 119493f84f4Smrg autoconf|autom4te|autoheader) 120493f84f4Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121493f84f4Smrg echo "<$gnu_software_URL/autoconf/>" 122493f84f4Smrg echo "It also requires GNU m4 and Perl in order to run:" 123493f84f4Smrg echo "<$gnu_software_URL/m4/>" 124493f84f4Smrg echo "<$perl_URL>" 125493f84f4Smrg ;; 126493f84f4Smrg esac 127493f84f4Smrg} 128493f84f4Smrg 129493f84f4Smrggive_advice () 130493f84f4Smrg{ 131493f84f4Smrg # Normalize program name to check for. 132493f84f4Smrg normalized_program=`echo "$1" | sed ' 133493f84f4Smrg s/^gnu-//; t 134493f84f4Smrg s/^gnu//; t 135493f84f4Smrg s/^g//; t'` 136493f84f4Smrg 137493f84f4Smrg printf '%s\n' "'$1' is $msg." 138493f84f4Smrg 139493f84f4Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140493f84f4Smrg case $normalized_program in 141493f84f4Smrg autoconf*) 142493f84f4Smrg echo "You should only need it if you modified 'configure.ac'," 143493f84f4Smrg echo "or m4 files included by it." 144493f84f4Smrg program_details 'autoconf' 145493f84f4Smrg ;; 146493f84f4Smrg autoheader*) 147493f84f4Smrg echo "You should only need it if you modified 'acconfig.h' or" 148493f84f4Smrg echo "$configure_deps." 149493f84f4Smrg program_details 'autoheader' 150493f84f4Smrg ;; 151493f84f4Smrg automake*) 152493f84f4Smrg echo "You should only need it if you modified 'Makefile.am' or" 153493f84f4Smrg echo "$configure_deps." 154493f84f4Smrg program_details 'automake' 155493f84f4Smrg ;; 156493f84f4Smrg aclocal*) 157493f84f4Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158493f84f4Smrg echo "$configure_deps." 159493f84f4Smrg program_details 'aclocal' 160493f84f4Smrg ;; 161493f84f4Smrg autom4te*) 162493f84f4Smrg echo "You might have modified some maintainer files that require" 163493f84f4Smrg echo "the 'autom4te' program to be rebuilt." 164493f84f4Smrg program_details 'autom4te' 165493f84f4Smrg ;; 166493f84f4Smrg bison*|yacc*) 167493f84f4Smrg echo "You should only need it if you modified a '.y' file." 168493f84f4Smrg echo "You may want to install the GNU Bison package:" 169493f84f4Smrg echo "<$gnu_software_URL/bison/>" 170493f84f4Smrg ;; 171493f84f4Smrg lex*|flex*) 172493f84f4Smrg echo "You should only need it if you modified a '.l' file." 173493f84f4Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174493f84f4Smrg echo "<$flex_URL>" 175493f84f4Smrg ;; 176493f84f4Smrg help2man*) 177493f84f4Smrg echo "You should only need it if you modified a dependency" \ 178493f84f4Smrg "of a man page." 179493f84f4Smrg echo "You may want to install the GNU Help2man package:" 180493f84f4Smrg echo "<$gnu_software_URL/help2man/>" 181fe5e51b7Smrg ;; 182493f84f4Smrg makeinfo*) 183493f84f4Smrg echo "You should only need it if you modified a '.texi' file, or" 184493f84f4Smrg echo "any other file indirectly affecting the aspect of the manual." 185493f84f4Smrg echo "You might want to install the Texinfo package:" 186493f84f4Smrg echo "<$gnu_software_URL/texinfo/>" 187493f84f4Smrg echo "The spurious makeinfo call might also be the consequence of" 188493f84f4Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189493f84f4Smrg echo "want to install GNU make:" 190493f84f4Smrg echo "<$gnu_software_URL/make/>" 191493f84f4Smrg ;; 192493f84f4Smrg *) 193493f84f4Smrg echo "You might have modified some files without having the proper" 194493f84f4Smrg echo "tools for further handling them. Check the 'README' file, it" 195493f84f4Smrg echo "often tells you about the needed prerequisites for installing" 196493f84f4Smrg echo "this package. You may also peek at any GNU archive site, in" 197493f84f4Smrg echo "case some other package contains this missing '$1' program." 198493f84f4Smrg ;; 199493f84f4Smrg esac 200493f84f4Smrg} 201493f84f4Smrg 202493f84f4Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203493f84f4Smrg -e '2,$s/^/ /' >&2 204493f84f4Smrg 205493f84f4Smrg# Propagate the correct exit status (expected to be 127 for a program 206493f84f4Smrg# not found, 63 for a program that failed due to version mismatch). 207493f84f4Smrgexit $st 208fe5e51b7Smrg 209fe5e51b7Smrg# Local variables: 2101e423a8fSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 211fe5e51b7Smrg# time-stamp-start: "scriptversion=" 212fe5e51b7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2131e423a8fSmrg# time-stamp-time-zone: "UTC0" 2140bb88ba4Smrg# time-stamp-end: "; # UTC" 215fe5e51b7Smrg# End: 216