127702724Smrg#! /bin/sh 2ae545d91Smrg# Common wrapper for a few potentially missing GNU and other programs. 327702724Smrg 4ae545d91Smrgscriptversion=2024-06-07.14; # UTC 527702724Smrg 6ae545d91Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 7ae545d91Smrg 8ae545d91Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 9313a12fdSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 1027702724Smrg 1127702724Smrg# This program is free software; you can redistribute it and/or modify 1227702724Smrg# it under the terms of the GNU General Public License as published by 1327702724Smrg# the Free Software Foundation; either version 2, or (at your option) 1427702724Smrg# any later version. 1527702724Smrg 1627702724Smrg# This program is distributed in the hope that it will be useful, 1727702724Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1827702724Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1927702724Smrg# GNU General Public License for more details. 2027702724Smrg 2127702724Smrg# You should have received a copy of the GNU General Public License 2295b7a5c8Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2327702724Smrg 2427702724Smrg# As a special exception to the GNU General Public License, if you 2527702724Smrg# distribute this file as part of a program that contains a 2627702724Smrg# configuration script generated by Autoconf, you may include it under 2727702724Smrg# the same distribution terms that you use for the rest of that program. 2827702724Smrg 2927702724Smrgif test $# -eq 0; then 30313a12fdSmrg echo 1>&2 "Try '$0 --help' for more information" 3127702724Smrg exit 1 3227702724Smrgfi 3327702724Smrg 34313a12fdSmrgcase $1 in 3527702724Smrg 36313a12fdSmrg --is-lightweight) 37313a12fdSmrg # Used by our autoconf macros to check whether the available missing 38313a12fdSmrg # script is modern enough. 39313a12fdSmrg exit 0 40313a12fdSmrg ;; 4127702724Smrg 42313a12fdSmrg --run) 43313a12fdSmrg # Back-compat with the calling convention used by older automake. 44313a12fdSmrg shift 45313a12fdSmrg ;; 4627702724Smrg 4727702724Smrg -h|--h|--he|--hel|--help) 4827702724Smrg echo "\ 4927702724Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 5027702724Smrg 51313a12fdSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 52313a12fdSmrgto PROGRAM being missing or too old. 5327702724Smrg 5427702724SmrgOptions: 5527702724Smrg -h, --help display this help and exit 5627702724Smrg -v, --version output version information and exit 5727702724Smrg 5827702724SmrgSupported PROGRAM values: 59ae545d91Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 60ae545d91Smrgbison flex help2man lex makeinfo perl yacc 6127702724Smrg 62313a12fdSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 63313a12fdSmrg'g' are ignored when checking the name. 6400084f2cSmrg 65ae545d91SmrgReport bugs to <bug-automake@gnu.org>. 66ae545d91SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 67ae545d91SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 6827702724Smrg exit $? 6927702724Smrg ;; 7027702724Smrg 7127702724Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 72ae545d91Smrg echo "missing (GNU Automake) $scriptversion" 7327702724Smrg exit $? 7427702724Smrg ;; 7527702724Smrg 7627702724Smrg -*) 77313a12fdSmrg echo 1>&2 "$0: unknown '$1' option" 78313a12fdSmrg echo 1>&2 "Try '$0 --help' for more information" 7927702724Smrg exit 1 8027702724Smrg ;; 8127702724Smrg 8227702724Smrgesac 8327702724Smrg 84313a12fdSmrg# Run the given program, remember its exit status. 85313a12fdSmrg"$@"; st=$? 86313a12fdSmrg 87313a12fdSmrg# If it succeeded, we are done. 88313a12fdSmrgtest $st -eq 0 && exit 0 89313a12fdSmrg 90313a12fdSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 91313a12fdSmrg# passed; such an option is passed most likely to detect whether the 92313a12fdSmrg# program is present and works. 93313a12fdSmrgcase $2 in --version|--help) exit $st;; esac 94313a12fdSmrg 95313a12fdSmrg# Exit code 63 means version mismatch. This often happens when the user 96313a12fdSmrg# tries to use an ancient version of a tool on a file that requires a 97313a12fdSmrg# minimum version. 98313a12fdSmrgif test $st -eq 63; then 99313a12fdSmrg msg="probably too old" 100313a12fdSmrgelif test $st -eq 127; then 101313a12fdSmrg # Program was missing. 102313a12fdSmrg msg="missing on your system" 103313a12fdSmrgelse 104313a12fdSmrg # Program was found and executed, but failed. Give up. 105313a12fdSmrg exit $st 106313a12fdSmrgfi 10727702724Smrg 10895b7a5c8Smrgperl_URL=https://www.perl.org/ 10995b7a5c8Smrgflex_URL=https://github.com/westes/flex 11095b7a5c8Smrggnu_software_URL=https://www.gnu.org/software 111313a12fdSmrg 112313a12fdSmrgprogram_details () 113313a12fdSmrg{ 114313a12fdSmrg case $1 in 115ae545d91Smrg aclocal|automake|autoreconf) 116313a12fdSmrg echo "The '$1' program is part of the GNU Automake package:" 117313a12fdSmrg echo "<$gnu_software_URL/automake>" 118313a12fdSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 119313a12fdSmrg echo "<$gnu_software_URL/autoconf>" 120313a12fdSmrg echo "<$gnu_software_URL/m4/>" 121313a12fdSmrg echo "<$perl_URL>" 122313a12fdSmrg ;; 123313a12fdSmrg autoconf|autom4te|autoheader) 124313a12fdSmrg echo "The '$1' program is part of the GNU Autoconf package:" 125313a12fdSmrg echo "<$gnu_software_URL/autoconf/>" 126313a12fdSmrg echo "It also requires GNU m4 and Perl in order to run:" 127313a12fdSmrg echo "<$gnu_software_URL/m4/>" 128313a12fdSmrg echo "<$perl_URL>" 129313a12fdSmrg ;; 130ae545d91Smrg *) 131ae545d91Smrg : 132ae545d91Smrg ;; 133313a12fdSmrg esac 134313a12fdSmrg} 135313a12fdSmrg 136313a12fdSmrggive_advice () 137313a12fdSmrg{ 138313a12fdSmrg # Normalize program name to check for. 139313a12fdSmrg normalized_program=`echo "$1" | sed ' 140313a12fdSmrg s/^gnu-//; t 141313a12fdSmrg s/^gnu//; t 142313a12fdSmrg s/^g//; t'` 143313a12fdSmrg 144313a12fdSmrg printf '%s\n' "'$1' is $msg." 145313a12fdSmrg 146313a12fdSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 147ae545d91Smrg autoheader_deps="'acconfig.h'" 148ae545d91Smrg automake_deps="'Makefile.am'" 149ae545d91Smrg aclocal_deps="'acinclude.m4'" 150313a12fdSmrg case $normalized_program in 151ae545d91Smrg aclocal*) 152ae545d91Smrg echo "You should only need it if you modified $aclocal_deps or" 153ae545d91Smrg echo "$configure_deps." 154ae545d91Smrg ;; 155313a12fdSmrg autoconf*) 156ae545d91Smrg echo "You should only need it if you modified $configure_deps." 157ae545d91Smrg ;; 158ae545d91Smrg autogen*) 159ae545d91Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 160ae545d91Smrg echo "You may want to install the GNU AutoGen package:" 161ae545d91Smrg echo "<$gnu_software_URL/autogen/>" 162313a12fdSmrg ;; 163313a12fdSmrg autoheader*) 164ae545d91Smrg echo "You should only need it if you modified $autoheader_deps or" 165313a12fdSmrg echo "$configure_deps." 166313a12fdSmrg ;; 167313a12fdSmrg automake*) 168ae545d91Smrg echo "You should only need it if you modified $automake_deps or" 169313a12fdSmrg echo "$configure_deps." 170313a12fdSmrg ;; 171ae545d91Smrg autom4te*) 172313a12fdSmrg echo "You might have modified some maintainer files that require" 1737cea3689Smrg echo "the 'autom4te' program to be rebuilt." 174ae545d91Smrg ;; 175ae545d91Smrg autoreconf*) 176ae545d91Smrg echo "You should only need it if you modified $aclocal_deps or" 177ae545d91Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 178ae545d91Smrg echo "$configure_deps." 179313a12fdSmrg ;; 180313a12fdSmrg bison*|yacc*) 181313a12fdSmrg echo "You should only need it if you modified a '.y' file." 182313a12fdSmrg echo "You may want to install the GNU Bison package:" 183313a12fdSmrg echo "<$gnu_software_URL/bison/>" 184313a12fdSmrg ;; 185313a12fdSmrg help2man*) 186313a12fdSmrg echo "You should only need it if you modified a dependency" \ 187313a12fdSmrg "of a man page." 188313a12fdSmrg echo "You may want to install the GNU Help2man package:" 189313a12fdSmrg echo "<$gnu_software_URL/help2man/>" 190313a12fdSmrg ;; 191ae545d91Smrg lex*|flex*) 192ae545d91Smrg echo "You should only need it if you modified a '.l' file." 193ae545d91Smrg echo "You may want to install the Fast Lexical Analyzer package:" 194ae545d91Smrg echo "<$flex_URL>" 195ae545d91Smrg ;; 196313a12fdSmrg makeinfo*) 197313a12fdSmrg echo "You should only need it if you modified a '.texi' file, or" 198313a12fdSmrg echo "any other file indirectly affecting the aspect of the manual." 199313a12fdSmrg echo "You might want to install the Texinfo package:" 200313a12fdSmrg echo "<$gnu_software_URL/texinfo/>" 201313a12fdSmrg echo "The spurious makeinfo call might also be the consequence of" 202313a12fdSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 203313a12fdSmrg echo "want to install GNU make:" 204313a12fdSmrg echo "<$gnu_software_URL/make/>" 205313a12fdSmrg ;; 206ae545d91Smrg perl*) 207ae545d91Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 208ae545d91Smrg echo " assorted other tools, or if you modified a Perl source file." 209ae545d91Smrg echo "You may want to install the Perl 5 language interpreter:" 210ae545d91Smrg echo "<$perl_URL>" 211ae545d91Smrg ;; 212313a12fdSmrg *) 213313a12fdSmrg echo "You might have modified some files without having the proper" 214313a12fdSmrg echo "tools for further handling them. Check the 'README' file, it" 215313a12fdSmrg echo "often tells you about the needed prerequisites for installing" 216313a12fdSmrg echo "this package. You may also peek at any GNU archive site, in" 217313a12fdSmrg echo "case some other package contains this missing '$1' program." 218313a12fdSmrg ;; 219313a12fdSmrg esac 220ae545d91Smrg program_details "$normalized_program" 221313a12fdSmrg} 222313a12fdSmrg 223313a12fdSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 224313a12fdSmrg -e '2,$s/^/ /' >&2 225313a12fdSmrg 226313a12fdSmrg# Propagate the correct exit status (expected to be 127 for a program 227313a12fdSmrg# not found, 63 for a program that failed due to version mismatch). 228313a12fdSmrgexit $st 22927702724Smrg 23027702724Smrg# Local variables: 23195b7a5c8Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 23227702724Smrg# time-stamp-start: "scriptversion=" 23327702724Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 23495b7a5c8Smrg# time-stamp-time-zone: "UTC0" 23500084f2cSmrg# time-stamp-end: "; # UTC" 23627702724Smrg# End: 237