12c7c4e3dSmrg#! /bin/sh 2c1e8faa6Smrg# Common wrapper for a few potentially missing GNU and other programs. 38650bb69Smrg 4c1e8faa6Smrgscriptversion=2024-06-07.14; # UTC 58650bb69Smrg 6c1e8faa6Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 7c1e8faa6Smrg 8c1e8faa6Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 92becc446Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 102c7c4e3dSmrg 112c7c4e3dSmrg# This program is free software; you can redistribute it and/or modify 122c7c4e3dSmrg# it under the terms of the GNU General Public License as published by 132c7c4e3dSmrg# the Free Software Foundation; either version 2, or (at your option) 142c7c4e3dSmrg# any later version. 152c7c4e3dSmrg 162c7c4e3dSmrg# This program is distributed in the hope that it will be useful, 172c7c4e3dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 182c7c4e3dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 192c7c4e3dSmrg# GNU General Public License for more details. 202c7c4e3dSmrg 212c7c4e3dSmrg# You should have received a copy of the GNU General Public License 223458e6c2Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 232c7c4e3dSmrg 242c7c4e3dSmrg# As a special exception to the GNU General Public License, if you 252c7c4e3dSmrg# distribute this file as part of a program that contains a 262c7c4e3dSmrg# configuration script generated by Autoconf, you may include it under 272c7c4e3dSmrg# the same distribution terms that you use for the rest of that program. 282c7c4e3dSmrg 292c7c4e3dSmrgif test $# -eq 0; then 302becc446Smrg echo 1>&2 "Try '$0 --help' for more information" 312c7c4e3dSmrg exit 1 322c7c4e3dSmrgfi 332c7c4e3dSmrg 342becc446Smrgcase $1 in 352c7c4e3dSmrg 362becc446Smrg --is-lightweight) 372becc446Smrg # Used by our autoconf macros to check whether the available missing 382becc446Smrg # script is modern enough. 392becc446Smrg exit 0 402becc446Smrg ;; 418650bb69Smrg 422becc446Smrg --run) 432becc446Smrg # Back-compat with the calling convention used by older automake. 442becc446Smrg shift 452becc446Smrg ;; 462c7c4e3dSmrg 472c7c4e3dSmrg -h|--h|--he|--hel|--help) 482c7c4e3dSmrg echo "\ 492c7c4e3dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 502c7c4e3dSmrg 512becc446SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 522becc446Smrgto PROGRAM being missing or too old. 532c7c4e3dSmrg 542c7c4e3dSmrgOptions: 552c7c4e3dSmrg -h, --help display this help and exit 562c7c4e3dSmrg -v, --version output version information and exit 572c7c4e3dSmrg 582c7c4e3dSmrgSupported PROGRAM values: 59c1e8faa6Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 60c1e8faa6Smrgbison flex help2man lex makeinfo perl yacc 618650bb69Smrg 622becc446SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 632becc446Smrg'g' are ignored when checking the name. 648650bb69Smrg 65c1e8faa6SmrgReport bugs to <bug-automake@gnu.org>. 66c1e8faa6SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 67c1e8faa6SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 688650bb69Smrg exit $? 692c7c4e3dSmrg ;; 702c7c4e3dSmrg 712c7c4e3dSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 72c1e8faa6Smrg echo "missing (GNU Automake) $scriptversion" 738650bb69Smrg exit $? 742c7c4e3dSmrg ;; 752c7c4e3dSmrg 762c7c4e3dSmrg -*) 772becc446Smrg echo 1>&2 "$0: unknown '$1' option" 782becc446Smrg echo 1>&2 "Try '$0 --help' for more information" 792c7c4e3dSmrg exit 1 802c7c4e3dSmrg ;; 812c7c4e3dSmrg 828650bb69Smrgesac 838650bb69Smrg 842becc446Smrg# Run the given program, remember its exit status. 852becc446Smrg"$@"; st=$? 862becc446Smrg 872becc446Smrg# If it succeeded, we are done. 882becc446Smrgtest $st -eq 0 && exit 0 892becc446Smrg 902becc446Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 912becc446Smrg# passed; such an option is passed most likely to detect whether the 922becc446Smrg# program is present and works. 932becc446Smrgcase $2 in --version|--help) exit $st;; esac 942becc446Smrg 952becc446Smrg# Exit code 63 means version mismatch. This often happens when the user 962becc446Smrg# tries to use an ancient version of a tool on a file that requires a 972becc446Smrg# minimum version. 982becc446Smrgif test $st -eq 63; then 992becc446Smrg msg="probably too old" 1002becc446Smrgelif test $st -eq 127; then 1012becc446Smrg # Program was missing. 1022becc446Smrg msg="missing on your system" 1032becc446Smrgelse 1042becc446Smrg # Program was found and executed, but failed. Give up. 1052becc446Smrg exit $st 1062becc446Smrgfi 1072c7c4e3dSmrg 1083458e6c2Smrgperl_URL=https://www.perl.org/ 1093458e6c2Smrgflex_URL=https://github.com/westes/flex 1103458e6c2Smrggnu_software_URL=https://www.gnu.org/software 1112becc446Smrg 1122becc446Smrgprogram_details () 1132becc446Smrg{ 1142becc446Smrg case $1 in 115c1e8faa6Smrg aclocal|automake|autoreconf) 1162becc446Smrg echo "The '$1' program is part of the GNU Automake package:" 1172becc446Smrg echo "<$gnu_software_URL/automake>" 1182becc446Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1192becc446Smrg echo "<$gnu_software_URL/autoconf>" 1202becc446Smrg echo "<$gnu_software_URL/m4/>" 1212becc446Smrg echo "<$perl_URL>" 1222becc446Smrg ;; 1232becc446Smrg autoconf|autom4te|autoheader) 1242becc446Smrg echo "The '$1' program is part of the GNU Autoconf package:" 1252becc446Smrg echo "<$gnu_software_URL/autoconf/>" 1262becc446Smrg echo "It also requires GNU m4 and Perl in order to run:" 1272becc446Smrg echo "<$gnu_software_URL/m4/>" 1282becc446Smrg echo "<$perl_URL>" 1292becc446Smrg ;; 130c1e8faa6Smrg *) 131c1e8faa6Smrg : 132c1e8faa6Smrg ;; 1332becc446Smrg esac 1342becc446Smrg} 1352becc446Smrg 1362becc446Smrggive_advice () 1372becc446Smrg{ 1382becc446Smrg # Normalize program name to check for. 1392becc446Smrg normalized_program=`echo "$1" | sed ' 1402becc446Smrg s/^gnu-//; t 1412becc446Smrg s/^gnu//; t 1422becc446Smrg s/^g//; t'` 1432becc446Smrg 1442becc446Smrg printf '%s\n' "'$1' is $msg." 1452becc446Smrg 1462becc446Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 147c1e8faa6Smrg autoheader_deps="'acconfig.h'" 148c1e8faa6Smrg automake_deps="'Makefile.am'" 149c1e8faa6Smrg aclocal_deps="'acinclude.m4'" 1502becc446Smrg case $normalized_program in 151c1e8faa6Smrg aclocal*) 152c1e8faa6Smrg echo "You should only need it if you modified $aclocal_deps or" 153c1e8faa6Smrg echo "$configure_deps." 154c1e8faa6Smrg ;; 1552becc446Smrg autoconf*) 156c1e8faa6Smrg echo "You should only need it if you modified $configure_deps." 157c1e8faa6Smrg ;; 158c1e8faa6Smrg autogen*) 159c1e8faa6Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 160c1e8faa6Smrg echo "You may want to install the GNU AutoGen package:" 161c1e8faa6Smrg echo "<$gnu_software_URL/autogen/>" 1622becc446Smrg ;; 1632becc446Smrg autoheader*) 164c1e8faa6Smrg echo "You should only need it if you modified $autoheader_deps or" 1652becc446Smrg echo "$configure_deps." 1662becc446Smrg ;; 1672becc446Smrg automake*) 168c1e8faa6Smrg echo "You should only need it if you modified $automake_deps or" 1692becc446Smrg echo "$configure_deps." 1702becc446Smrg ;; 171c1e8faa6Smrg autom4te*) 1722becc446Smrg echo "You might have modified some maintainer files that require" 1732becc446Smrg echo "the 'autom4te' program to be rebuilt." 174c1e8faa6Smrg ;; 175c1e8faa6Smrg autoreconf*) 176c1e8faa6Smrg echo "You should only need it if you modified $aclocal_deps or" 177c1e8faa6Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 178c1e8faa6Smrg echo "$configure_deps." 1792becc446Smrg ;; 1802becc446Smrg bison*|yacc*) 1812becc446Smrg echo "You should only need it if you modified a '.y' file." 1822becc446Smrg echo "You may want to install the GNU Bison package:" 1832becc446Smrg echo "<$gnu_software_URL/bison/>" 1842becc446Smrg ;; 1852becc446Smrg help2man*) 1862becc446Smrg echo "You should only need it if you modified a dependency" \ 1872becc446Smrg "of a man page." 1882becc446Smrg echo "You may want to install the GNU Help2man package:" 1892becc446Smrg echo "<$gnu_software_URL/help2man/>" 1902becc446Smrg ;; 191c1e8faa6Smrg lex*|flex*) 192c1e8faa6Smrg echo "You should only need it if you modified a '.l' file." 193c1e8faa6Smrg echo "You may want to install the Fast Lexical Analyzer package:" 194c1e8faa6Smrg echo "<$flex_URL>" 195c1e8faa6Smrg ;; 1962becc446Smrg makeinfo*) 1972becc446Smrg echo "You should only need it if you modified a '.texi' file, or" 1982becc446Smrg echo "any other file indirectly affecting the aspect of the manual." 1992becc446Smrg echo "You might want to install the Texinfo package:" 2002becc446Smrg echo "<$gnu_software_URL/texinfo/>" 2012becc446Smrg echo "The spurious makeinfo call might also be the consequence of" 2022becc446Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 2032becc446Smrg echo "want to install GNU make:" 2042becc446Smrg echo "<$gnu_software_URL/make/>" 2052becc446Smrg ;; 206c1e8faa6Smrg perl*) 207c1e8faa6Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 208c1e8faa6Smrg echo " assorted other tools, or if you modified a Perl source file." 209c1e8faa6Smrg echo "You may want to install the Perl 5 language interpreter:" 210c1e8faa6Smrg echo "<$perl_URL>" 211c1e8faa6Smrg ;; 2122becc446Smrg *) 2132becc446Smrg echo "You might have modified some files without having the proper" 2142becc446Smrg echo "tools for further handling them. Check the 'README' file, it" 2152becc446Smrg echo "often tells you about the needed prerequisites for installing" 2162becc446Smrg echo "this package. You may also peek at any GNU archive site, in" 2172becc446Smrg echo "case some other package contains this missing '$1' program." 2182becc446Smrg ;; 2192becc446Smrg esac 220c1e8faa6Smrg program_details "$normalized_program" 2212becc446Smrg} 2222becc446Smrg 2232becc446Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2242becc446Smrg -e '2,$s/^/ /' >&2 2252becc446Smrg 2262becc446Smrg# Propagate the correct exit status (expected to be 127 for a program 2272becc446Smrg# not found, 63 for a program that failed due to version mismatch). 2282becc446Smrgexit $st 2298650bb69Smrg 2308650bb69Smrg# Local variables: 2313458e6c2Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2328650bb69Smrg# time-stamp-start: "scriptversion=" 2338650bb69Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2343458e6c2Smrg# time-stamp-time-zone: "UTC0" 2358650bb69Smrg# time-stamp-end: "; # UTC" 2368650bb69Smrg# End: 237