1266e564dSmrg#! /bin/sh 23bf3b463Smrg# Common wrapper for a few potentially missing GNU and other programs. 3266e564dSmrg 43bf3b463Smrgscriptversion=2024-06-07.14; # UTC 5266e564dSmrg 63bf3b463Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 73bf3b463Smrg 83bf3b463Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 9fb5e8d76Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 10266e564dSmrg 11266e564dSmrg# This program is free software; you can redistribute it and/or modify 12266e564dSmrg# it under the terms of the GNU General Public License as published by 13266e564dSmrg# the Free Software Foundation; either version 2, or (at your option) 14266e564dSmrg# any later version. 15266e564dSmrg 16266e564dSmrg# This program is distributed in the hope that it will be useful, 17266e564dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 18266e564dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19266e564dSmrg# GNU General Public License for more details. 20266e564dSmrg 21266e564dSmrg# You should have received a copy of the GNU General Public License 221009a292Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 23266e564dSmrg 24266e564dSmrg# As a special exception to the GNU General Public License, if you 25266e564dSmrg# distribute this file as part of a program that contains a 26266e564dSmrg# configuration script generated by Autoconf, you may include it under 27266e564dSmrg# the same distribution terms that you use for the rest of that program. 28266e564dSmrg 29266e564dSmrgif test $# -eq 0; then 30fb5e8d76Smrg echo 1>&2 "Try '$0 --help' for more information" 31266e564dSmrg exit 1 32266e564dSmrgfi 33266e564dSmrg 34fb5e8d76Smrgcase $1 in 35266e564dSmrg 36fb5e8d76Smrg --is-lightweight) 37fb5e8d76Smrg # Used by our autoconf macros to check whether the available missing 38fb5e8d76Smrg # script is modern enough. 39fb5e8d76Smrg exit 0 40fb5e8d76Smrg ;; 41266e564dSmrg 42fb5e8d76Smrg --run) 43fb5e8d76Smrg # Back-compat with the calling convention used by older automake. 44fb5e8d76Smrg shift 45fb5e8d76Smrg ;; 46266e564dSmrg 47266e564dSmrg -h|--h|--he|--hel|--help) 48266e564dSmrg echo "\ 49266e564dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 50266e564dSmrg 51fb5e8d76SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 52fb5e8d76Smrgto PROGRAM being missing or too old. 53266e564dSmrg 54266e564dSmrgOptions: 55266e564dSmrg -h, --help display this help and exit 56266e564dSmrg -v, --version output version information and exit 57266e564dSmrg 58266e564dSmrgSupported PROGRAM values: 593bf3b463Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 603bf3b463Smrgbison flex help2man lex makeinfo perl yacc 61266e564dSmrg 62fb5e8d76SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 63fb5e8d76Smrg'g' are ignored when checking the name. 64d17cd367Smrg 653bf3b463SmrgReport bugs to <bug-automake@gnu.org>. 663bf3b463SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 673bf3b463SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 68266e564dSmrg exit $? 69266e564dSmrg ;; 70266e564dSmrg 71266e564dSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 723bf3b463Smrg echo "missing (GNU Automake) $scriptversion" 73266e564dSmrg exit $? 74266e564dSmrg ;; 75266e564dSmrg 76266e564dSmrg -*) 77fb5e8d76Smrg echo 1>&2 "$0: unknown '$1' option" 78fb5e8d76Smrg echo 1>&2 "Try '$0 --help' for more information" 79266e564dSmrg exit 1 80266e564dSmrg ;; 81266e564dSmrg 82266e564dSmrgesac 83266e564dSmrg 84fb5e8d76Smrg# Run the given program, remember its exit status. 85fb5e8d76Smrg"$@"; st=$? 86fb5e8d76Smrg 87fb5e8d76Smrg# If it succeeded, we are done. 88fb5e8d76Smrgtest $st -eq 0 && exit 0 89fb5e8d76Smrg 90fb5e8d76Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 91fb5e8d76Smrg# passed; such an option is passed most likely to detect whether the 92fb5e8d76Smrg# program is present and works. 93fb5e8d76Smrgcase $2 in --version|--help) exit $st;; esac 94fb5e8d76Smrg 95fb5e8d76Smrg# Exit code 63 means version mismatch. This often happens when the user 96fb5e8d76Smrg# tries to use an ancient version of a tool on a file that requires a 97fb5e8d76Smrg# minimum version. 98fb5e8d76Smrgif test $st -eq 63; then 99fb5e8d76Smrg msg="probably too old" 100fb5e8d76Smrgelif test $st -eq 127; then 101fb5e8d76Smrg # Program was missing. 102fb5e8d76Smrg msg="missing on your system" 103fb5e8d76Smrgelse 104fb5e8d76Smrg # Program was found and executed, but failed. Give up. 105fb5e8d76Smrg exit $st 106fb5e8d76Smrgfi 107266e564dSmrg 1081009a292Smrgperl_URL=https://www.perl.org/ 1091009a292Smrgflex_URL=https://github.com/westes/flex 1101009a292Smrggnu_software_URL=https://www.gnu.org/software 111fb5e8d76Smrg 112fb5e8d76Smrgprogram_details () 113fb5e8d76Smrg{ 114fb5e8d76Smrg case $1 in 1153bf3b463Smrg aclocal|automake|autoreconf) 116fb5e8d76Smrg echo "The '$1' program is part of the GNU Automake package:" 117fb5e8d76Smrg echo "<$gnu_software_URL/automake>" 118fb5e8d76Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 119fb5e8d76Smrg echo "<$gnu_software_URL/autoconf>" 120fb5e8d76Smrg echo "<$gnu_software_URL/m4/>" 121fb5e8d76Smrg echo "<$perl_URL>" 122fb5e8d76Smrg ;; 123fb5e8d76Smrg autoconf|autom4te|autoheader) 124fb5e8d76Smrg echo "The '$1' program is part of the GNU Autoconf package:" 125fb5e8d76Smrg echo "<$gnu_software_URL/autoconf/>" 126fb5e8d76Smrg echo "It also requires GNU m4 and Perl in order to run:" 127fb5e8d76Smrg echo "<$gnu_software_URL/m4/>" 128fb5e8d76Smrg echo "<$perl_URL>" 129fb5e8d76Smrg ;; 1303bf3b463Smrg *) 1313bf3b463Smrg : 1323bf3b463Smrg ;; 133fb5e8d76Smrg esac 134fb5e8d76Smrg} 135fb5e8d76Smrg 136fb5e8d76Smrggive_advice () 137fb5e8d76Smrg{ 138fb5e8d76Smrg # Normalize program name to check for. 139fb5e8d76Smrg normalized_program=`echo "$1" | sed ' 140fb5e8d76Smrg s/^gnu-//; t 141fb5e8d76Smrg s/^gnu//; t 142fb5e8d76Smrg s/^g//; t'` 143fb5e8d76Smrg 144fb5e8d76Smrg printf '%s\n' "'$1' is $msg." 145fb5e8d76Smrg 146fb5e8d76Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1473bf3b463Smrg autoheader_deps="'acconfig.h'" 1483bf3b463Smrg automake_deps="'Makefile.am'" 1493bf3b463Smrg aclocal_deps="'acinclude.m4'" 150fb5e8d76Smrg case $normalized_program in 1513bf3b463Smrg aclocal*) 1523bf3b463Smrg echo "You should only need it if you modified $aclocal_deps or" 1533bf3b463Smrg echo "$configure_deps." 1543bf3b463Smrg ;; 155fb5e8d76Smrg autoconf*) 1563bf3b463Smrg echo "You should only need it if you modified $configure_deps." 1573bf3b463Smrg ;; 1583bf3b463Smrg autogen*) 1593bf3b463Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 1603bf3b463Smrg echo "You may want to install the GNU AutoGen package:" 1613bf3b463Smrg echo "<$gnu_software_URL/autogen/>" 162fb5e8d76Smrg ;; 163fb5e8d76Smrg autoheader*) 1643bf3b463Smrg echo "You should only need it if you modified $autoheader_deps or" 165fb5e8d76Smrg echo "$configure_deps." 166fb5e8d76Smrg ;; 167fb5e8d76Smrg automake*) 1683bf3b463Smrg echo "You should only need it if you modified $automake_deps or" 169fb5e8d76Smrg echo "$configure_deps." 170fb5e8d76Smrg ;; 1713bf3b463Smrg autom4te*) 172fb5e8d76Smrg echo "You might have modified some maintainer files that require" 173a3129944Smrg echo "the 'autom4te' program to be rebuilt." 1743bf3b463Smrg ;; 1753bf3b463Smrg autoreconf*) 1763bf3b463Smrg echo "You should only need it if you modified $aclocal_deps or" 1773bf3b463Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 1783bf3b463Smrg echo "$configure_deps." 179fb5e8d76Smrg ;; 180fb5e8d76Smrg bison*|yacc*) 181fb5e8d76Smrg echo "You should only need it if you modified a '.y' file." 182fb5e8d76Smrg echo "You may want to install the GNU Bison package:" 183fb5e8d76Smrg echo "<$gnu_software_URL/bison/>" 184fb5e8d76Smrg ;; 185fb5e8d76Smrg help2man*) 186fb5e8d76Smrg echo "You should only need it if you modified a dependency" \ 187fb5e8d76Smrg "of a man page." 188fb5e8d76Smrg echo "You may want to install the GNU Help2man package:" 189fb5e8d76Smrg echo "<$gnu_software_URL/help2man/>" 190fb5e8d76Smrg ;; 1913bf3b463Smrg lex*|flex*) 1923bf3b463Smrg echo "You should only need it if you modified a '.l' file." 1933bf3b463Smrg echo "You may want to install the Fast Lexical Analyzer package:" 1943bf3b463Smrg echo "<$flex_URL>" 1953bf3b463Smrg ;; 196fb5e8d76Smrg makeinfo*) 197fb5e8d76Smrg echo "You should only need it if you modified a '.texi' file, or" 198fb5e8d76Smrg echo "any other file indirectly affecting the aspect of the manual." 199fb5e8d76Smrg echo "You might want to install the Texinfo package:" 200fb5e8d76Smrg echo "<$gnu_software_URL/texinfo/>" 201fb5e8d76Smrg echo "The spurious makeinfo call might also be the consequence of" 202fb5e8d76Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 203fb5e8d76Smrg echo "want to install GNU make:" 204fb5e8d76Smrg echo "<$gnu_software_URL/make/>" 205fb5e8d76Smrg ;; 2063bf3b463Smrg perl*) 2073bf3b463Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 2083bf3b463Smrg echo " assorted other tools, or if you modified a Perl source file." 2093bf3b463Smrg echo "You may want to install the Perl 5 language interpreter:" 2103bf3b463Smrg echo "<$perl_URL>" 2113bf3b463Smrg ;; 212fb5e8d76Smrg *) 213fb5e8d76Smrg echo "You might have modified some files without having the proper" 214fb5e8d76Smrg echo "tools for further handling them. Check the 'README' file, it" 215fb5e8d76Smrg echo "often tells you about the needed prerequisites for installing" 216fb5e8d76Smrg echo "this package. You may also peek at any GNU archive site, in" 217fb5e8d76Smrg echo "case some other package contains this missing '$1' program." 218fb5e8d76Smrg ;; 219fb5e8d76Smrg esac 2203bf3b463Smrg program_details "$normalized_program" 221fb5e8d76Smrg} 222fb5e8d76Smrg 223fb5e8d76Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 224fb5e8d76Smrg -e '2,$s/^/ /' >&2 225fb5e8d76Smrg 226fb5e8d76Smrg# Propagate the correct exit status (expected to be 127 for a program 227fb5e8d76Smrg# not found, 63 for a program that failed due to version mismatch). 228fb5e8d76Smrgexit $st 229266e564dSmrg 230266e564dSmrg# Local variables: 2311009a292Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 232266e564dSmrg# time-stamp-start: "scriptversion=" 233266e564dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2341009a292Smrg# time-stamp-time-zone: "UTC0" 235d17cd367Smrg# time-stamp-end: "; # UTC" 236266e564dSmrg# End: 237