173143b9aSmrg#! /bin/sh 247a4502cSmrg# Common wrapper for a few potentially missing GNU and other programs. 373143b9aSmrg 447a4502cSmrgscriptversion=2024-06-07.14; # UTC 573143b9aSmrg 647a4502cSmrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 747a4502cSmrg 847a4502cSmrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 975ebec6dSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 1073143b9aSmrg 1173143b9aSmrg# This program is free software; you can redistribute it and/or modify 1273143b9aSmrg# it under the terms of the GNU General Public License as published by 1373143b9aSmrg# the Free Software Foundation; either version 2, or (at your option) 1473143b9aSmrg# any later version. 1573143b9aSmrg 1673143b9aSmrg# This program is distributed in the hope that it will be useful, 1773143b9aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1873143b9aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1973143b9aSmrg# GNU General Public License for more details. 2073143b9aSmrg 2173143b9aSmrg# You should have received a copy of the GNU General Public License 22e45ace2bSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2373143b9aSmrg 2473143b9aSmrg# As a special exception to the GNU General Public License, if you 2573143b9aSmrg# distribute this file as part of a program that contains a 2673143b9aSmrg# configuration script generated by Autoconf, you may include it under 2773143b9aSmrg# the same distribution terms that you use for the rest of that program. 2873143b9aSmrg 2973143b9aSmrgif test $# -eq 0; then 3075ebec6dSmrg echo 1>&2 "Try '$0 --help' for more information" 3173143b9aSmrg exit 1 3273143b9aSmrgfi 3373143b9aSmrg 3475ebec6dSmrgcase $1 in 3573143b9aSmrg 3675ebec6dSmrg --is-lightweight) 3775ebec6dSmrg # Used by our autoconf macros to check whether the available missing 3875ebec6dSmrg # script is modern enough. 3975ebec6dSmrg exit 0 4075ebec6dSmrg ;; 4173143b9aSmrg 4275ebec6dSmrg --run) 4375ebec6dSmrg # Back-compat with the calling convention used by older automake. 4475ebec6dSmrg shift 4575ebec6dSmrg ;; 4673143b9aSmrg 4773143b9aSmrg -h|--h|--he|--hel|--help) 4873143b9aSmrg echo "\ 4973143b9aSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 5073143b9aSmrg 5175ebec6dSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5275ebec6dSmrgto PROGRAM being missing or too old. 5373143b9aSmrg 5473143b9aSmrgOptions: 5573143b9aSmrg -h, --help display this help and exit 5673143b9aSmrg -v, --version output version information and exit 5773143b9aSmrg 5873143b9aSmrgSupported PROGRAM values: 5947a4502cSmrgaclocal autoconf autogen autoheader autom4te automake autoreconf 6047a4502cSmrgbison flex help2man lex makeinfo perl yacc 6173143b9aSmrg 6275ebec6dSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6375ebec6dSmrg'g' are ignored when checking the name. 64b53e5eeaSmrg 6547a4502cSmrgReport bugs to <bug-automake@gnu.org>. 6647a4502cSmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 6747a4502cSmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 6873143b9aSmrg exit $? 6973143b9aSmrg ;; 7073143b9aSmrg 7173143b9aSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 7247a4502cSmrg echo "missing (GNU Automake) $scriptversion" 7373143b9aSmrg exit $? 7473143b9aSmrg ;; 7573143b9aSmrg 7673143b9aSmrg -*) 7775ebec6dSmrg echo 1>&2 "$0: unknown '$1' option" 7875ebec6dSmrg echo 1>&2 "Try '$0 --help' for more information" 7973143b9aSmrg exit 1 8073143b9aSmrg ;; 8173143b9aSmrg 8273143b9aSmrgesac 8373143b9aSmrg 8475ebec6dSmrg# Run the given program, remember its exit status. 8575ebec6dSmrg"$@"; st=$? 8675ebec6dSmrg 8775ebec6dSmrg# If it succeeded, we are done. 8875ebec6dSmrgtest $st -eq 0 && exit 0 8975ebec6dSmrg 9075ebec6dSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 9175ebec6dSmrg# passed; such an option is passed most likely to detect whether the 9275ebec6dSmrg# program is present and works. 9375ebec6dSmrgcase $2 in --version|--help) exit $st;; esac 9475ebec6dSmrg 9575ebec6dSmrg# Exit code 63 means version mismatch. This often happens when the user 9675ebec6dSmrg# tries to use an ancient version of a tool on a file that requires a 9775ebec6dSmrg# minimum version. 9875ebec6dSmrgif test $st -eq 63; then 9975ebec6dSmrg msg="probably too old" 10075ebec6dSmrgelif test $st -eq 127; then 10175ebec6dSmrg # Program was missing. 10275ebec6dSmrg msg="missing on your system" 10375ebec6dSmrgelse 10475ebec6dSmrg # Program was found and executed, but failed. Give up. 10575ebec6dSmrg exit $st 10675ebec6dSmrgfi 10773143b9aSmrg 108e45ace2bSmrgperl_URL=https://www.perl.org/ 109e45ace2bSmrgflex_URL=https://github.com/westes/flex 110e45ace2bSmrggnu_software_URL=https://www.gnu.org/software 11175ebec6dSmrg 11275ebec6dSmrgprogram_details () 11375ebec6dSmrg{ 11475ebec6dSmrg case $1 in 11547a4502cSmrg aclocal|automake|autoreconf) 11675ebec6dSmrg echo "The '$1' program is part of the GNU Automake package:" 11775ebec6dSmrg echo "<$gnu_software_URL/automake>" 11875ebec6dSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11975ebec6dSmrg echo "<$gnu_software_URL/autoconf>" 12075ebec6dSmrg echo "<$gnu_software_URL/m4/>" 12175ebec6dSmrg echo "<$perl_URL>" 12275ebec6dSmrg ;; 12375ebec6dSmrg autoconf|autom4te|autoheader) 12475ebec6dSmrg echo "The '$1' program is part of the GNU Autoconf package:" 12575ebec6dSmrg echo "<$gnu_software_URL/autoconf/>" 12675ebec6dSmrg echo "It also requires GNU m4 and Perl in order to run:" 12775ebec6dSmrg echo "<$gnu_software_URL/m4/>" 12875ebec6dSmrg echo "<$perl_URL>" 12975ebec6dSmrg ;; 13047a4502cSmrg *) 13147a4502cSmrg : 13247a4502cSmrg ;; 13375ebec6dSmrg esac 13475ebec6dSmrg} 13575ebec6dSmrg 13675ebec6dSmrggive_advice () 13775ebec6dSmrg{ 13875ebec6dSmrg # Normalize program name to check for. 13975ebec6dSmrg normalized_program=`echo "$1" | sed ' 14075ebec6dSmrg s/^gnu-//; t 14175ebec6dSmrg s/^gnu//; t 14275ebec6dSmrg s/^g//; t'` 14375ebec6dSmrg 14475ebec6dSmrg printf '%s\n' "'$1' is $msg." 14575ebec6dSmrg 14675ebec6dSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14747a4502cSmrg autoheader_deps="'acconfig.h'" 14847a4502cSmrg automake_deps="'Makefile.am'" 14947a4502cSmrg aclocal_deps="'acinclude.m4'" 15075ebec6dSmrg case $normalized_program in 15147a4502cSmrg aclocal*) 15247a4502cSmrg echo "You should only need it if you modified $aclocal_deps or" 15347a4502cSmrg echo "$configure_deps." 15447a4502cSmrg ;; 15575ebec6dSmrg autoconf*) 15647a4502cSmrg echo "You should only need it if you modified $configure_deps." 15747a4502cSmrg ;; 15847a4502cSmrg autogen*) 15947a4502cSmrg echo "You should only need it if you modified a '.def' or '.tpl' file." 16047a4502cSmrg echo "You may want to install the GNU AutoGen package:" 16147a4502cSmrg echo "<$gnu_software_URL/autogen/>" 16275ebec6dSmrg ;; 16375ebec6dSmrg autoheader*) 16447a4502cSmrg echo "You should only need it if you modified $autoheader_deps or" 16575ebec6dSmrg echo "$configure_deps." 16675ebec6dSmrg ;; 16775ebec6dSmrg automake*) 16847a4502cSmrg echo "You should only need it if you modified $automake_deps or" 16975ebec6dSmrg echo "$configure_deps." 17075ebec6dSmrg ;; 17147a4502cSmrg autom4te*) 17275ebec6dSmrg echo "You might have modified some maintainer files that require" 1733d2ed3e3Smrg echo "the 'autom4te' program to be rebuilt." 17447a4502cSmrg ;; 17547a4502cSmrg autoreconf*) 17647a4502cSmrg echo "You should only need it if you modified $aclocal_deps or" 17747a4502cSmrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 17847a4502cSmrg echo "$configure_deps." 17975ebec6dSmrg ;; 18075ebec6dSmrg bison*|yacc*) 18175ebec6dSmrg echo "You should only need it if you modified a '.y' file." 18275ebec6dSmrg echo "You may want to install the GNU Bison package:" 18375ebec6dSmrg echo "<$gnu_software_URL/bison/>" 18475ebec6dSmrg ;; 18575ebec6dSmrg help2man*) 18675ebec6dSmrg echo "You should only need it if you modified a dependency" \ 18775ebec6dSmrg "of a man page." 18875ebec6dSmrg echo "You may want to install the GNU Help2man package:" 18975ebec6dSmrg echo "<$gnu_software_URL/help2man/>" 19075ebec6dSmrg ;; 19147a4502cSmrg lex*|flex*) 19247a4502cSmrg echo "You should only need it if you modified a '.l' file." 19347a4502cSmrg echo "You may want to install the Fast Lexical Analyzer package:" 19447a4502cSmrg echo "<$flex_URL>" 19547a4502cSmrg ;; 19675ebec6dSmrg makeinfo*) 19775ebec6dSmrg echo "You should only need it if you modified a '.texi' file, or" 19875ebec6dSmrg echo "any other file indirectly affecting the aspect of the manual." 19975ebec6dSmrg echo "You might want to install the Texinfo package:" 20075ebec6dSmrg echo "<$gnu_software_URL/texinfo/>" 20175ebec6dSmrg echo "The spurious makeinfo call might also be the consequence of" 20275ebec6dSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 20375ebec6dSmrg echo "want to install GNU make:" 20475ebec6dSmrg echo "<$gnu_software_URL/make/>" 20575ebec6dSmrg ;; 20647a4502cSmrg perl*) 20747a4502cSmrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 20847a4502cSmrg echo " assorted other tools, or if you modified a Perl source file." 20947a4502cSmrg echo "You may want to install the Perl 5 language interpreter:" 21047a4502cSmrg echo "<$perl_URL>" 21147a4502cSmrg ;; 21275ebec6dSmrg *) 21375ebec6dSmrg echo "You might have modified some files without having the proper" 21475ebec6dSmrg echo "tools for further handling them. Check the 'README' file, it" 21575ebec6dSmrg echo "often tells you about the needed prerequisites for installing" 21675ebec6dSmrg echo "this package. You may also peek at any GNU archive site, in" 21775ebec6dSmrg echo "case some other package contains this missing '$1' program." 21875ebec6dSmrg ;; 21975ebec6dSmrg esac 22047a4502cSmrg program_details "$normalized_program" 22175ebec6dSmrg} 22275ebec6dSmrg 22375ebec6dSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 22475ebec6dSmrg -e '2,$s/^/ /' >&2 22575ebec6dSmrg 22675ebec6dSmrg# Propagate the correct exit status (expected to be 127 for a program 22775ebec6dSmrg# not found, 63 for a program that failed due to version mismatch). 22875ebec6dSmrgexit $st 22973143b9aSmrg 23073143b9aSmrg# Local variables: 231e45ace2bSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 23273143b9aSmrg# time-stamp-start: "scriptversion=" 23373143b9aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 234e45ace2bSmrg# time-stamp-time-zone: "UTC0" 235b53e5eeaSmrg# time-stamp-end: "; # UTC" 23673143b9aSmrg# End: 237