1fc89c0fbSmrg#! /bin/sh 2c8df0c59Smrg# Common wrapper for a few potentially missing GNU and other programs. 3fc89c0fbSmrg 4c8df0c59Smrgscriptversion=2024-06-07.14; # UTC 5fc89c0fbSmrg 6c8df0c59Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 7c8df0c59Smrg 8c8df0c59Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 9576bbdfcSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 10fc89c0fbSmrg 11fc89c0fbSmrg# This program is free software; you can redistribute it and/or modify 12fc89c0fbSmrg# it under the terms of the GNU General Public License as published by 13fc89c0fbSmrg# the Free Software Foundation; either version 2, or (at your option) 14fc89c0fbSmrg# any later version. 15fc89c0fbSmrg 16fc89c0fbSmrg# This program is distributed in the hope that it will be useful, 17fc89c0fbSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 18fc89c0fbSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19fc89c0fbSmrg# GNU General Public License for more details. 20fc89c0fbSmrg 21fc89c0fbSmrg# You should have received a copy of the GNU General Public License 22f9c28e31Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 23fc89c0fbSmrg 24fc89c0fbSmrg# As a special exception to the GNU General Public License, if you 25fc89c0fbSmrg# distribute this file as part of a program that contains a 26fc89c0fbSmrg# configuration script generated by Autoconf, you may include it under 27fc89c0fbSmrg# the same distribution terms that you use for the rest of that program. 28fc89c0fbSmrg 29fc89c0fbSmrgif test $# -eq 0; then 30576bbdfcSmrg echo 1>&2 "Try '$0 --help' for more information" 31fc89c0fbSmrg exit 1 32fc89c0fbSmrgfi 33fc89c0fbSmrg 34576bbdfcSmrgcase $1 in 35fc89c0fbSmrg 36576bbdfcSmrg --is-lightweight) 37576bbdfcSmrg # Used by our autoconf macros to check whether the available missing 38576bbdfcSmrg # script is modern enough. 39576bbdfcSmrg exit 0 40576bbdfcSmrg ;; 41fc89c0fbSmrg 42576bbdfcSmrg --run) 43576bbdfcSmrg # Back-compat with the calling convention used by older automake. 44576bbdfcSmrg shift 45576bbdfcSmrg ;; 46fc89c0fbSmrg 47fc89c0fbSmrg -h|--h|--he|--hel|--help) 48fc89c0fbSmrg echo "\ 49fc89c0fbSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 50fc89c0fbSmrg 51576bbdfcSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 52576bbdfcSmrgto PROGRAM being missing or too old. 53fc89c0fbSmrg 54fc89c0fbSmrgOptions: 55fc89c0fbSmrg -h, --help display this help and exit 56fc89c0fbSmrg -v, --version output version information and exit 57fc89c0fbSmrg 58fc89c0fbSmrgSupported PROGRAM values: 59c8df0c59Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 60c8df0c59Smrgbison flex help2man lex makeinfo perl yacc 61fc89c0fbSmrg 62576bbdfcSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 63576bbdfcSmrg'g' are ignored when checking the name. 6491ec45ceSmrg 65c8df0c59SmrgReport bugs to <bug-automake@gnu.org>. 66c8df0c59SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 67c8df0c59SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 68fc89c0fbSmrg exit $? 69fc89c0fbSmrg ;; 70fc89c0fbSmrg 71fc89c0fbSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 72c8df0c59Smrg echo "missing (GNU Automake) $scriptversion" 73fc89c0fbSmrg exit $? 74fc89c0fbSmrg ;; 75fc89c0fbSmrg 76fc89c0fbSmrg -*) 77576bbdfcSmrg echo 1>&2 "$0: unknown '$1' option" 78576bbdfcSmrg echo 1>&2 "Try '$0 --help' for more information" 79fc89c0fbSmrg exit 1 80fc89c0fbSmrg ;; 81fc89c0fbSmrg 82fc89c0fbSmrgesac 83fc89c0fbSmrg 84576bbdfcSmrg# Run the given program, remember its exit status. 85576bbdfcSmrg"$@"; st=$? 86576bbdfcSmrg 87576bbdfcSmrg# If it succeeded, we are done. 88576bbdfcSmrgtest $st -eq 0 && exit 0 89576bbdfcSmrg 90576bbdfcSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 91576bbdfcSmrg# passed; such an option is passed most likely to detect whether the 92576bbdfcSmrg# program is present and works. 93576bbdfcSmrgcase $2 in --version|--help) exit $st;; esac 94576bbdfcSmrg 95576bbdfcSmrg# Exit code 63 means version mismatch. This often happens when the user 96576bbdfcSmrg# tries to use an ancient version of a tool on a file that requires a 97576bbdfcSmrg# minimum version. 98576bbdfcSmrgif test $st -eq 63; then 99576bbdfcSmrg msg="probably too old" 100576bbdfcSmrgelif test $st -eq 127; then 101576bbdfcSmrg # Program was missing. 102576bbdfcSmrg msg="missing on your system" 103576bbdfcSmrgelse 104576bbdfcSmrg # Program was found and executed, but failed. Give up. 105576bbdfcSmrg exit $st 106576bbdfcSmrgfi 107fc89c0fbSmrg 108f9c28e31Smrgperl_URL=https://www.perl.org/ 109f9c28e31Smrgflex_URL=https://github.com/westes/flex 110f9c28e31Smrggnu_software_URL=https://www.gnu.org/software 111576bbdfcSmrg 112576bbdfcSmrgprogram_details () 113576bbdfcSmrg{ 114576bbdfcSmrg case $1 in 115c8df0c59Smrg aclocal|automake|autoreconf) 116576bbdfcSmrg echo "The '$1' program is part of the GNU Automake package:" 117576bbdfcSmrg echo "<$gnu_software_URL/automake>" 118576bbdfcSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 119576bbdfcSmrg echo "<$gnu_software_URL/autoconf>" 120576bbdfcSmrg echo "<$gnu_software_URL/m4/>" 121576bbdfcSmrg echo "<$perl_URL>" 122576bbdfcSmrg ;; 123576bbdfcSmrg autoconf|autom4te|autoheader) 124576bbdfcSmrg echo "The '$1' program is part of the GNU Autoconf package:" 125576bbdfcSmrg echo "<$gnu_software_URL/autoconf/>" 126576bbdfcSmrg echo "It also requires GNU m4 and Perl in order to run:" 127576bbdfcSmrg echo "<$gnu_software_URL/m4/>" 128576bbdfcSmrg echo "<$perl_URL>" 129576bbdfcSmrg ;; 130c8df0c59Smrg *) 131c8df0c59Smrg : 132c8df0c59Smrg ;; 133576bbdfcSmrg esac 134576bbdfcSmrg} 135576bbdfcSmrg 136576bbdfcSmrggive_advice () 137576bbdfcSmrg{ 138576bbdfcSmrg # Normalize program name to check for. 139576bbdfcSmrg normalized_program=`echo "$1" | sed ' 140576bbdfcSmrg s/^gnu-//; t 141576bbdfcSmrg s/^gnu//; t 142576bbdfcSmrg s/^g//; t'` 143576bbdfcSmrg 144576bbdfcSmrg printf '%s\n' "'$1' is $msg." 145576bbdfcSmrg 146576bbdfcSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 147c8df0c59Smrg autoheader_deps="'acconfig.h'" 148c8df0c59Smrg automake_deps="'Makefile.am'" 149c8df0c59Smrg aclocal_deps="'acinclude.m4'" 150576bbdfcSmrg case $normalized_program in 151c8df0c59Smrg aclocal*) 152c8df0c59Smrg echo "You should only need it if you modified $aclocal_deps or" 153c8df0c59Smrg echo "$configure_deps." 154c8df0c59Smrg ;; 155576bbdfcSmrg autoconf*) 156c8df0c59Smrg echo "You should only need it if you modified $configure_deps." 157c8df0c59Smrg ;; 158c8df0c59Smrg autogen*) 159c8df0c59Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 160c8df0c59Smrg echo "You may want to install the GNU AutoGen package:" 161c8df0c59Smrg echo "<$gnu_software_URL/autogen/>" 162576bbdfcSmrg ;; 163576bbdfcSmrg autoheader*) 164c8df0c59Smrg echo "You should only need it if you modified $autoheader_deps or" 165576bbdfcSmrg echo "$configure_deps." 166576bbdfcSmrg ;; 167576bbdfcSmrg automake*) 168c8df0c59Smrg echo "You should only need it if you modified $automake_deps or" 169576bbdfcSmrg echo "$configure_deps." 170576bbdfcSmrg ;; 171c8df0c59Smrg autom4te*) 172576bbdfcSmrg echo "You might have modified some maintainer files that require" 17381676fe2Smrg echo "the 'autom4te' program to be rebuilt." 174c8df0c59Smrg ;; 175c8df0c59Smrg autoreconf*) 176c8df0c59Smrg echo "You should only need it if you modified $aclocal_deps or" 177c8df0c59Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 178c8df0c59Smrg echo "$configure_deps." 179576bbdfcSmrg ;; 180576bbdfcSmrg bison*|yacc*) 181576bbdfcSmrg echo "You should only need it if you modified a '.y' file." 182576bbdfcSmrg echo "You may want to install the GNU Bison package:" 183576bbdfcSmrg echo "<$gnu_software_URL/bison/>" 184576bbdfcSmrg ;; 185576bbdfcSmrg help2man*) 186576bbdfcSmrg echo "You should only need it if you modified a dependency" \ 187576bbdfcSmrg "of a man page." 188576bbdfcSmrg echo "You may want to install the GNU Help2man package:" 189576bbdfcSmrg echo "<$gnu_software_URL/help2man/>" 190576bbdfcSmrg ;; 191c8df0c59Smrg lex*|flex*) 192c8df0c59Smrg echo "You should only need it if you modified a '.l' file." 193c8df0c59Smrg echo "You may want to install the Fast Lexical Analyzer package:" 194c8df0c59Smrg echo "<$flex_URL>" 195c8df0c59Smrg ;; 196576bbdfcSmrg makeinfo*) 197576bbdfcSmrg echo "You should only need it if you modified a '.texi' file, or" 198576bbdfcSmrg echo "any other file indirectly affecting the aspect of the manual." 199576bbdfcSmrg echo "You might want to install the Texinfo package:" 200576bbdfcSmrg echo "<$gnu_software_URL/texinfo/>" 201576bbdfcSmrg echo "The spurious makeinfo call might also be the consequence of" 202576bbdfcSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 203576bbdfcSmrg echo "want to install GNU make:" 204576bbdfcSmrg echo "<$gnu_software_URL/make/>" 205576bbdfcSmrg ;; 206c8df0c59Smrg perl*) 207c8df0c59Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 208c8df0c59Smrg echo " assorted other tools, or if you modified a Perl source file." 209c8df0c59Smrg echo "You may want to install the Perl 5 language interpreter:" 210c8df0c59Smrg echo "<$perl_URL>" 211c8df0c59Smrg ;; 212576bbdfcSmrg *) 213576bbdfcSmrg echo "You might have modified some files without having the proper" 214576bbdfcSmrg echo "tools for further handling them. Check the 'README' file, it" 215576bbdfcSmrg echo "often tells you about the needed prerequisites for installing" 216576bbdfcSmrg echo "this package. You may also peek at any GNU archive site, in" 217576bbdfcSmrg echo "case some other package contains this missing '$1' program." 218576bbdfcSmrg ;; 219576bbdfcSmrg esac 220c8df0c59Smrg program_details "$normalized_program" 221576bbdfcSmrg} 222576bbdfcSmrg 223576bbdfcSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 224576bbdfcSmrg -e '2,$s/^/ /' >&2 225576bbdfcSmrg 226576bbdfcSmrg# Propagate the correct exit status (expected to be 127 for a program 227576bbdfcSmrg# not found, 63 for a program that failed due to version mismatch). 228576bbdfcSmrgexit $st 229fc89c0fbSmrg 230fc89c0fbSmrg# Local variables: 231f9c28e31Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 232fc89c0fbSmrg# time-stamp-start: "scriptversion=" 233fc89c0fbSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 234f9c28e31Smrg# time-stamp-time-zone: "UTC0" 23591ec45ceSmrg# time-stamp-end: "; # UTC" 236fc89c0fbSmrg# End: 237