1d1333322Smrg#! /bin/sh 2742aa962Smrg# Common wrapper for a few potentially missing GNU and other programs. 3d1333322Smrg 4742aa962Smrgscriptversion=2024-06-07.14; # UTC 5d1333322Smrg 6742aa962Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 7742aa962Smrg 8742aa962Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 969ef5f27Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 10d1333322Smrg 11d1333322Smrg# This program is free software; you can redistribute it and/or modify 12d1333322Smrg# it under the terms of the GNU General Public License as published by 13d1333322Smrg# the Free Software Foundation; either version 2, or (at your option) 14d1333322Smrg# any later version. 15d1333322Smrg 16d1333322Smrg# This program is distributed in the hope that it will be useful, 17d1333322Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 18d1333322Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19d1333322Smrg# GNU General Public License for more details. 20d1333322Smrg 21d1333322Smrg# You should have received a copy of the GNU General Public License 22d04472e1Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 23d1333322Smrg 24d1333322Smrg# As a special exception to the GNU General Public License, if you 25d1333322Smrg# distribute this file as part of a program that contains a 26d1333322Smrg# configuration script generated by Autoconf, you may include it under 27d1333322Smrg# the same distribution terms that you use for the rest of that program. 28d1333322Smrg 29d1333322Smrgif test $# -eq 0; then 3069ef5f27Smrg echo 1>&2 "Try '$0 --help' for more information" 31d1333322Smrg exit 1 32d1333322Smrgfi 33d1333322Smrg 3469ef5f27Smrgcase $1 in 35d1333322Smrg 3669ef5f27Smrg --is-lightweight) 3769ef5f27Smrg # Used by our autoconf macros to check whether the available missing 3869ef5f27Smrg # script is modern enough. 3969ef5f27Smrg exit 0 4069ef5f27Smrg ;; 41d1333322Smrg 4269ef5f27Smrg --run) 4369ef5f27Smrg # Back-compat with the calling convention used by older automake. 4469ef5f27Smrg shift 4569ef5f27Smrg ;; 46d1333322Smrg 47d1333322Smrg -h|--h|--he|--hel|--help) 48d1333322Smrg echo "\ 49d1333322Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 50d1333322Smrg 5169ef5f27SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5269ef5f27Smrgto PROGRAM being missing or too old. 53d1333322Smrg 54d1333322SmrgOptions: 55d1333322Smrg -h, --help display this help and exit 56d1333322Smrg -v, --version output version information and exit 57d1333322Smrg 58d1333322SmrgSupported PROGRAM values: 59742aa962Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 60742aa962Smrgbison flex help2man lex makeinfo perl yacc 61d1333322Smrg 6269ef5f27SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6369ef5f27Smrg'g' are ignored when checking the name. 644f9ac78aSmrg 65742aa962SmrgReport bugs to <bug-automake@gnu.org>. 66742aa962SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 67742aa962SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 68d1333322Smrg exit $? 69d1333322Smrg ;; 70d1333322Smrg 71d1333322Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 72742aa962Smrg echo "missing (GNU Automake) $scriptversion" 73d1333322Smrg exit $? 74d1333322Smrg ;; 75d1333322Smrg 76d1333322Smrg -*) 7769ef5f27Smrg echo 1>&2 "$0: unknown '$1' option" 7869ef5f27Smrg echo 1>&2 "Try '$0 --help' for more information" 79d1333322Smrg exit 1 80d1333322Smrg ;; 81d1333322Smrg 82d1333322Smrgesac 83d1333322Smrg 8469ef5f27Smrg# Run the given program, remember its exit status. 8569ef5f27Smrg"$@"; st=$? 8669ef5f27Smrg 8769ef5f27Smrg# If it succeeded, we are done. 8869ef5f27Smrgtest $st -eq 0 && exit 0 8969ef5f27Smrg 9069ef5f27Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 9169ef5f27Smrg# passed; such an option is passed most likely to detect whether the 9269ef5f27Smrg# program is present and works. 9369ef5f27Smrgcase $2 in --version|--help) exit $st;; esac 9469ef5f27Smrg 9569ef5f27Smrg# Exit code 63 means version mismatch. This often happens when the user 9669ef5f27Smrg# tries to use an ancient version of a tool on a file that requires a 9769ef5f27Smrg# minimum version. 9869ef5f27Smrgif test $st -eq 63; then 9969ef5f27Smrg msg="probably too old" 10069ef5f27Smrgelif test $st -eq 127; then 10169ef5f27Smrg # Program was missing. 10269ef5f27Smrg msg="missing on your system" 10369ef5f27Smrgelse 10469ef5f27Smrg # Program was found and executed, but failed. Give up. 10569ef5f27Smrg exit $st 10669ef5f27Smrgfi 107d1333322Smrg 108d04472e1Smrgperl_URL=https://www.perl.org/ 109d04472e1Smrgflex_URL=https://github.com/westes/flex 110d04472e1Smrggnu_software_URL=https://www.gnu.org/software 11169ef5f27Smrg 11269ef5f27Smrgprogram_details () 11369ef5f27Smrg{ 11469ef5f27Smrg case $1 in 115742aa962Smrg aclocal|automake|autoreconf) 11669ef5f27Smrg echo "The '$1' program is part of the GNU Automake package:" 11769ef5f27Smrg echo "<$gnu_software_URL/automake>" 11869ef5f27Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11969ef5f27Smrg echo "<$gnu_software_URL/autoconf>" 12069ef5f27Smrg echo "<$gnu_software_URL/m4/>" 12169ef5f27Smrg echo "<$perl_URL>" 12269ef5f27Smrg ;; 12369ef5f27Smrg autoconf|autom4te|autoheader) 12469ef5f27Smrg echo "The '$1' program is part of the GNU Autoconf package:" 12569ef5f27Smrg echo "<$gnu_software_URL/autoconf/>" 12669ef5f27Smrg echo "It also requires GNU m4 and Perl in order to run:" 12769ef5f27Smrg echo "<$gnu_software_URL/m4/>" 12869ef5f27Smrg echo "<$perl_URL>" 12969ef5f27Smrg ;; 130742aa962Smrg *) 131742aa962Smrg : 132742aa962Smrg ;; 13369ef5f27Smrg esac 13469ef5f27Smrg} 13569ef5f27Smrg 13669ef5f27Smrggive_advice () 13769ef5f27Smrg{ 13869ef5f27Smrg # Normalize program name to check for. 13969ef5f27Smrg normalized_program=`echo "$1" | sed ' 14069ef5f27Smrg s/^gnu-//; t 14169ef5f27Smrg s/^gnu//; t 14269ef5f27Smrg s/^g//; t'` 14369ef5f27Smrg 14469ef5f27Smrg printf '%s\n' "'$1' is $msg." 14569ef5f27Smrg 14669ef5f27Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 147742aa962Smrg autoheader_deps="'acconfig.h'" 148742aa962Smrg automake_deps="'Makefile.am'" 149742aa962Smrg aclocal_deps="'acinclude.m4'" 15069ef5f27Smrg case $normalized_program in 151742aa962Smrg aclocal*) 152742aa962Smrg echo "You should only need it if you modified $aclocal_deps or" 153742aa962Smrg echo "$configure_deps." 154742aa962Smrg ;; 15569ef5f27Smrg autoconf*) 156742aa962Smrg echo "You should only need it if you modified $configure_deps." 157742aa962Smrg ;; 158742aa962Smrg autogen*) 159742aa962Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 160742aa962Smrg echo "You may want to install the GNU AutoGen package:" 161742aa962Smrg echo "<$gnu_software_URL/autogen/>" 16269ef5f27Smrg ;; 16369ef5f27Smrg autoheader*) 164742aa962Smrg echo "You should only need it if you modified $autoheader_deps or" 16569ef5f27Smrg echo "$configure_deps." 16669ef5f27Smrg ;; 16769ef5f27Smrg automake*) 168742aa962Smrg echo "You should only need it if you modified $automake_deps or" 16969ef5f27Smrg echo "$configure_deps." 17069ef5f27Smrg ;; 171742aa962Smrg autom4te*) 17269ef5f27Smrg echo "You might have modified some maintainer files that require" 17369ef5f27Smrg echo "the 'autom4te' program to be rebuilt." 174742aa962Smrg ;; 175742aa962Smrg autoreconf*) 176742aa962Smrg echo "You should only need it if you modified $aclocal_deps or" 177742aa962Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 178742aa962Smrg echo "$configure_deps." 17969ef5f27Smrg ;; 18069ef5f27Smrg bison*|yacc*) 18169ef5f27Smrg echo "You should only need it if you modified a '.y' file." 18269ef5f27Smrg echo "You may want to install the GNU Bison package:" 18369ef5f27Smrg echo "<$gnu_software_URL/bison/>" 18469ef5f27Smrg ;; 18569ef5f27Smrg help2man*) 18669ef5f27Smrg echo "You should only need it if you modified a dependency" \ 18769ef5f27Smrg "of a man page." 18869ef5f27Smrg echo "You may want to install the GNU Help2man package:" 18969ef5f27Smrg echo "<$gnu_software_URL/help2man/>" 19069ef5f27Smrg ;; 191742aa962Smrg lex*|flex*) 192742aa962Smrg echo "You should only need it if you modified a '.l' file." 193742aa962Smrg echo "You may want to install the Fast Lexical Analyzer package:" 194742aa962Smrg echo "<$flex_URL>" 195742aa962Smrg ;; 19669ef5f27Smrg makeinfo*) 19769ef5f27Smrg echo "You should only need it if you modified a '.texi' file, or" 19869ef5f27Smrg echo "any other file indirectly affecting the aspect of the manual." 19969ef5f27Smrg echo "You might want to install the Texinfo package:" 20069ef5f27Smrg echo "<$gnu_software_URL/texinfo/>" 20169ef5f27Smrg echo "The spurious makeinfo call might also be the consequence of" 20269ef5f27Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 20369ef5f27Smrg echo "want to install GNU make:" 20469ef5f27Smrg echo "<$gnu_software_URL/make/>" 20569ef5f27Smrg ;; 206742aa962Smrg perl*) 207742aa962Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 208742aa962Smrg echo " assorted other tools, or if you modified a Perl source file." 209742aa962Smrg echo "You may want to install the Perl 5 language interpreter:" 210742aa962Smrg echo "<$perl_URL>" 211742aa962Smrg ;; 21269ef5f27Smrg *) 21369ef5f27Smrg echo "You might have modified some files without having the proper" 21469ef5f27Smrg echo "tools for further handling them. Check the 'README' file, it" 21569ef5f27Smrg echo "often tells you about the needed prerequisites for installing" 21669ef5f27Smrg echo "this package. You may also peek at any GNU archive site, in" 21769ef5f27Smrg echo "case some other package contains this missing '$1' program." 21869ef5f27Smrg ;; 21969ef5f27Smrg esac 220742aa962Smrg program_details "$normalized_program" 22169ef5f27Smrg} 22269ef5f27Smrg 22369ef5f27Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 22469ef5f27Smrg -e '2,$s/^/ /' >&2 22569ef5f27Smrg 22669ef5f27Smrg# Propagate the correct exit status (expected to be 127 for a program 22769ef5f27Smrg# not found, 63 for a program that failed due to version mismatch). 22869ef5f27Smrgexit $st 229d1333322Smrg 230d1333322Smrg# Local variables: 231d04472e1Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 232d1333322Smrg# time-stamp-start: "scriptversion=" 233d1333322Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 234d04472e1Smrg# time-stamp-time-zone: "UTC0" 2354f9ac78aSmrg# time-stamp-end: "; # UTC" 236d1333322Smrg# End: 237