1a6d9b409Smrg#! /bin/sh 2838f5b0bSmrg# Common wrapper for a few potentially missing GNU and other programs. 3a6d9b409Smrg 4838f5b0bSmrgscriptversion=2024-06-07.14; # UTC 5a6d9b409Smrg 6838f5b0bSmrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 7838f5b0bSmrg 8838f5b0bSmrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 9b91640d3Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 10a6d9b409Smrg 11a6d9b409Smrg# This program is free software; you can redistribute it and/or modify 12a6d9b409Smrg# it under the terms of the GNU General Public License as published by 13a6d9b409Smrg# the Free Software Foundation; either version 2, or (at your option) 14a6d9b409Smrg# any later version. 15a6d9b409Smrg 16a6d9b409Smrg# This program is distributed in the hope that it will be useful, 17a6d9b409Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 18a6d9b409Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19a6d9b409Smrg# GNU General Public License for more details. 20a6d9b409Smrg 21a6d9b409Smrg# You should have received a copy of the GNU General Public License 2292e95ad1Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 23a6d9b409Smrg 24a6d9b409Smrg# As a special exception to the GNU General Public License, if you 25a6d9b409Smrg# distribute this file as part of a program that contains a 26a6d9b409Smrg# configuration script generated by Autoconf, you may include it under 27a6d9b409Smrg# the same distribution terms that you use for the rest of that program. 28a6d9b409Smrg 29a6d9b409Smrgif test $# -eq 0; then 30b91640d3Smrg echo 1>&2 "Try '$0 --help' for more information" 31a6d9b409Smrg exit 1 32a6d9b409Smrgfi 33a6d9b409Smrg 34b91640d3Smrgcase $1 in 35a6d9b409Smrg 36b91640d3Smrg --is-lightweight) 37b91640d3Smrg # Used by our autoconf macros to check whether the available missing 38b91640d3Smrg # script is modern enough. 39b91640d3Smrg exit 0 40b91640d3Smrg ;; 41a6d9b409Smrg 42b91640d3Smrg --run) 43b91640d3Smrg # Back-compat with the calling convention used by older automake. 44b91640d3Smrg shift 45b91640d3Smrg ;; 46a6d9b409Smrg 47a6d9b409Smrg -h|--h|--he|--hel|--help) 48a6d9b409Smrg echo "\ 49a6d9b409Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 50a6d9b409Smrg 51b91640d3SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 52b91640d3Smrgto PROGRAM being missing or too old. 53a6d9b409Smrg 54a6d9b409SmrgOptions: 55a6d9b409Smrg -h, --help display this help and exit 56a6d9b409Smrg -v, --version output version information and exit 57a6d9b409Smrg 58a6d9b409SmrgSupported PROGRAM values: 59838f5b0bSmrgaclocal autoconf autogen autoheader autom4te automake autoreconf 60838f5b0bSmrgbison flex help2man lex makeinfo perl yacc 61a6d9b409Smrg 62b91640d3SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 63b91640d3Smrg'g' are ignored when checking the name. 64efda2da8Smrg 65838f5b0bSmrgReport bugs to <bug-automake@gnu.org>. 66838f5b0bSmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 67838f5b0bSmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 68a6d9b409Smrg exit $? 69a6d9b409Smrg ;; 70a6d9b409Smrg 71a6d9b409Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 72838f5b0bSmrg echo "missing (GNU Automake) $scriptversion" 73a6d9b409Smrg exit $? 74a6d9b409Smrg ;; 75a6d9b409Smrg 76a6d9b409Smrg -*) 77b91640d3Smrg echo 1>&2 "$0: unknown '$1' option" 78b91640d3Smrg echo 1>&2 "Try '$0 --help' for more information" 79a6d9b409Smrg exit 1 80a6d9b409Smrg ;; 81a6d9b409Smrg 82a6d9b409Smrgesac 83a6d9b409Smrg 84b91640d3Smrg# Run the given program, remember its exit status. 85b91640d3Smrg"$@"; st=$? 86b91640d3Smrg 87b91640d3Smrg# If it succeeded, we are done. 88b91640d3Smrgtest $st -eq 0 && exit 0 89b91640d3Smrg 90b91640d3Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 91b91640d3Smrg# passed; such an option is passed most likely to detect whether the 92b91640d3Smrg# program is present and works. 93b91640d3Smrgcase $2 in --version|--help) exit $st;; esac 94b91640d3Smrg 95b91640d3Smrg# Exit code 63 means version mismatch. This often happens when the user 96b91640d3Smrg# tries to use an ancient version of a tool on a file that requires a 97b91640d3Smrg# minimum version. 98b91640d3Smrgif test $st -eq 63; then 99b91640d3Smrg msg="probably too old" 100b91640d3Smrgelif test $st -eq 127; then 101b91640d3Smrg # Program was missing. 102b91640d3Smrg msg="missing on your system" 103b91640d3Smrgelse 104b91640d3Smrg # Program was found and executed, but failed. Give up. 105b91640d3Smrg exit $st 106b91640d3Smrgfi 107a6d9b409Smrg 10892e95ad1Smrgperl_URL=https://www.perl.org/ 10992e95ad1Smrgflex_URL=https://github.com/westes/flex 11092e95ad1Smrggnu_software_URL=https://www.gnu.org/software 111b91640d3Smrg 112b91640d3Smrgprogram_details () 113b91640d3Smrg{ 114b91640d3Smrg case $1 in 115838f5b0bSmrg aclocal|automake|autoreconf) 116b91640d3Smrg echo "The '$1' program is part of the GNU Automake package:" 117b91640d3Smrg echo "<$gnu_software_URL/automake>" 118b91640d3Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 119b91640d3Smrg echo "<$gnu_software_URL/autoconf>" 120b91640d3Smrg echo "<$gnu_software_URL/m4/>" 121b91640d3Smrg echo "<$perl_URL>" 122b91640d3Smrg ;; 123b91640d3Smrg autoconf|autom4te|autoheader) 124b91640d3Smrg echo "The '$1' program is part of the GNU Autoconf package:" 125b91640d3Smrg echo "<$gnu_software_URL/autoconf/>" 126b91640d3Smrg echo "It also requires GNU m4 and Perl in order to run:" 127b91640d3Smrg echo "<$gnu_software_URL/m4/>" 128b91640d3Smrg echo "<$perl_URL>" 129b91640d3Smrg ;; 130838f5b0bSmrg *) 131838f5b0bSmrg : 132838f5b0bSmrg ;; 133b91640d3Smrg esac 134b91640d3Smrg} 135b91640d3Smrg 136b91640d3Smrggive_advice () 137b91640d3Smrg{ 138b91640d3Smrg # Normalize program name to check for. 139b91640d3Smrg normalized_program=`echo "$1" | sed ' 140b91640d3Smrg s/^gnu-//; t 141b91640d3Smrg s/^gnu//; t 142b91640d3Smrg s/^g//; t'` 143b91640d3Smrg 144b91640d3Smrg printf '%s\n' "'$1' is $msg." 145b91640d3Smrg 146b91640d3Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 147838f5b0bSmrg autoheader_deps="'acconfig.h'" 148838f5b0bSmrg automake_deps="'Makefile.am'" 149838f5b0bSmrg aclocal_deps="'acinclude.m4'" 150b91640d3Smrg case $normalized_program in 151838f5b0bSmrg aclocal*) 152838f5b0bSmrg echo "You should only need it if you modified $aclocal_deps or" 153838f5b0bSmrg echo "$configure_deps." 154838f5b0bSmrg ;; 155b91640d3Smrg autoconf*) 156838f5b0bSmrg echo "You should only need it if you modified $configure_deps." 157838f5b0bSmrg ;; 158838f5b0bSmrg autogen*) 159838f5b0bSmrg echo "You should only need it if you modified a '.def' or '.tpl' file." 160838f5b0bSmrg echo "You may want to install the GNU AutoGen package:" 161838f5b0bSmrg echo "<$gnu_software_URL/autogen/>" 162b91640d3Smrg ;; 163b91640d3Smrg autoheader*) 164838f5b0bSmrg echo "You should only need it if you modified $autoheader_deps or" 165b91640d3Smrg echo "$configure_deps." 166b91640d3Smrg ;; 167b91640d3Smrg automake*) 168838f5b0bSmrg echo "You should only need it if you modified $automake_deps or" 169b91640d3Smrg echo "$configure_deps." 170b91640d3Smrg ;; 171838f5b0bSmrg autom4te*) 172b91640d3Smrg echo "You might have modified some maintainer files that require" 173b91640d3Smrg echo "the 'autom4te' program to be rebuilt." 174838f5b0bSmrg ;; 175838f5b0bSmrg autoreconf*) 176838f5b0bSmrg echo "You should only need it if you modified $aclocal_deps or" 177838f5b0bSmrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 178838f5b0bSmrg echo "$configure_deps." 179b91640d3Smrg ;; 180b91640d3Smrg bison*|yacc*) 181b91640d3Smrg echo "You should only need it if you modified a '.y' file." 182b91640d3Smrg echo "You may want to install the GNU Bison package:" 183b91640d3Smrg echo "<$gnu_software_URL/bison/>" 184b91640d3Smrg ;; 185b91640d3Smrg help2man*) 186b91640d3Smrg echo "You should only need it if you modified a dependency" \ 187b91640d3Smrg "of a man page." 188b91640d3Smrg echo "You may want to install the GNU Help2man package:" 189b91640d3Smrg echo "<$gnu_software_URL/help2man/>" 190b91640d3Smrg ;; 191838f5b0bSmrg lex*|flex*) 192838f5b0bSmrg echo "You should only need it if you modified a '.l' file." 193838f5b0bSmrg echo "You may want to install the Fast Lexical Analyzer package:" 194838f5b0bSmrg echo "<$flex_URL>" 195838f5b0bSmrg ;; 196b91640d3Smrg makeinfo*) 197b91640d3Smrg echo "You should only need it if you modified a '.texi' file, or" 198b91640d3Smrg echo "any other file indirectly affecting the aspect of the manual." 199b91640d3Smrg echo "You might want to install the Texinfo package:" 200b91640d3Smrg echo "<$gnu_software_URL/texinfo/>" 201b91640d3Smrg echo "The spurious makeinfo call might also be the consequence of" 202b91640d3Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 203b91640d3Smrg echo "want to install GNU make:" 204b91640d3Smrg echo "<$gnu_software_URL/make/>" 205b91640d3Smrg ;; 206838f5b0bSmrg perl*) 207838f5b0bSmrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 208838f5b0bSmrg echo " assorted other tools, or if you modified a Perl source file." 209838f5b0bSmrg echo "You may want to install the Perl 5 language interpreter:" 210838f5b0bSmrg echo "<$perl_URL>" 211838f5b0bSmrg ;; 212b91640d3Smrg *) 213b91640d3Smrg echo "You might have modified some files without having the proper" 214b91640d3Smrg echo "tools for further handling them. Check the 'README' file, it" 215b91640d3Smrg echo "often tells you about the needed prerequisites for installing" 216b91640d3Smrg echo "this package. You may also peek at any GNU archive site, in" 217b91640d3Smrg echo "case some other package contains this missing '$1' program." 218b91640d3Smrg ;; 219b91640d3Smrg esac 220838f5b0bSmrg program_details "$normalized_program" 221b91640d3Smrg} 222b91640d3Smrg 223b91640d3Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 224b91640d3Smrg -e '2,$s/^/ /' >&2 225b91640d3Smrg 226b91640d3Smrg# Propagate the correct exit status (expected to be 127 for a program 227b91640d3Smrg# not found, 63 for a program that failed due to version mismatch). 228b91640d3Smrgexit $st 229a6d9b409Smrg 230a6d9b409Smrg# Local variables: 23192e95ad1Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 232a6d9b409Smrg# time-stamp-start: "scriptversion=" 233a6d9b409Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 23492e95ad1Smrg# time-stamp-time-zone: "UTC0" 235efda2da8Smrg# time-stamp-end: "; # UTC" 236a6d9b409Smrg# End: 237