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