19f606849Smrg#! /bin/sh 2dc088bc7Smrg# Common wrapper for a few potentially missing GNU and other programs. 39f606849Smrg 4dc088bc7Smrgscriptversion=2024-06-07.14; # UTC 59f606849Smrg 6dc088bc7Smrg# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells 7dc088bc7Smrg 8dc088bc7Smrg# Copyright (C) 1996-2024 Free Software Foundation, Inc. 9cdbfa18aSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 109f606849Smrg 119f606849Smrg# This program is free software; you can redistribute it and/or modify 129f606849Smrg# it under the terms of the GNU General Public License as published by 139f606849Smrg# the Free Software Foundation; either version 2, or (at your option) 149f606849Smrg# any later version. 159f606849Smrg 169f606849Smrg# This program is distributed in the hope that it will be useful, 179f606849Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 189f606849Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 199f606849Smrg# GNU General Public License for more details. 209f606849Smrg 219f606849Smrg# You should have received a copy of the GNU General Public License 22949d0342Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 239f606849Smrg 249f606849Smrg# As a special exception to the GNU General Public License, if you 259f606849Smrg# distribute this file as part of a program that contains a 269f606849Smrg# configuration script generated by Autoconf, you may include it under 279f606849Smrg# the same distribution terms that you use for the rest of that program. 289f606849Smrg 299f606849Smrgif test $# -eq 0; then 30cdbfa18aSmrg echo 1>&2 "Try '$0 --help' for more information" 319f606849Smrg exit 1 329f606849Smrgfi 339f606849Smrg 34cdbfa18aSmrgcase $1 in 359f606849Smrg 36cdbfa18aSmrg --is-lightweight) 37cdbfa18aSmrg # Used by our autoconf macros to check whether the available missing 38cdbfa18aSmrg # script is modern enough. 39cdbfa18aSmrg exit 0 40cdbfa18aSmrg ;; 419f606849Smrg 42cdbfa18aSmrg --run) 43cdbfa18aSmrg # Back-compat with the calling convention used by older automake. 44cdbfa18aSmrg shift 45cdbfa18aSmrg ;; 469f606849Smrg 479f606849Smrg -h|--h|--he|--hel|--help) 489f606849Smrg echo "\ 499f606849Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 509f606849Smrg 51cdbfa18aSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 52cdbfa18aSmrgto PROGRAM being missing or too old. 539f606849Smrg 549f606849SmrgOptions: 559f606849Smrg -h, --help display this help and exit 569f606849Smrg -v, --version output version information and exit 579f606849Smrg 589f606849SmrgSupported PROGRAM values: 59dc088bc7Smrgaclocal autoconf autogen autoheader autom4te automake autoreconf 60dc088bc7Smrgbison flex help2man lex makeinfo perl yacc 619f606849Smrg 62cdbfa18aSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 63cdbfa18aSmrg'g' are ignored when checking the name. 64fba89afeSmrg 65dc088bc7SmrgReport bugs to <bug-automake@gnu.org>. 66dc088bc7SmrgGNU Automake home page: <https://www.gnu.org/software/automake/>. 67dc088bc7SmrgGeneral help using GNU software: <https://www.gnu.org/gethelp/>." 689f606849Smrg exit $? 699f606849Smrg ;; 709f606849Smrg 719f606849Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 72dc088bc7Smrg echo "missing (GNU Automake) $scriptversion" 739f606849Smrg exit $? 749f606849Smrg ;; 759f606849Smrg 769f606849Smrg -*) 77cdbfa18aSmrg echo 1>&2 "$0: unknown '$1' option" 78cdbfa18aSmrg echo 1>&2 "Try '$0 --help' for more information" 799f606849Smrg exit 1 809f606849Smrg ;; 819f606849Smrg 829f606849Smrgesac 839f606849Smrg 84cdbfa18aSmrg# Run the given program, remember its exit status. 85cdbfa18aSmrg"$@"; st=$? 86cdbfa18aSmrg 87cdbfa18aSmrg# If it succeeded, we are done. 88cdbfa18aSmrgtest $st -eq 0 && exit 0 89cdbfa18aSmrg 90cdbfa18aSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 91cdbfa18aSmrg# passed; such an option is passed most likely to detect whether the 92cdbfa18aSmrg# program is present and works. 93cdbfa18aSmrgcase $2 in --version|--help) exit $st;; esac 94cdbfa18aSmrg 95cdbfa18aSmrg# Exit code 63 means version mismatch. This often happens when the user 96cdbfa18aSmrg# tries to use an ancient version of a tool on a file that requires a 97cdbfa18aSmrg# minimum version. 98cdbfa18aSmrgif test $st -eq 63; then 99cdbfa18aSmrg msg="probably too old" 100cdbfa18aSmrgelif test $st -eq 127; then 101cdbfa18aSmrg # Program was missing. 102cdbfa18aSmrg msg="missing on your system" 103cdbfa18aSmrgelse 104cdbfa18aSmrg # Program was found and executed, but failed. Give up. 105cdbfa18aSmrg exit $st 106cdbfa18aSmrgfi 1079f606849Smrg 108949d0342Smrgperl_URL=https://www.perl.org/ 109949d0342Smrgflex_URL=https://github.com/westes/flex 110949d0342Smrggnu_software_URL=https://www.gnu.org/software 111cdbfa18aSmrg 112cdbfa18aSmrgprogram_details () 113cdbfa18aSmrg{ 114cdbfa18aSmrg case $1 in 115dc088bc7Smrg aclocal|automake|autoreconf) 116cdbfa18aSmrg echo "The '$1' program is part of the GNU Automake package:" 117cdbfa18aSmrg echo "<$gnu_software_URL/automake>" 118cdbfa18aSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 119cdbfa18aSmrg echo "<$gnu_software_URL/autoconf>" 120cdbfa18aSmrg echo "<$gnu_software_URL/m4/>" 121cdbfa18aSmrg echo "<$perl_URL>" 122cdbfa18aSmrg ;; 123cdbfa18aSmrg autoconf|autom4te|autoheader) 124cdbfa18aSmrg echo "The '$1' program is part of the GNU Autoconf package:" 125cdbfa18aSmrg echo "<$gnu_software_URL/autoconf/>" 126cdbfa18aSmrg echo "It also requires GNU m4 and Perl in order to run:" 127cdbfa18aSmrg echo "<$gnu_software_URL/m4/>" 128cdbfa18aSmrg echo "<$perl_URL>" 129cdbfa18aSmrg ;; 130dc088bc7Smrg *) 131dc088bc7Smrg : 132dc088bc7Smrg ;; 133cdbfa18aSmrg esac 134cdbfa18aSmrg} 135cdbfa18aSmrg 136cdbfa18aSmrggive_advice () 137cdbfa18aSmrg{ 138cdbfa18aSmrg # Normalize program name to check for. 139cdbfa18aSmrg normalized_program=`echo "$1" | sed ' 140cdbfa18aSmrg s/^gnu-//; t 141cdbfa18aSmrg s/^gnu//; t 142cdbfa18aSmrg s/^g//; t'` 143cdbfa18aSmrg 144cdbfa18aSmrg printf '%s\n' "'$1' is $msg." 145cdbfa18aSmrg 146cdbfa18aSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 147dc088bc7Smrg autoheader_deps="'acconfig.h'" 148dc088bc7Smrg automake_deps="'Makefile.am'" 149dc088bc7Smrg aclocal_deps="'acinclude.m4'" 150cdbfa18aSmrg case $normalized_program in 151dc088bc7Smrg aclocal*) 152dc088bc7Smrg echo "You should only need it if you modified $aclocal_deps or" 153dc088bc7Smrg echo "$configure_deps." 154dc088bc7Smrg ;; 155cdbfa18aSmrg autoconf*) 156dc088bc7Smrg echo "You should only need it if you modified $configure_deps." 157dc088bc7Smrg ;; 158dc088bc7Smrg autogen*) 159dc088bc7Smrg echo "You should only need it if you modified a '.def' or '.tpl' file." 160dc088bc7Smrg echo "You may want to install the GNU AutoGen package:" 161dc088bc7Smrg echo "<$gnu_software_URL/autogen/>" 162cdbfa18aSmrg ;; 163cdbfa18aSmrg autoheader*) 164dc088bc7Smrg echo "You should only need it if you modified $autoheader_deps or" 165cdbfa18aSmrg echo "$configure_deps." 166cdbfa18aSmrg ;; 167cdbfa18aSmrg automake*) 168dc088bc7Smrg echo "You should only need it if you modified $automake_deps or" 169cdbfa18aSmrg echo "$configure_deps." 170cdbfa18aSmrg ;; 171dc088bc7Smrg autom4te*) 172cdbfa18aSmrg echo "You might have modified some maintainer files that require" 173444fb138Smrg echo "the 'autom4te' program to be rebuilt." 174dc088bc7Smrg ;; 175dc088bc7Smrg autoreconf*) 176dc088bc7Smrg echo "You should only need it if you modified $aclocal_deps or" 177dc088bc7Smrg echo "$automake_deps or $autoheader_deps or $automake_deps or" 178dc088bc7Smrg echo "$configure_deps." 179cdbfa18aSmrg ;; 180cdbfa18aSmrg bison*|yacc*) 181cdbfa18aSmrg echo "You should only need it if you modified a '.y' file." 182cdbfa18aSmrg echo "You may want to install the GNU Bison package:" 183cdbfa18aSmrg echo "<$gnu_software_URL/bison/>" 184cdbfa18aSmrg ;; 185cdbfa18aSmrg help2man*) 186cdbfa18aSmrg echo "You should only need it if you modified a dependency" \ 187cdbfa18aSmrg "of a man page." 188cdbfa18aSmrg echo "You may want to install the GNU Help2man package:" 189cdbfa18aSmrg echo "<$gnu_software_URL/help2man/>" 190cdbfa18aSmrg ;; 191dc088bc7Smrg lex*|flex*) 192dc088bc7Smrg echo "You should only need it if you modified a '.l' file." 193dc088bc7Smrg echo "You may want to install the Fast Lexical Analyzer package:" 194dc088bc7Smrg echo "<$flex_URL>" 195dc088bc7Smrg ;; 196cdbfa18aSmrg makeinfo*) 197cdbfa18aSmrg echo "You should only need it if you modified a '.texi' file, or" 198cdbfa18aSmrg echo "any other file indirectly affecting the aspect of the manual." 199cdbfa18aSmrg echo "You might want to install the Texinfo package:" 200cdbfa18aSmrg echo "<$gnu_software_URL/texinfo/>" 201cdbfa18aSmrg echo "The spurious makeinfo call might also be the consequence of" 202cdbfa18aSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 203cdbfa18aSmrg echo "want to install GNU make:" 204cdbfa18aSmrg echo "<$gnu_software_URL/make/>" 205cdbfa18aSmrg ;; 206dc088bc7Smrg perl*) 207dc088bc7Smrg echo "You should only need it to run GNU Autoconf, GNU Automake, " 208dc088bc7Smrg echo " assorted other tools, or if you modified a Perl source file." 209dc088bc7Smrg echo "You may want to install the Perl 5 language interpreter:" 210dc088bc7Smrg echo "<$perl_URL>" 211dc088bc7Smrg ;; 212cdbfa18aSmrg *) 213cdbfa18aSmrg echo "You might have modified some files without having the proper" 214cdbfa18aSmrg echo "tools for further handling them. Check the 'README' file, it" 215cdbfa18aSmrg echo "often tells you about the needed prerequisites for installing" 216cdbfa18aSmrg echo "this package. You may also peek at any GNU archive site, in" 217cdbfa18aSmrg echo "case some other package contains this missing '$1' program." 218cdbfa18aSmrg ;; 219cdbfa18aSmrg esac 220dc088bc7Smrg program_details "$normalized_program" 221cdbfa18aSmrg} 222cdbfa18aSmrg 223cdbfa18aSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 224cdbfa18aSmrg -e '2,$s/^/ /' >&2 225cdbfa18aSmrg 226cdbfa18aSmrg# Propagate the correct exit status (expected to be 127 for a program 227cdbfa18aSmrg# not found, 63 for a program that failed due to version mismatch). 228cdbfa18aSmrgexit $st 2299f606849Smrg 2309f606849Smrg# Local variables: 231949d0342Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2329f606849Smrg# time-stamp-start: "scriptversion=" 2339f606849Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 234949d0342Smrg# time-stamp-time-zone: "UTC0" 235fba89afeSmrg# time-stamp-end: "; # UTC" 2369f606849Smrg# End: 237