10ed7c580Smrg#! /bin/sh 2a0cd246fSmrg# Common wrapper for a few potentially missing GNU and other programs. 30ed7c580Smrg 4a0cd246fSmrgscriptversion=2024-06-07.14; # UTC 50ed7c580Smrg 6a0cd246fSmrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 7a0cd246fSmrg 8a0cd246fSmrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 90ed7c580Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 100ed7c580Smrg 110ed7c580Smrg# This program is free software; you can redistribute it and/or modify 120ed7c580Smrg# it under the terms of the GNU General Public License as published by 130ed7c580Smrg# the Free Software Foundation; either version 2, or (at your option) 140ed7c580Smrg# any later version. 150ed7c580Smrg 160ed7c580Smrg# This program is distributed in the hope that it will be useful, 170ed7c580Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 180ed7c580Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 190ed7c580Smrg# GNU General Public License for more details. 200ed7c580Smrg 210ed7c580Smrg# You should have received a copy of the GNU General Public License 221a28b98bSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 230ed7c580Smrg 240ed7c580Smrg# As a special exception to the GNU General Public License, if you 250ed7c580Smrg# distribute this file as part of a program that contains a 260ed7c580Smrg# configuration script generated by Autoconf, you may include it under 270ed7c580Smrg# the same distribution terms that you use for the rest of that program. 280ed7c580Smrg 290ed7c580Smrgif test $# -eq 0; then 300ed7c580Smrg echo 1>&2 "Try '$0 --help' for more information" 310ed7c580Smrg exit 1 320ed7c580Smrgfi 330ed7c580Smrg 340ed7c580Smrgcase $1 in 350ed7c580Smrg 360ed7c580Smrg --is-lightweight) 370ed7c580Smrg # Used by our autoconf macros to check whether the available missing 380ed7c580Smrg # script is modern enough. 390ed7c580Smrg exit 0 400ed7c580Smrg ;; 410ed7c580Smrg 420ed7c580Smrg --run) 430ed7c580Smrg # Back-compat with the calling convention used by older automake. 440ed7c580Smrg shift 450ed7c580Smrg ;; 460ed7c580Smrg 470ed7c580Smrg -h|--h|--he|--hel|--help) 480ed7c580Smrg echo "\ 490ed7c580Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 500ed7c580Smrg 510ed7c580SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 520ed7c580Smrgto PROGRAM being missing or too old. 530ed7c580Smrg 540ed7c580SmrgOptions: 550ed7c580Smrg -h, --help display this help and exit 560ed7c580Smrg -v, --version output version information and exit 570ed7c580Smrg 580ed7c580SmrgSupported PROGRAM values: 59a0cd246fSmrgaclocal autoconf autogen autoheader autom4te automake autoreconf 60a0cd246fSmrgbison flex help2man lex makeinfo perl yacc 610ed7c580Smrg 620ed7c580SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 630ed7c580Smrg'g' are ignored when checking the name. 640ed7c580Smrg 65a0cd246fSmrgReport bugs to <bug-automake@gnu.org>. 66a0cd246fSmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 67a0cd246fSmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 680ed7c580Smrg exit $? 690ed7c580Smrg ;; 700ed7c580Smrg 710ed7c580Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 72a0cd246fSmrg echo "missing (GNU Automake) $scriptversion" 730ed7c580Smrg exit $? 740ed7c580Smrg ;; 750ed7c580Smrg 760ed7c580Smrg -*) 770ed7c580Smrg echo 1>&2 "$0: unknown '$1' option" 780ed7c580Smrg echo 1>&2 "Try '$0 --help' for more information" 790ed7c580Smrg exit 1 800ed7c580Smrg ;; 810ed7c580Smrg 820ed7c580Smrgesac 830ed7c580Smrg 840ed7c580Smrg# Run the given program, remember its exit status. 850ed7c580Smrg"$@"; st=$? 860ed7c580Smrg 870ed7c580Smrg# If it succeeded, we are done. 880ed7c580Smrgtest $st -eq 0 && exit 0 890ed7c580Smrg 900ed7c580Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 910ed7c580Smrg# passed; such an option is passed most likely to detect whether the 920ed7c580Smrg# program is present and works. 930ed7c580Smrgcase $2 in --version|--help) exit $st;; esac 940ed7c580Smrg 950ed7c580Smrg# Exit code 63 means version mismatch. This often happens when the user 960ed7c580Smrg# tries to use an ancient version of a tool on a file that requires a 970ed7c580Smrg# minimum version. 980ed7c580Smrgif test $st -eq 63; then 990ed7c580Smrg msg="probably too old" 1000ed7c580Smrgelif test $st -eq 127; then 1010ed7c580Smrg # Program was missing. 1020ed7c580Smrg msg="missing on your system" 1030ed7c580Smrgelse 1040ed7c580Smrg # Program was found and executed, but failed. Give up. 1050ed7c580Smrg exit $st 1060ed7c580Smrgfi 1070ed7c580Smrg 1081a28b98bSmrgperl_URL=https://www.perl.org/ 1091a28b98bSmrgflex_URL=https://github.com/westes/flex 1101a28b98bSmrggnu_software_URL=https://www.gnu.org/software 1110ed7c580Smrg 1120ed7c580Smrgprogram_details () 1130ed7c580Smrg{ 1140ed7c580Smrg case $1 in 115a0cd246fSmrg aclocal|automake|autoreconf) 1160ed7c580Smrg echo "The '$1' program is part of the GNU Automake package:" 1170ed7c580Smrg echo "<$gnu_software_URL/automake>" 1180ed7c580Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1190ed7c580Smrg echo "<$gnu_software_URL/autoconf>" 1200ed7c580Smrg echo "<$gnu_software_URL/m4/>" 1210ed7c580Smrg echo "<$perl_URL>" 1220ed7c580Smrg ;; 1230ed7c580Smrg autoconf|autom4te|autoheader) 1240ed7c580Smrg echo "The '$1' program is part of the GNU Autoconf package:" 1250ed7c580Smrg echo "<$gnu_software_URL/autoconf/>" 1260ed7c580Smrg echo "It also requires GNU m4 and Perl in order to run:" 1270ed7c580Smrg echo "<$gnu_software_URL/m4/>" 1280ed7c580Smrg echo "<$perl_URL>" 1290ed7c580Smrg ;; 130a0cd246fSmrg *) 131a0cd246fSmrg : 132a0cd246fSmrg ;; 1330ed7c580Smrg esac 1340ed7c580Smrg} 1350ed7c580Smrg 1360ed7c580Smrggive_advice () 1370ed7c580Smrg{ 1380ed7c580Smrg # Normalize program name to check for. 1390ed7c580Smrg normalized_program=`echo "$1" | sed ' 1400ed7c580Smrg s/^gnu-//; t 1410ed7c580Smrg s/^gnu//; t 1420ed7c580Smrg s/^g//; t'` 1430ed7c580Smrg 1440ed7c580Smrg printf '%s\n' "'$1' is $msg." 1450ed7c580Smrg 1460ed7c580Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 147a0cd246fSmrg autoheader_deps="'acconfig.h'" 148a0cd246fSmrg automake_deps="'Makefile.am'" 149a0cd246fSmrg aclocal_deps="'acinclude.m4'" 1500ed7c580Smrg case $normalized_program in 151a0cd246fSmrg aclocal*) 152a0cd246fSmrg echo "You should only need it if you modified $aclocal_deps or" 153a0cd246fSmrg echo "$configure_deps." 154a0cd246fSmrg ;; 1550ed7c580Smrg autoconf*) 156a0cd246fSmrg echo "You should only need it if you modified $configure_deps." 157a0cd246fSmrg ;; 158a0cd246fSmrg autogen*) 159a0cd246fSmrg echo "You should only need it if you modified a '.def' or '.tpl' file." 160a0cd246fSmrg echo "You may want to install the GNU AutoGen package:" 161a0cd246fSmrg echo "<$gnu_software_URL/autogen/>" 1620ed7c580Smrg ;; 1630ed7c580Smrg autoheader*) 164a0cd246fSmrg echo "You should only need it if you modified $autoheader_deps or" 1650ed7c580Smrg echo "$configure_deps." 1660ed7c580Smrg ;; 1670ed7c580Smrg automake*) 168a0cd246fSmrg echo "You should only need it if you modified $automake_deps or" 1690ed7c580Smrg echo "$configure_deps." 1700ed7c580Smrg ;; 171a0cd246fSmrg autom4te*) 1720ed7c580Smrg echo "You might have modified some maintainer files that require" 1730ed7c580Smrg echo "the 'autom4te' program to be rebuilt." 174a0cd246fSmrg ;; 175a0cd246fSmrg autoreconf*) 176a0cd246fSmrg echo "You should only need it if you modified $aclocal_deps or" 177a0cd246fSmrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 178a0cd246fSmrg echo "$configure_deps." 1790ed7c580Smrg ;; 1800ed7c580Smrg bison*|yacc*) 1810ed7c580Smrg echo "You should only need it if you modified a '.y' file." 1820ed7c580Smrg echo "You may want to install the GNU Bison package:" 1830ed7c580Smrg echo "<$gnu_software_URL/bison/>" 1840ed7c580Smrg ;; 1850ed7c580Smrg help2man*) 1860ed7c580Smrg echo "You should only need it if you modified a dependency" \ 1870ed7c580Smrg "of a man page." 1880ed7c580Smrg echo "You may want to install the GNU Help2man package:" 1890ed7c580Smrg echo "<$gnu_software_URL/help2man/>" 1900ed7c580Smrg ;; 191a0cd246fSmrg lex*|flex*) 192a0cd246fSmrg echo "You should only need it if you modified a '.l' file." 193a0cd246fSmrg echo "You may want to install the Fast Lexical Analyzer package:" 194a0cd246fSmrg echo "<$flex_URL>" 195a0cd246fSmrg ;; 1960ed7c580Smrg makeinfo*) 1970ed7c580Smrg echo "You should only need it if you modified a '.texi' file, or" 1980ed7c580Smrg echo "any other file indirectly affecting the aspect of the manual." 1990ed7c580Smrg echo "You might want to install the Texinfo package:" 2000ed7c580Smrg echo "<$gnu_software_URL/texinfo/>" 2010ed7c580Smrg echo "The spurious makeinfo call might also be the consequence of" 2020ed7c580Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 2030ed7c580Smrg echo "want to install GNU make:" 2040ed7c580Smrg echo "<$gnu_software_URL/make/>" 2050ed7c580Smrg ;; 206a0cd246fSmrg perl*) 207a0cd246fSmrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 208a0cd246fSmrg echo " assorted other tools, or if you modified a Perl source file." 209a0cd246fSmrg echo "You may want to install the Perl 5 language interpreter:" 210a0cd246fSmrg echo "<$perl_URL>" 211a0cd246fSmrg ;; 2120ed7c580Smrg *) 2130ed7c580Smrg echo "You might have modified some files without having the proper" 2140ed7c580Smrg echo "tools for further handling them. Check the 'README' file, it" 2150ed7c580Smrg echo "often tells you about the needed prerequisites for installing" 2160ed7c580Smrg echo "this package. You may also peek at any GNU archive site, in" 2170ed7c580Smrg echo "case some other package contains this missing '$1' program." 2180ed7c580Smrg ;; 2190ed7c580Smrg esac 220a0cd246fSmrg program_details "$normalized_program" 2210ed7c580Smrg} 2220ed7c580Smrg 2230ed7c580Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2240ed7c580Smrg -e '2,$s/^/ /' >&2 2250ed7c580Smrg 2260ed7c580Smrg# Propagate the correct exit status (expected to be 127 for a program 2270ed7c580Smrg# not found, 63 for a program that failed due to version mismatch). 2280ed7c580Smrgexit $st 2290ed7c580Smrg 2300ed7c580Smrg# Local variables: 2311a28b98bSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2320ed7c580Smrg# time-stamp-start: "scriptversion=" 2330ed7c580Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2341a28b98bSmrg# time-stamp-time-zone: "UTC0" 2350ed7c580Smrg# time-stamp-end: "; # UTC" 2360ed7c580Smrg# End: 237