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