1ded1caa4Smrg#! /bin/sh 2414cce6aSmrg# Common wrapper for a few potentially missing GNU programs. 350539131Smrg 4414cce6aSmrgscriptversion=2018-03-07.03; # UTC 550539131Smrg 6414cce6aSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7414cce6aSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8ded1caa4Smrg 9ded1caa4Smrg# This program is free software; you can redistribute it and/or modify 10ded1caa4Smrg# it under the terms of the GNU General Public License as published by 11ded1caa4Smrg# the Free Software Foundation; either version 2, or (at your option) 12ded1caa4Smrg# any later version. 13ded1caa4Smrg 14ded1caa4Smrg# This program is distributed in the hope that it will be useful, 15ded1caa4Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16ded1caa4Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17ded1caa4Smrg# GNU General Public License for more details. 18ded1caa4Smrg 19ded1caa4Smrg# You should have received a copy of the GNU General Public License 20414cce6aSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21ded1caa4Smrg 22ded1caa4Smrg# As a special exception to the GNU General Public License, if you 23ded1caa4Smrg# distribute this file as part of a program that contains a 24ded1caa4Smrg# configuration script generated by Autoconf, you may include it under 25ded1caa4Smrg# the same distribution terms that you use for the rest of that program. 26ded1caa4Smrg 27ded1caa4Smrgif test $# -eq 0; then 28414cce6aSmrg echo 1>&2 "Try '$0 --help' for more information" 29ded1caa4Smrg exit 1 30ded1caa4Smrgfi 31ded1caa4Smrg 32414cce6aSmrgcase $1 in 33ded1caa4Smrg 34414cce6aSmrg --is-lightweight) 35414cce6aSmrg # Used by our autoconf macros to check whether the available missing 36414cce6aSmrg # script is modern enough. 37414cce6aSmrg exit 0 38414cce6aSmrg ;; 3950539131Smrg 40414cce6aSmrg --run) 41414cce6aSmrg # Back-compat with the calling convention used by older automake. 42414cce6aSmrg shift 43414cce6aSmrg ;; 44ded1caa4Smrg 45ded1caa4Smrg -h|--h|--he|--hel|--help) 46ded1caa4Smrg echo "\ 47ded1caa4Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48ded1caa4Smrg 49414cce6aSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50414cce6aSmrgto PROGRAM being missing or too old. 51ded1caa4Smrg 52ded1caa4SmrgOptions: 53ded1caa4Smrg -h, --help display this help and exit 54ded1caa4Smrg -v, --version output version information and exit 55ded1caa4Smrg 56ded1caa4SmrgSupported PROGRAM values: 57414cce6aSmrg aclocal autoconf autoheader autom4te automake makeinfo 58414cce6aSmrg bison yacc flex lex help2man 5950539131Smrg 60414cce6aSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61414cce6aSmrg'g' are ignored when checking the name. 6250539131Smrg 6350539131SmrgSend bug reports to <bug-automake@gnu.org>." 6450539131Smrg exit $? 65ded1caa4Smrg ;; 66ded1caa4Smrg 67ded1caa4Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6850539131Smrg echo "missing $scriptversion (GNU Automake)" 6950539131Smrg exit $? 70ded1caa4Smrg ;; 71ded1caa4Smrg 72ded1caa4Smrg -*) 73414cce6aSmrg echo 1>&2 "$0: unknown '$1' option" 74414cce6aSmrg echo 1>&2 "Try '$0 --help' for more information" 75ded1caa4Smrg exit 1 76ded1caa4Smrg ;; 77ded1caa4Smrg 7850539131Smrgesac 7950539131Smrg 80414cce6aSmrg# Run the given program, remember its exit status. 81414cce6aSmrg"$@"; st=$? 82414cce6aSmrg 83414cce6aSmrg# If it succeeded, we are done. 84414cce6aSmrgtest $st -eq 0 && exit 0 85414cce6aSmrg 86414cce6aSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87414cce6aSmrg# passed; such an option is passed most likely to detect whether the 88414cce6aSmrg# program is present and works. 89414cce6aSmrgcase $2 in --version|--help) exit $st;; esac 90414cce6aSmrg 91414cce6aSmrg# Exit code 63 means version mismatch. This often happens when the user 92414cce6aSmrg# tries to use an ancient version of a tool on a file that requires a 93414cce6aSmrg# minimum version. 94414cce6aSmrgif test $st -eq 63; then 95414cce6aSmrg msg="probably too old" 96414cce6aSmrgelif test $st -eq 127; then 97414cce6aSmrg # Program was missing. 98414cce6aSmrg msg="missing on your system" 99414cce6aSmrgelse 100414cce6aSmrg # Program was found and executed, but failed. Give up. 101414cce6aSmrg exit $st 102414cce6aSmrgfi 103ded1caa4Smrg 104414cce6aSmrgperl_URL=https://www.perl.org/ 105414cce6aSmrgflex_URL=https://github.com/westes/flex 106414cce6aSmrggnu_software_URL=https://www.gnu.org/software 107414cce6aSmrg 108414cce6aSmrgprogram_details () 109414cce6aSmrg{ 110414cce6aSmrg case $1 in 111414cce6aSmrg aclocal|automake) 112414cce6aSmrg echo "The '$1' program is part of the GNU Automake package:" 113414cce6aSmrg echo "<$gnu_software_URL/automake>" 114414cce6aSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115414cce6aSmrg echo "<$gnu_software_URL/autoconf>" 116414cce6aSmrg echo "<$gnu_software_URL/m4/>" 117414cce6aSmrg echo "<$perl_URL>" 118414cce6aSmrg ;; 119414cce6aSmrg autoconf|autom4te|autoheader) 120414cce6aSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121414cce6aSmrg echo "<$gnu_software_URL/autoconf/>" 122414cce6aSmrg echo "It also requires GNU m4 and Perl in order to run:" 123414cce6aSmrg echo "<$gnu_software_URL/m4/>" 124414cce6aSmrg echo "<$perl_URL>" 125414cce6aSmrg ;; 126414cce6aSmrg esac 127414cce6aSmrg} 128414cce6aSmrg 129414cce6aSmrggive_advice () 130414cce6aSmrg{ 131414cce6aSmrg # Normalize program name to check for. 132414cce6aSmrg normalized_program=`echo "$1" | sed ' 133414cce6aSmrg s/^gnu-//; t 134414cce6aSmrg s/^gnu//; t 135414cce6aSmrg s/^g//; t'` 136414cce6aSmrg 137414cce6aSmrg printf '%s\n' "'$1' is $msg." 138414cce6aSmrg 139414cce6aSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140414cce6aSmrg case $normalized_program in 141414cce6aSmrg autoconf*) 142414cce6aSmrg echo "You should only need it if you modified 'configure.ac'," 143414cce6aSmrg echo "or m4 files included by it." 144414cce6aSmrg program_details 'autoconf' 145414cce6aSmrg ;; 146414cce6aSmrg autoheader*) 147414cce6aSmrg echo "You should only need it if you modified 'acconfig.h' or" 148414cce6aSmrg echo "$configure_deps." 149414cce6aSmrg program_details 'autoheader' 150414cce6aSmrg ;; 151414cce6aSmrg automake*) 152414cce6aSmrg echo "You should only need it if you modified 'Makefile.am' or" 153414cce6aSmrg echo "$configure_deps." 154414cce6aSmrg program_details 'automake' 155414cce6aSmrg ;; 156414cce6aSmrg aclocal*) 157414cce6aSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158414cce6aSmrg echo "$configure_deps." 159414cce6aSmrg program_details 'aclocal' 160414cce6aSmrg ;; 161414cce6aSmrg autom4te*) 162414cce6aSmrg echo "You might have modified some maintainer files that require" 163414cce6aSmrg echo "the 'autom4te' program to be rebuilt." 164414cce6aSmrg program_details 'autom4te' 165414cce6aSmrg ;; 166414cce6aSmrg bison*|yacc*) 167414cce6aSmrg echo "You should only need it if you modified a '.y' file." 168414cce6aSmrg echo "You may want to install the GNU Bison package:" 169414cce6aSmrg echo "<$gnu_software_URL/bison/>" 170414cce6aSmrg ;; 171414cce6aSmrg lex*|flex*) 172414cce6aSmrg echo "You should only need it if you modified a '.l' file." 173414cce6aSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174414cce6aSmrg echo "<$flex_URL>" 175414cce6aSmrg ;; 176414cce6aSmrg help2man*) 177414cce6aSmrg echo "You should only need it if you modified a dependency" \ 178414cce6aSmrg "of a man page." 179414cce6aSmrg echo "You may want to install the GNU Help2man package:" 180414cce6aSmrg echo "<$gnu_software_URL/help2man/>" 181414cce6aSmrg ;; 182414cce6aSmrg makeinfo*) 183414cce6aSmrg echo "You should only need it if you modified a '.texi' file, or" 184414cce6aSmrg echo "any other file indirectly affecting the aspect of the manual." 185414cce6aSmrg echo "You might want to install the Texinfo package:" 186414cce6aSmrg echo "<$gnu_software_URL/texinfo/>" 187414cce6aSmrg echo "The spurious makeinfo call might also be the consequence of" 188414cce6aSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189414cce6aSmrg echo "want to install GNU make:" 190414cce6aSmrg echo "<$gnu_software_URL/make/>" 191414cce6aSmrg ;; 192414cce6aSmrg *) 193414cce6aSmrg echo "You might have modified some files without having the proper" 194414cce6aSmrg echo "tools for further handling them. Check the 'README' file, it" 195414cce6aSmrg echo "often tells you about the needed prerequisites for installing" 196414cce6aSmrg echo "this package. You may also peek at any GNU archive site, in" 197414cce6aSmrg echo "case some other package contains this missing '$1' program." 198414cce6aSmrg ;; 199414cce6aSmrg esac 200414cce6aSmrg} 201414cce6aSmrg 202414cce6aSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203414cce6aSmrg -e '2,$s/^/ /' >&2 204414cce6aSmrg 205414cce6aSmrg# Propagate the correct exit status (expected to be 127 for a program 206414cce6aSmrg# not found, 63 for a program that failed due to version mismatch). 207414cce6aSmrgexit $st 20850539131Smrg 20950539131Smrg# Local variables: 210414cce6aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 21150539131Smrg# time-stamp-start: "scriptversion=" 21250539131Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213414cce6aSmrg# time-stamp-time-zone: "UTC0" 21450539131Smrg# time-stamp-end: "; # UTC" 21550539131Smrg# End: 216