19aa228fdSmrg#! /bin/sh 246374b8dSmrg# Common wrapper for a few potentially missing GNU and other programs. 39aa228fdSmrg 446374b8dSmrgscriptversion=2024-06-07.14; # UTC 59aa228fdSmrg 646374b8dSmrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 746374b8dSmrg 846374b8dSmrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 90c7e83b2Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 109aa228fdSmrg 119aa228fdSmrg# This program is free software; you can redistribute it and/or modify 129aa228fdSmrg# it under the terms of the GNU General Public License as published by 139aa228fdSmrg# the Free Software Foundation; either version 2, or (at your option) 149aa228fdSmrg# any later version. 159aa228fdSmrg 169aa228fdSmrg# This program is distributed in the hope that it will be useful, 179aa228fdSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 189aa228fdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 199aa228fdSmrg# GNU General Public License for more details. 209aa228fdSmrg 219aa228fdSmrg# You should have received a copy of the GNU General Public License 22e39ce84cSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 239aa228fdSmrg 249aa228fdSmrg# As a special exception to the GNU General Public License, if you 259aa228fdSmrg# distribute this file as part of a program that contains a 269aa228fdSmrg# configuration script generated by Autoconf, you may include it under 279aa228fdSmrg# the same distribution terms that you use for the rest of that program. 289aa228fdSmrg 299aa228fdSmrgif test $# -eq 0; then 300c7e83b2Smrg echo 1>&2 "Try '$0 --help' for more information" 319aa228fdSmrg exit 1 329aa228fdSmrgfi 339aa228fdSmrg 340c7e83b2Smrgcase $1 in 359aa228fdSmrg 360c7e83b2Smrg --is-lightweight) 370c7e83b2Smrg # Used by our autoconf macros to check whether the available missing 380c7e83b2Smrg # script is modern enough. 390c7e83b2Smrg exit 0 400c7e83b2Smrg ;; 419aa228fdSmrg 420c7e83b2Smrg --run) 430c7e83b2Smrg # Back-compat with the calling convention used by older automake. 440c7e83b2Smrg shift 450c7e83b2Smrg ;; 469aa228fdSmrg 479aa228fdSmrg -h|--h|--he|--hel|--help) 489aa228fdSmrg echo "\ 499aa228fdSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 509aa228fdSmrg 510c7e83b2SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 520c7e83b2Smrgto PROGRAM being missing or too old. 539aa228fdSmrg 549aa228fdSmrgOptions: 559aa228fdSmrg -h, --help display this help and exit 569aa228fdSmrg -v, --version output version information and exit 579aa228fdSmrg 589aa228fdSmrgSupported PROGRAM values: 5946374b8dSmrgaclocal autoconf autogen autoheader autom4te automake autoreconf 6046374b8dSmrgbison flex help2man lex makeinfo perl yacc 619aa228fdSmrg 620c7e83b2SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 630c7e83b2Smrg'g' are ignored when checking the name. 648f65982aSmrg 6546374b8dSmrgReport bugs to <bug-automake@gnu.org>. 6646374b8dSmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 6746374b8dSmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 689aa228fdSmrg exit $? 699aa228fdSmrg ;; 709aa228fdSmrg 719aa228fdSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 7246374b8dSmrg echo "missing (GNU Automake) $scriptversion" 739aa228fdSmrg exit $? 749aa228fdSmrg ;; 759aa228fdSmrg 769aa228fdSmrg -*) 770c7e83b2Smrg echo 1>&2 "$0: unknown '$1' option" 780c7e83b2Smrg echo 1>&2 "Try '$0 --help' for more information" 799aa228fdSmrg exit 1 809aa228fdSmrg ;; 819aa228fdSmrg 829aa228fdSmrgesac 839aa228fdSmrg 840c7e83b2Smrg# Run the given program, remember its exit status. 850c7e83b2Smrg"$@"; st=$? 860c7e83b2Smrg 870c7e83b2Smrg# If it succeeded, we are done. 880c7e83b2Smrgtest $st -eq 0 && exit 0 890c7e83b2Smrg 900c7e83b2Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 910c7e83b2Smrg# passed; such an option is passed most likely to detect whether the 920c7e83b2Smrg# program is present and works. 930c7e83b2Smrgcase $2 in --version|--help) exit $st;; esac 940c7e83b2Smrg 950c7e83b2Smrg# Exit code 63 means version mismatch. This often happens when the user 960c7e83b2Smrg# tries to use an ancient version of a tool on a file that requires a 970c7e83b2Smrg# minimum version. 980c7e83b2Smrgif test $st -eq 63; then 990c7e83b2Smrg msg="probably too old" 1000c7e83b2Smrgelif test $st -eq 127; then 1010c7e83b2Smrg # Program was missing. 1020c7e83b2Smrg msg="missing on your system" 1030c7e83b2Smrgelse 1040c7e83b2Smrg # Program was found and executed, but failed. Give up. 1050c7e83b2Smrg exit $st 1060c7e83b2Smrgfi 1079aa228fdSmrg 108e39ce84cSmrgperl_URL=https://www.perl.org/ 109e39ce84cSmrgflex_URL=https://github.com/westes/flex 110e39ce84cSmrggnu_software_URL=https://www.gnu.org/software 1110c7e83b2Smrg 1120c7e83b2Smrgprogram_details () 1130c7e83b2Smrg{ 1140c7e83b2Smrg case $1 in 11546374b8dSmrg aclocal|automake|autoreconf) 1160c7e83b2Smrg echo "The '$1' program is part of the GNU Automake package:" 1170c7e83b2Smrg echo "<$gnu_software_URL/automake>" 1180c7e83b2Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1190c7e83b2Smrg echo "<$gnu_software_URL/autoconf>" 1200c7e83b2Smrg echo "<$gnu_software_URL/m4/>" 1210c7e83b2Smrg echo "<$perl_URL>" 1220c7e83b2Smrg ;; 1230c7e83b2Smrg autoconf|autom4te|autoheader) 1240c7e83b2Smrg echo "The '$1' program is part of the GNU Autoconf package:" 1250c7e83b2Smrg echo "<$gnu_software_URL/autoconf/>" 1260c7e83b2Smrg echo "It also requires GNU m4 and Perl in order to run:" 1270c7e83b2Smrg echo "<$gnu_software_URL/m4/>" 1280c7e83b2Smrg echo "<$perl_URL>" 1290c7e83b2Smrg ;; 13046374b8dSmrg *) 13146374b8dSmrg : 13246374b8dSmrg ;; 1330c7e83b2Smrg esac 1340c7e83b2Smrg} 1350c7e83b2Smrg 1360c7e83b2Smrggive_advice () 1370c7e83b2Smrg{ 1380c7e83b2Smrg # Normalize program name to check for. 1390c7e83b2Smrg normalized_program=`echo "$1" | sed ' 1400c7e83b2Smrg s/^gnu-//; t 1410c7e83b2Smrg s/^gnu//; t 1420c7e83b2Smrg s/^g//; t'` 1430c7e83b2Smrg 1440c7e83b2Smrg printf '%s\n' "'$1' is $msg." 1450c7e83b2Smrg 1460c7e83b2Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14746374b8dSmrg autoheader_deps="'acconfig.h'" 14846374b8dSmrg automake_deps="'Makefile.am'" 14946374b8dSmrg aclocal_deps="'acinclude.m4'" 1500c7e83b2Smrg case $normalized_program in 15146374b8dSmrg aclocal*) 15246374b8dSmrg echo "You should only need it if you modified $aclocal_deps or" 15346374b8dSmrg echo "$configure_deps." 15446374b8dSmrg ;; 1550c7e83b2Smrg autoconf*) 15646374b8dSmrg echo "You should only need it if you modified $configure_deps." 15746374b8dSmrg ;; 15846374b8dSmrg autogen*) 15946374b8dSmrg echo "You should only need it if you modified a '.def' or '.tpl' file." 16046374b8dSmrg echo "You may want to install the GNU AutoGen package:" 16146374b8dSmrg echo "<$gnu_software_URL/autogen/>" 1620c7e83b2Smrg ;; 1630c7e83b2Smrg autoheader*) 16446374b8dSmrg echo "You should only need it if you modified $autoheader_deps or" 1650c7e83b2Smrg echo "$configure_deps." 1660c7e83b2Smrg ;; 1670c7e83b2Smrg automake*) 16846374b8dSmrg echo "You should only need it if you modified $automake_deps or" 1690c7e83b2Smrg echo "$configure_deps." 1700c7e83b2Smrg ;; 17146374b8dSmrg autom4te*) 1720c7e83b2Smrg echo "You might have modified some maintainer files that require" 1730c7e83b2Smrg echo "the 'autom4te' program to be rebuilt." 17446374b8dSmrg ;; 17546374b8dSmrg autoreconf*) 17646374b8dSmrg echo "You should only need it if you modified $aclocal_deps or" 17746374b8dSmrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 17846374b8dSmrg echo "$configure_deps." 1790c7e83b2Smrg ;; 1800c7e83b2Smrg bison*|yacc*) 1810c7e83b2Smrg echo "You should only need it if you modified a '.y' file." 1820c7e83b2Smrg echo "You may want to install the GNU Bison package:" 1830c7e83b2Smrg echo "<$gnu_software_URL/bison/>" 1840c7e83b2Smrg ;; 1850c7e83b2Smrg help2man*) 1860c7e83b2Smrg echo "You should only need it if you modified a dependency" \ 1870c7e83b2Smrg "of a man page." 1880c7e83b2Smrg echo "You may want to install the GNU Help2man package:" 1890c7e83b2Smrg echo "<$gnu_software_URL/help2man/>" 1900c7e83b2Smrg ;; 19146374b8dSmrg lex*|flex*) 19246374b8dSmrg echo "You should only need it if you modified a '.l' file." 19346374b8dSmrg echo "You may want to install the Fast Lexical Analyzer package:" 19446374b8dSmrg echo "<$flex_URL>" 19546374b8dSmrg ;; 1960c7e83b2Smrg makeinfo*) 1970c7e83b2Smrg echo "You should only need it if you modified a '.texi' file, or" 1980c7e83b2Smrg echo "any other file indirectly affecting the aspect of the manual." 1990c7e83b2Smrg echo "You might want to install the Texinfo package:" 2000c7e83b2Smrg echo "<$gnu_software_URL/texinfo/>" 2010c7e83b2Smrg echo "The spurious makeinfo call might also be the consequence of" 2020c7e83b2Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 2030c7e83b2Smrg echo "want to install GNU make:" 2040c7e83b2Smrg echo "<$gnu_software_URL/make/>" 2050c7e83b2Smrg ;; 20646374b8dSmrg perl*) 20746374b8dSmrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 20846374b8dSmrg echo " assorted other tools, or if you modified a Perl source file." 20946374b8dSmrg echo "You may want to install the Perl 5 language interpreter:" 21046374b8dSmrg echo "<$perl_URL>" 21146374b8dSmrg ;; 2120c7e83b2Smrg *) 2130c7e83b2Smrg echo "You might have modified some files without having the proper" 2140c7e83b2Smrg echo "tools for further handling them. Check the 'README' file, it" 2150c7e83b2Smrg echo "often tells you about the needed prerequisites for installing" 2160c7e83b2Smrg echo "this package. You may also peek at any GNU archive site, in" 2170c7e83b2Smrg echo "case some other package contains this missing '$1' program." 2180c7e83b2Smrg ;; 2190c7e83b2Smrg esac 22046374b8dSmrg program_details "$normalized_program" 2210c7e83b2Smrg} 2220c7e83b2Smrg 2230c7e83b2Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2240c7e83b2Smrg -e '2,$s/^/ /' >&2 2250c7e83b2Smrg 2260c7e83b2Smrg# Propagate the correct exit status (expected to be 127 for a program 2270c7e83b2Smrg# not found, 63 for a program that failed due to version mismatch). 2280c7e83b2Smrgexit $st 2299aa228fdSmrg 2309aa228fdSmrg# Local variables: 231e39ce84cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2329aa228fdSmrg# time-stamp-start: "scriptversion=" 2339aa228fdSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 234e39ce84cSmrg# time-stamp-time-zone: "UTC0" 2358f65982aSmrg# time-stamp-end: "; # UTC" 2369aa228fdSmrg# End: 237