1a96d7823Smrg#! /bin/sh 26a46240fSmrg# Common wrapper for a few potentially missing GNU and other programs. 3a96d7823Smrg 46a46240fSmrgscriptversion=2024-06-07.14; # UTC 5a96d7823Smrg 66a46240fSmrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 76a46240fSmrg 86a46240fSmrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 9a96d7823Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 10a96d7823Smrg 11a96d7823Smrg# This program is free software; you can redistribute it and/or modify 12a96d7823Smrg# it under the terms of the GNU General Public License as published by 13a96d7823Smrg# the Free Software Foundation; either version 2, or (at your option) 14a96d7823Smrg# any later version. 15a96d7823Smrg 16a96d7823Smrg# This program is distributed in the hope that it will be useful, 17a96d7823Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 18a96d7823Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19a96d7823Smrg# GNU General Public License for more details. 20a96d7823Smrg 21a96d7823Smrg# You should have received a copy of the GNU General Public License 2260da515cSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 23a96d7823Smrg 24a96d7823Smrg# As a special exception to the GNU General Public License, if you 25a96d7823Smrg# distribute this file as part of a program that contains a 26a96d7823Smrg# configuration script generated by Autoconf, you may include it under 27a96d7823Smrg# the same distribution terms that you use for the rest of that program. 28a96d7823Smrg 29a96d7823Smrgif test $# -eq 0; then 30a96d7823Smrg echo 1>&2 "Try '$0 --help' for more information" 31a96d7823Smrg exit 1 32a96d7823Smrgfi 33a96d7823Smrg 34a96d7823Smrgcase $1 in 35a96d7823Smrg 36a96d7823Smrg --is-lightweight) 37a96d7823Smrg # Used by our autoconf macros to check whether the available missing 38a96d7823Smrg # script is modern enough. 39a96d7823Smrg exit 0 40a96d7823Smrg ;; 41a96d7823Smrg 42a96d7823Smrg --run) 43a96d7823Smrg # Back-compat with the calling convention used by older automake. 44a96d7823Smrg shift 45a96d7823Smrg ;; 46a96d7823Smrg 47a96d7823Smrg -h|--h|--he|--hel|--help) 48a96d7823Smrg echo "\ 49a96d7823Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 50a96d7823Smrg 51a96d7823SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 52a96d7823Smrgto PROGRAM being missing or too old. 53a96d7823Smrg 54a96d7823SmrgOptions: 55a96d7823Smrg -h, --help display this help and exit 56a96d7823Smrg -v, --version output version information and exit 57a96d7823Smrg 58a96d7823SmrgSupported PROGRAM values: 596a46240fSmrgaclocal autoconf autogen autoheader autom4te automake autoreconf 606a46240fSmrgbison flex help2man lex makeinfo perl yacc 61a96d7823Smrg 62a96d7823SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 63a96d7823Smrg'g' are ignored when checking the name. 64a96d7823Smrg 656a46240fSmrgReport bugs to <bug-automake@gnu.org>. 666a46240fSmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 676a46240fSmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 68a96d7823Smrg exit $? 69a96d7823Smrg ;; 70a96d7823Smrg 71a96d7823Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 726a46240fSmrg echo "missing (GNU Automake) $scriptversion" 73a96d7823Smrg exit $? 74a96d7823Smrg ;; 75a96d7823Smrg 76a96d7823Smrg -*) 77a96d7823Smrg echo 1>&2 "$0: unknown '$1' option" 78a96d7823Smrg echo 1>&2 "Try '$0 --help' for more information" 79a96d7823Smrg exit 1 80a96d7823Smrg ;; 81a96d7823Smrg 82a96d7823Smrgesac 83a96d7823Smrg 84a96d7823Smrg# Run the given program, remember its exit status. 85a96d7823Smrg"$@"; st=$? 86a96d7823Smrg 87a96d7823Smrg# If it succeeded, we are done. 88a96d7823Smrgtest $st -eq 0 && exit 0 89a96d7823Smrg 90a96d7823Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 91a96d7823Smrg# passed; such an option is passed most likely to detect whether the 92a96d7823Smrg# program is present and works. 93a96d7823Smrgcase $2 in --version|--help) exit $st;; esac 94a96d7823Smrg 95a96d7823Smrg# Exit code 63 means version mismatch. This often happens when the user 96a96d7823Smrg# tries to use an ancient version of a tool on a file that requires a 97a96d7823Smrg# minimum version. 98a96d7823Smrgif test $st -eq 63; then 99a96d7823Smrg msg="probably too old" 100a96d7823Smrgelif test $st -eq 127; then 101a96d7823Smrg # Program was missing. 102a96d7823Smrg msg="missing on your system" 103a96d7823Smrgelse 104a96d7823Smrg # Program was found and executed, but failed. Give up. 105a96d7823Smrg exit $st 106a96d7823Smrgfi 107a96d7823Smrg 10860da515cSmrgperl_URL=https://www.perl.org/ 10960da515cSmrgflex_URL=https://github.com/westes/flex 11060da515cSmrggnu_software_URL=https://www.gnu.org/software 111a96d7823Smrg 112a96d7823Smrgprogram_details () 113a96d7823Smrg{ 114a96d7823Smrg case $1 in 1156a46240fSmrg aclocal|automake|autoreconf) 116a96d7823Smrg echo "The '$1' program is part of the GNU Automake package:" 117a96d7823Smrg echo "<$gnu_software_URL/automake>" 118a96d7823Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 119a96d7823Smrg echo "<$gnu_software_URL/autoconf>" 120a96d7823Smrg echo "<$gnu_software_URL/m4/>" 121a96d7823Smrg echo "<$perl_URL>" 122a96d7823Smrg ;; 123a96d7823Smrg autoconf|autom4te|autoheader) 124a96d7823Smrg echo "The '$1' program is part of the GNU Autoconf package:" 125a96d7823Smrg echo "<$gnu_software_URL/autoconf/>" 126a96d7823Smrg echo "It also requires GNU m4 and Perl in order to run:" 127a96d7823Smrg echo "<$gnu_software_URL/m4/>" 128a96d7823Smrg echo "<$perl_URL>" 129a96d7823Smrg ;; 1306a46240fSmrg *) 1316a46240fSmrg : 1326a46240fSmrg ;; 133a96d7823Smrg esac 134a96d7823Smrg} 135a96d7823Smrg 136a96d7823Smrggive_advice () 137a96d7823Smrg{ 138a96d7823Smrg # Normalize program name to check for. 139a96d7823Smrg normalized_program=`echo "$1" | sed ' 140a96d7823Smrg s/^gnu-//; t 141a96d7823Smrg s/^gnu//; t 142a96d7823Smrg s/^g//; t'` 143a96d7823Smrg 144a96d7823Smrg printf '%s\n' "'$1' is $msg." 145a96d7823Smrg 146a96d7823Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1476a46240fSmrg autoheader_deps="'acconfig.h'" 1486a46240fSmrg automake_deps="'Makefile.am'" 1496a46240fSmrg aclocal_deps="'acinclude.m4'" 150a96d7823Smrg case $normalized_program in 1516a46240fSmrg aclocal*) 1526a46240fSmrg echo "You should only need it if you modified $aclocal_deps or" 1536a46240fSmrg echo "$configure_deps." 1546a46240fSmrg ;; 155a96d7823Smrg autoconf*) 1566a46240fSmrg echo "You should only need it if you modified $configure_deps." 1576a46240fSmrg ;; 1586a46240fSmrg autogen*) 1596a46240fSmrg echo "You should only need it if you modified a '.def' or '.tpl' file." 1606a46240fSmrg echo "You may want to install the GNU AutoGen package:" 1616a46240fSmrg echo "<$gnu_software_URL/autogen/>" 162a96d7823Smrg ;; 163a96d7823Smrg autoheader*) 1646a46240fSmrg echo "You should only need it if you modified $autoheader_deps or" 165a96d7823Smrg echo "$configure_deps." 166a96d7823Smrg ;; 167a96d7823Smrg automake*) 1686a46240fSmrg echo "You should only need it if you modified $automake_deps or" 169a96d7823Smrg echo "$configure_deps." 170a96d7823Smrg ;; 1716a46240fSmrg autom4te*) 172a96d7823Smrg echo "You might have modified some maintainer files that require" 173a96d7823Smrg echo "the 'autom4te' program to be rebuilt." 1746a46240fSmrg ;; 1756a46240fSmrg autoreconf*) 1766a46240fSmrg echo "You should only need it if you modified $aclocal_deps or" 1776a46240fSmrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 1786a46240fSmrg echo "$configure_deps." 179a96d7823Smrg ;; 180a96d7823Smrg bison*|yacc*) 181a96d7823Smrg echo "You should only need it if you modified a '.y' file." 182a96d7823Smrg echo "You may want to install the GNU Bison package:" 183a96d7823Smrg echo "<$gnu_software_URL/bison/>" 184a96d7823Smrg ;; 185a96d7823Smrg help2man*) 186a96d7823Smrg echo "You should only need it if you modified a dependency" \ 187a96d7823Smrg "of a man page." 188a96d7823Smrg echo "You may want to install the GNU Help2man package:" 189a96d7823Smrg echo "<$gnu_software_URL/help2man/>" 190a96d7823Smrg ;; 1916a46240fSmrg lex*|flex*) 1926a46240fSmrg echo "You should only need it if you modified a '.l' file." 1936a46240fSmrg echo "You may want to install the Fast Lexical Analyzer package:" 1946a46240fSmrg echo "<$flex_URL>" 1956a46240fSmrg ;; 196a96d7823Smrg makeinfo*) 197a96d7823Smrg echo "You should only need it if you modified a '.texi' file, or" 198a96d7823Smrg echo "any other file indirectly affecting the aspect of the manual." 199a96d7823Smrg echo "You might want to install the Texinfo package:" 200a96d7823Smrg echo "<$gnu_software_URL/texinfo/>" 201a96d7823Smrg echo "The spurious makeinfo call might also be the consequence of" 202a96d7823Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 203a96d7823Smrg echo "want to install GNU make:" 204a96d7823Smrg echo "<$gnu_software_URL/make/>" 205a96d7823Smrg ;; 2066a46240fSmrg perl*) 2076a46240fSmrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 2086a46240fSmrg echo " assorted other tools, or if you modified a Perl source file." 2096a46240fSmrg echo "You may want to install the Perl 5 language interpreter:" 2106a46240fSmrg echo "<$perl_URL>" 2116a46240fSmrg ;; 212a96d7823Smrg *) 213a96d7823Smrg echo "You might have modified some files without having the proper" 214a96d7823Smrg echo "tools for further handling them. Check the 'README' file, it" 215a96d7823Smrg echo "often tells you about the needed prerequisites for installing" 216a96d7823Smrg echo "this package. You may also peek at any GNU archive site, in" 217a96d7823Smrg echo "case some other package contains this missing '$1' program." 218a96d7823Smrg ;; 219a96d7823Smrg esac 2206a46240fSmrg program_details "$normalized_program" 221a96d7823Smrg} 222a96d7823Smrg 223a96d7823Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 224a96d7823Smrg -e '2,$s/^/ /' >&2 225a96d7823Smrg 226a96d7823Smrg# Propagate the correct exit status (expected to be 127 for a program 227a96d7823Smrg# not found, 63 for a program that failed due to version mismatch). 228a96d7823Smrgexit $st 229a96d7823Smrg 230a96d7823Smrg# Local variables: 23160da515cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 232a96d7823Smrg# time-stamp-start: "scriptversion=" 233a96d7823Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 23460da515cSmrg# time-stamp-time-zone: "UTC0" 235a96d7823Smrg# time-stamp-end: "; # UTC" 236a96d7823Smrg# End: 237