13da7aff1Smrg#! /bin/sh 21e42c052Smrg# Common wrapper for a few potentially missing GNU and other programs. 3e531b1a7Smrg 41e42c052Smrgscriptversion=2024-06-07.14; # UTC 5e531b1a7Smrg 61e42c052Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 71e42c052Smrg 81e42c052Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 93e999d35Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 103da7aff1Smrg 113da7aff1Smrg# This program is free software; you can redistribute it and/or modify 123da7aff1Smrg# it under the terms of the GNU General Public License as published by 133da7aff1Smrg# the Free Software Foundation; either version 2, or (at your option) 143da7aff1Smrg# any later version. 153da7aff1Smrg 163da7aff1Smrg# This program is distributed in the hope that it will be useful, 173da7aff1Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 183da7aff1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 193da7aff1Smrg# GNU General Public License for more details. 203da7aff1Smrg 213da7aff1Smrg# You should have received a copy of the GNU General Public License 223a99fc18Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 233da7aff1Smrg 243da7aff1Smrg# As a special exception to the GNU General Public License, if you 253da7aff1Smrg# distribute this file as part of a program that contains a 263da7aff1Smrg# configuration script generated by Autoconf, you may include it under 273da7aff1Smrg# the same distribution terms that you use for the rest of that program. 283da7aff1Smrg 293da7aff1Smrgif test $# -eq 0; then 303e999d35Smrg echo 1>&2 "Try '$0 --help' for more information" 313da7aff1Smrg exit 1 323da7aff1Smrgfi 333da7aff1Smrg 343e999d35Smrgcase $1 in 353da7aff1Smrg 363e999d35Smrg --is-lightweight) 373e999d35Smrg # Used by our autoconf macros to check whether the available missing 383e999d35Smrg # script is modern enough. 393e999d35Smrg exit 0 403e999d35Smrg ;; 41e531b1a7Smrg 423e999d35Smrg --run) 433e999d35Smrg # Back-compat with the calling convention used by older automake. 443e999d35Smrg shift 453e999d35Smrg ;; 463da7aff1Smrg 473da7aff1Smrg -h|--h|--he|--hel|--help) 483da7aff1Smrg echo "\ 493da7aff1Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 503da7aff1Smrg 513e999d35SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 523e999d35Smrgto PROGRAM being missing or too old. 533da7aff1Smrg 543da7aff1SmrgOptions: 553da7aff1Smrg -h, --help display this help and exit 563da7aff1Smrg -v, --version output version information and exit 573da7aff1Smrg 583da7aff1SmrgSupported PROGRAM values: 591e42c052Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 601e42c052Smrgbison flex help2man lex makeinfo perl yacc 61e531b1a7Smrg 623e999d35SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 633e999d35Smrg'g' are ignored when checking the name. 64e531b1a7Smrg 651e42c052SmrgReport bugs to <bug-automake@gnu.org>. 661e42c052SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 671e42c052SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 68e531b1a7Smrg exit $? 693da7aff1Smrg ;; 703da7aff1Smrg 713da7aff1Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 721e42c052Smrg echo "missing (GNU Automake) $scriptversion" 73e531b1a7Smrg exit $? 743da7aff1Smrg ;; 753da7aff1Smrg 763da7aff1Smrg -*) 773e999d35Smrg echo 1>&2 "$0: unknown '$1' option" 783e999d35Smrg echo 1>&2 "Try '$0 --help' for more information" 793da7aff1Smrg exit 1 803da7aff1Smrg ;; 813da7aff1Smrg 82e531b1a7Smrgesac 83e531b1a7Smrg 843e999d35Smrg# Run the given program, remember its exit status. 853e999d35Smrg"$@"; st=$? 863e999d35Smrg 873e999d35Smrg# If it succeeded, we are done. 883e999d35Smrgtest $st -eq 0 && exit 0 893e999d35Smrg 903e999d35Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 913e999d35Smrg# passed; such an option is passed most likely to detect whether the 923e999d35Smrg# program is present and works. 933e999d35Smrgcase $2 in --version|--help) exit $st;; esac 943e999d35Smrg 953e999d35Smrg# Exit code 63 means version mismatch. This often happens when the user 963e999d35Smrg# tries to use an ancient version of a tool on a file that requires a 973e999d35Smrg# minimum version. 983e999d35Smrgif test $st -eq 63; then 993e999d35Smrg msg="probably too old" 1003e999d35Smrgelif test $st -eq 127; then 1013e999d35Smrg # Program was missing. 1023e999d35Smrg msg="missing on your system" 1033e999d35Smrgelse 1043e999d35Smrg # Program was found and executed, but failed. Give up. 1053e999d35Smrg exit $st 1063e999d35Smrgfi 1073da7aff1Smrg 1083a99fc18Smrgperl_URL=https://www.perl.org/ 1093a99fc18Smrgflex_URL=https://github.com/westes/flex 1103a99fc18Smrggnu_software_URL=https://www.gnu.org/software 1113e999d35Smrg 1123e999d35Smrgprogram_details () 1133e999d35Smrg{ 1143e999d35Smrg case $1 in 1151e42c052Smrg aclocal|automake|autoreconf) 1163e999d35Smrg echo "The '$1' program is part of the GNU Automake package:" 1173e999d35Smrg echo "<$gnu_software_URL/automake>" 1183e999d35Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1193e999d35Smrg echo "<$gnu_software_URL/autoconf>" 1203e999d35Smrg echo "<$gnu_software_URL/m4/>" 1213e999d35Smrg echo "<$perl_URL>" 1223e999d35Smrg ;; 1233e999d35Smrg autoconf|autom4te|autoheader) 1243e999d35Smrg echo "The '$1' program is part of the GNU Autoconf package:" 1253e999d35Smrg echo "<$gnu_software_URL/autoconf/>" 1263e999d35Smrg echo "It also requires GNU m4 and Perl in order to run:" 1273e999d35Smrg echo "<$gnu_software_URL/m4/>" 1283e999d35Smrg echo "<$perl_URL>" 1293e999d35Smrg ;; 1301e42c052Smrg *) 1311e42c052Smrg : 1321e42c052Smrg ;; 1333e999d35Smrg esac 1343e999d35Smrg} 1353e999d35Smrg 1363e999d35Smrggive_advice () 1373e999d35Smrg{ 1383e999d35Smrg # Normalize program name to check for. 1393e999d35Smrg normalized_program=`echo "$1" | sed ' 1403e999d35Smrg s/^gnu-//; t 1413e999d35Smrg s/^gnu//; t 1423e999d35Smrg s/^g//; t'` 1433e999d35Smrg 1443e999d35Smrg printf '%s\n' "'$1' is $msg." 1453e999d35Smrg 1463e999d35Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1471e42c052Smrg autoheader_deps="'acconfig.h'" 1481e42c052Smrg automake_deps="'Makefile.am'" 1491e42c052Smrg aclocal_deps="'acinclude.m4'" 1503e999d35Smrg case $normalized_program in 1511e42c052Smrg aclocal*) 1521e42c052Smrg echo "You should only need it if you modified $aclocal_deps or" 1531e42c052Smrg echo "$configure_deps." 1541e42c052Smrg ;; 1553e999d35Smrg autoconf*) 1561e42c052Smrg echo "You should only need it if you modified $configure_deps." 1571e42c052Smrg ;; 1581e42c052Smrg autogen*) 1591e42c052Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 1601e42c052Smrg echo "You may want to install the GNU AutoGen package:" 1611e42c052Smrg echo "<$gnu_software_URL/autogen/>" 1623e999d35Smrg ;; 1633e999d35Smrg autoheader*) 1641e42c052Smrg echo "You should only need it if you modified $autoheader_deps or" 1653e999d35Smrg echo "$configure_deps." 1663e999d35Smrg ;; 1673e999d35Smrg automake*) 1681e42c052Smrg echo "You should only need it if you modified $automake_deps or" 1693e999d35Smrg echo "$configure_deps." 1703e999d35Smrg ;; 1711e42c052Smrg autom4te*) 1723e999d35Smrg echo "You might have modified some maintainer files that require" 1733e999d35Smrg echo "the 'autom4te' program to be rebuilt." 1741e42c052Smrg ;; 1751e42c052Smrg autoreconf*) 1761e42c052Smrg echo "You should only need it if you modified $aclocal_deps or" 1771e42c052Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 1781e42c052Smrg echo "$configure_deps." 1793e999d35Smrg ;; 1803e999d35Smrg bison*|yacc*) 1813e999d35Smrg echo "You should only need it if you modified a '.y' file." 1823e999d35Smrg echo "You may want to install the GNU Bison package:" 1833e999d35Smrg echo "<$gnu_software_URL/bison/>" 1843e999d35Smrg ;; 1853e999d35Smrg help2man*) 1863e999d35Smrg echo "You should only need it if you modified a dependency" \ 1873e999d35Smrg "of a man page." 1883e999d35Smrg echo "You may want to install the GNU Help2man package:" 1893e999d35Smrg echo "<$gnu_software_URL/help2man/>" 1903e999d35Smrg ;; 1911e42c052Smrg lex*|flex*) 1921e42c052Smrg echo "You should only need it if you modified a '.l' file." 1931e42c052Smrg echo "You may want to install the Fast Lexical Analyzer package:" 1941e42c052Smrg echo "<$flex_URL>" 1951e42c052Smrg ;; 1963e999d35Smrg makeinfo*) 1973e999d35Smrg echo "You should only need it if you modified a '.texi' file, or" 1983e999d35Smrg echo "any other file indirectly affecting the aspect of the manual." 1993e999d35Smrg echo "You might want to install the Texinfo package:" 2003e999d35Smrg echo "<$gnu_software_URL/texinfo/>" 2013e999d35Smrg echo "The spurious makeinfo call might also be the consequence of" 2023e999d35Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 2033e999d35Smrg echo "want to install GNU make:" 2043e999d35Smrg echo "<$gnu_software_URL/make/>" 2053e999d35Smrg ;; 2061e42c052Smrg perl*) 2071e42c052Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 2081e42c052Smrg echo " assorted other tools, or if you modified a Perl source file." 2091e42c052Smrg echo "You may want to install the Perl 5 language interpreter:" 2101e42c052Smrg echo "<$perl_URL>" 2111e42c052Smrg ;; 2123e999d35Smrg *) 2133e999d35Smrg echo "You might have modified some files without having the proper" 2143e999d35Smrg echo "tools for further handling them. Check the 'README' file, it" 2153e999d35Smrg echo "often tells you about the needed prerequisites for installing" 2163e999d35Smrg echo "this package. You may also peek at any GNU archive site, in" 2173e999d35Smrg echo "case some other package contains this missing '$1' program." 2183e999d35Smrg ;; 2193e999d35Smrg esac 2201e42c052Smrg program_details "$normalized_program" 2213e999d35Smrg} 2223e999d35Smrg 2233e999d35Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2243e999d35Smrg -e '2,$s/^/ /' >&2 2253e999d35Smrg 2263e999d35Smrg# Propagate the correct exit status (expected to be 127 for a program 2273e999d35Smrg# not found, 63 for a program that failed due to version mismatch). 2283e999d35Smrgexit $st 229e531b1a7Smrg 230e531b1a7Smrg# Local variables: 2313a99fc18Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 232e531b1a7Smrg# time-stamp-start: "scriptversion=" 233e531b1a7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2343a99fc18Smrg# time-stamp-time-zone: "UTC0" 235e531b1a7Smrg# time-stamp-end: "; # UTC" 236e531b1a7Smrg# End: 237