1ba6a1819Smrg#! /bin/sh 200ca1914Smrg# Common wrapper for a few potentially missing GNU and other programs. 3ba6a1819Smrg 400ca1914Smrgscriptversion=2024-06-07.14; # UTC 5ba6a1819Smrg 600ca1914Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 700ca1914Smrg 800ca1914Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 91bedbe3fSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 10ba6a1819Smrg 11ba6a1819Smrg# This program is free software; you can redistribute it and/or modify 12ba6a1819Smrg# it under the terms of the GNU General Public License as published by 13ba6a1819Smrg# the Free Software Foundation; either version 2, or (at your option) 14ba6a1819Smrg# any later version. 15ba6a1819Smrg 16ba6a1819Smrg# This program is distributed in the hope that it will be useful, 17ba6a1819Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 18ba6a1819Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19ba6a1819Smrg# GNU General Public License for more details. 20ba6a1819Smrg 21ba6a1819Smrg# You should have received a copy of the GNU General Public License 22da1f2d5dSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 23ba6a1819Smrg 24ba6a1819Smrg# As a special exception to the GNU General Public License, if you 25ba6a1819Smrg# distribute this file as part of a program that contains a 26ba6a1819Smrg# configuration script generated by Autoconf, you may include it under 27ba6a1819Smrg# the same distribution terms that you use for the rest of that program. 28ba6a1819Smrg 29ba6a1819Smrgif test $# -eq 0; then 301bedbe3fSmrg echo 1>&2 "Try '$0 --help' for more information" 31ba6a1819Smrg exit 1 32ba6a1819Smrgfi 33ba6a1819Smrg 341bedbe3fSmrgcase $1 in 35ba6a1819Smrg 361bedbe3fSmrg --is-lightweight) 371bedbe3fSmrg # Used by our autoconf macros to check whether the available missing 381bedbe3fSmrg # script is modern enough. 391bedbe3fSmrg exit 0 401bedbe3fSmrg ;; 41ba6a1819Smrg 421bedbe3fSmrg --run) 431bedbe3fSmrg # Back-compat with the calling convention used by older automake. 441bedbe3fSmrg shift 451bedbe3fSmrg ;; 46ba6a1819Smrg 47ba6a1819Smrg -h|--h|--he|--hel|--help) 48ba6a1819Smrg echo "\ 49ba6a1819Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 50ba6a1819Smrg 511bedbe3fSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 521bedbe3fSmrgto PROGRAM being missing or too old. 53ba6a1819Smrg 54ba6a1819SmrgOptions: 55ba6a1819Smrg -h, --help display this help and exit 56ba6a1819Smrg -v, --version output version information and exit 57ba6a1819Smrg 58ba6a1819SmrgSupported PROGRAM values: 5900ca1914Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 6000ca1914Smrgbison flex help2man lex makeinfo perl yacc 61ba6a1819Smrg 621bedbe3fSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 631bedbe3fSmrg'g' are ignored when checking the name. 64549e21daSmrg 6500ca1914SmrgReport bugs to <bug-automake@gnu.org>. 6600ca1914SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 6700ca1914SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 68ba6a1819Smrg exit $? 69ba6a1819Smrg ;; 70ba6a1819Smrg 71ba6a1819Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 7200ca1914Smrg echo "missing (GNU Automake) $scriptversion" 73ba6a1819Smrg exit $? 74ba6a1819Smrg ;; 75ba6a1819Smrg 76ba6a1819Smrg -*) 771bedbe3fSmrg echo 1>&2 "$0: unknown '$1' option" 781bedbe3fSmrg echo 1>&2 "Try '$0 --help' for more information" 79ba6a1819Smrg exit 1 80ba6a1819Smrg ;; 81ba6a1819Smrg 82ba6a1819Smrgesac 83ba6a1819Smrg 841bedbe3fSmrg# Run the given program, remember its exit status. 851bedbe3fSmrg"$@"; st=$? 861bedbe3fSmrg 871bedbe3fSmrg# If it succeeded, we are done. 881bedbe3fSmrgtest $st -eq 0 && exit 0 891bedbe3fSmrg 901bedbe3fSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 911bedbe3fSmrg# passed; such an option is passed most likely to detect whether the 921bedbe3fSmrg# program is present and works. 931bedbe3fSmrgcase $2 in --version|--help) exit $st;; esac 941bedbe3fSmrg 951bedbe3fSmrg# Exit code 63 means version mismatch. This often happens when the user 961bedbe3fSmrg# tries to use an ancient version of a tool on a file that requires a 971bedbe3fSmrg# minimum version. 981bedbe3fSmrgif test $st -eq 63; then 991bedbe3fSmrg msg="probably too old" 1001bedbe3fSmrgelif test $st -eq 127; then 1011bedbe3fSmrg # Program was missing. 1021bedbe3fSmrg msg="missing on your system" 1031bedbe3fSmrgelse 1041bedbe3fSmrg # Program was found and executed, but failed. Give up. 1051bedbe3fSmrg exit $st 1061bedbe3fSmrgfi 107ba6a1819Smrg 108da1f2d5dSmrgperl_URL=https://www.perl.org/ 109da1f2d5dSmrgflex_URL=https://github.com/westes/flex 110da1f2d5dSmrggnu_software_URL=https://www.gnu.org/software 1111bedbe3fSmrg 1121bedbe3fSmrgprogram_details () 1131bedbe3fSmrg{ 1141bedbe3fSmrg case $1 in 11500ca1914Smrg aclocal|automake|autoreconf) 1161bedbe3fSmrg echo "The '$1' program is part of the GNU Automake package:" 1171bedbe3fSmrg echo "<$gnu_software_URL/automake>" 1181bedbe3fSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1191bedbe3fSmrg echo "<$gnu_software_URL/autoconf>" 1201bedbe3fSmrg echo "<$gnu_software_URL/m4/>" 1211bedbe3fSmrg echo "<$perl_URL>" 1221bedbe3fSmrg ;; 1231bedbe3fSmrg autoconf|autom4te|autoheader) 1241bedbe3fSmrg echo "The '$1' program is part of the GNU Autoconf package:" 1251bedbe3fSmrg echo "<$gnu_software_URL/autoconf/>" 1261bedbe3fSmrg echo "It also requires GNU m4 and Perl in order to run:" 1271bedbe3fSmrg echo "<$gnu_software_URL/m4/>" 1281bedbe3fSmrg echo "<$perl_URL>" 1291bedbe3fSmrg ;; 13000ca1914Smrg *) 13100ca1914Smrg : 13200ca1914Smrg ;; 1331bedbe3fSmrg esac 1341bedbe3fSmrg} 1351bedbe3fSmrg 1361bedbe3fSmrggive_advice () 1371bedbe3fSmrg{ 1381bedbe3fSmrg # Normalize program name to check for. 1391bedbe3fSmrg normalized_program=`echo "$1" | sed ' 1401bedbe3fSmrg s/^gnu-//; t 1411bedbe3fSmrg s/^gnu//; t 1421bedbe3fSmrg s/^g//; t'` 1431bedbe3fSmrg 1441bedbe3fSmrg printf '%s\n' "'$1' is $msg." 1451bedbe3fSmrg 1461bedbe3fSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14700ca1914Smrg autoheader_deps="'acconfig.h'" 14800ca1914Smrg automake_deps="'Makefile.am'" 14900ca1914Smrg aclocal_deps="'acinclude.m4'" 1501bedbe3fSmrg case $normalized_program in 15100ca1914Smrg aclocal*) 15200ca1914Smrg echo "You should only need it if you modified $aclocal_deps or" 15300ca1914Smrg echo "$configure_deps." 15400ca1914Smrg ;; 1551bedbe3fSmrg autoconf*) 15600ca1914Smrg echo "You should only need it if you modified $configure_deps." 15700ca1914Smrg ;; 15800ca1914Smrg autogen*) 15900ca1914Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 16000ca1914Smrg echo "You may want to install the GNU AutoGen package:" 16100ca1914Smrg echo "<$gnu_software_URL/autogen/>" 1621bedbe3fSmrg ;; 1631bedbe3fSmrg autoheader*) 16400ca1914Smrg echo "You should only need it if you modified $autoheader_deps or" 1651bedbe3fSmrg echo "$configure_deps." 1661bedbe3fSmrg ;; 1671bedbe3fSmrg automake*) 16800ca1914Smrg echo "You should only need it if you modified $automake_deps or" 1691bedbe3fSmrg echo "$configure_deps." 1701bedbe3fSmrg ;; 17100ca1914Smrg autom4te*) 1721bedbe3fSmrg echo "You might have modified some maintainer files that require" 173298453a4Smrg echo "the 'autom4te' program to be rebuilt." 17400ca1914Smrg ;; 17500ca1914Smrg autoreconf*) 17600ca1914Smrg echo "You should only need it if you modified $aclocal_deps or" 17700ca1914Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 17800ca1914Smrg echo "$configure_deps." 1791bedbe3fSmrg ;; 1801bedbe3fSmrg bison*|yacc*) 1811bedbe3fSmrg echo "You should only need it if you modified a '.y' file." 1821bedbe3fSmrg echo "You may want to install the GNU Bison package:" 1831bedbe3fSmrg echo "<$gnu_software_URL/bison/>" 1841bedbe3fSmrg ;; 1851bedbe3fSmrg help2man*) 1861bedbe3fSmrg echo "You should only need it if you modified a dependency" \ 1871bedbe3fSmrg "of a man page." 1881bedbe3fSmrg echo "You may want to install the GNU Help2man package:" 1891bedbe3fSmrg echo "<$gnu_software_URL/help2man/>" 1901bedbe3fSmrg ;; 19100ca1914Smrg lex*|flex*) 19200ca1914Smrg echo "You should only need it if you modified a '.l' file." 19300ca1914Smrg echo "You may want to install the Fast Lexical Analyzer package:" 19400ca1914Smrg echo "<$flex_URL>" 19500ca1914Smrg ;; 1961bedbe3fSmrg makeinfo*) 1971bedbe3fSmrg echo "You should only need it if you modified a '.texi' file, or" 1981bedbe3fSmrg echo "any other file indirectly affecting the aspect of the manual." 1991bedbe3fSmrg echo "You might want to install the Texinfo package:" 2001bedbe3fSmrg echo "<$gnu_software_URL/texinfo/>" 2011bedbe3fSmrg echo "The spurious makeinfo call might also be the consequence of" 2021bedbe3fSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 2031bedbe3fSmrg echo "want to install GNU make:" 2041bedbe3fSmrg echo "<$gnu_software_URL/make/>" 2051bedbe3fSmrg ;; 20600ca1914Smrg perl*) 20700ca1914Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 20800ca1914Smrg echo " assorted other tools, or if you modified a Perl source file." 20900ca1914Smrg echo "You may want to install the Perl 5 language interpreter:" 21000ca1914Smrg echo "<$perl_URL>" 21100ca1914Smrg ;; 2121bedbe3fSmrg *) 2131bedbe3fSmrg echo "You might have modified some files without having the proper" 2141bedbe3fSmrg echo "tools for further handling them. Check the 'README' file, it" 2151bedbe3fSmrg echo "often tells you about the needed prerequisites for installing" 2161bedbe3fSmrg echo "this package. You may also peek at any GNU archive site, in" 2171bedbe3fSmrg echo "case some other package contains this missing '$1' program." 2181bedbe3fSmrg ;; 2191bedbe3fSmrg esac 22000ca1914Smrg program_details "$normalized_program" 2211bedbe3fSmrg} 2221bedbe3fSmrg 2231bedbe3fSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2241bedbe3fSmrg -e '2,$s/^/ /' >&2 2251bedbe3fSmrg 2261bedbe3fSmrg# Propagate the correct exit status (expected to be 127 for a program 2271bedbe3fSmrg# not found, 63 for a program that failed due to version mismatch). 2281bedbe3fSmrgexit $st 229ba6a1819Smrg 230ba6a1819Smrg# Local variables: 231da1f2d5dSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 232ba6a1819Smrg# time-stamp-start: "scriptversion=" 233ba6a1819Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 234da1f2d5dSmrg# time-stamp-time-zone: "UTC0" 235549e21daSmrg# time-stamp-end: "; # UTC" 236ba6a1819Smrg# End: 237