1bb068e1dSmrg#! /bin/sh 2bb068e1dSmrg# Common wrapper for a few potentially missing GNU programs. 3bb068e1dSmrg 4bb068e1dSmrgscriptversion=2018-03-07.03; # UTC 5bb068e1dSmrg 6bb068e1dSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7bb068e1dSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8bb068e1dSmrg 9bb068e1dSmrg# This program is free software; you can redistribute it and/or modify 10bb068e1dSmrg# it under the terms of the GNU General Public License as published by 11bb068e1dSmrg# the Free Software Foundation; either version 2, or (at your option) 12bb068e1dSmrg# any later version. 13bb068e1dSmrg 14bb068e1dSmrg# This program is distributed in the hope that it will be useful, 15bb068e1dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16bb068e1dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17bb068e1dSmrg# GNU General Public License for more details. 18bb068e1dSmrg 19bb068e1dSmrg# You should have received a copy of the GNU General Public License 20bb068e1dSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21bb068e1dSmrg 22bb068e1dSmrg# As a special exception to the GNU General Public License, if you 23bb068e1dSmrg# distribute this file as part of a program that contains a 24bb068e1dSmrg# configuration script generated by Autoconf, you may include it under 25bb068e1dSmrg# the same distribution terms that you use for the rest of that program. 26bb068e1dSmrg 27bb068e1dSmrgif test $# -eq 0; then 28bb068e1dSmrg echo 1>&2 "Try '$0 --help' for more information" 29bb068e1dSmrg exit 1 30bb068e1dSmrgfi 31bb068e1dSmrg 32bb068e1dSmrgcase $1 in 33bb068e1dSmrg 34bb068e1dSmrg --is-lightweight) 35bb068e1dSmrg # Used by our autoconf macros to check whether the available missing 36bb068e1dSmrg # script is modern enough. 37bb068e1dSmrg exit 0 38bb068e1dSmrg ;; 39bb068e1dSmrg 40bb068e1dSmrg --run) 41bb068e1dSmrg # Back-compat with the calling convention used by older automake. 42bb068e1dSmrg shift 43bb068e1dSmrg ;; 44bb068e1dSmrg 45bb068e1dSmrg -h|--h|--he|--hel|--help) 46bb068e1dSmrg echo "\ 47bb068e1dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48bb068e1dSmrg 49bb068e1dSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50bb068e1dSmrgto PROGRAM being missing or too old. 51bb068e1dSmrg 52bb068e1dSmrgOptions: 53bb068e1dSmrg -h, --help display this help and exit 54bb068e1dSmrg -v, --version output version information and exit 55bb068e1dSmrg 56bb068e1dSmrgSupported PROGRAM values: 57bb068e1dSmrg aclocal autoconf autoheader autom4te automake makeinfo 58bb068e1dSmrg bison yacc flex lex help2man 59bb068e1dSmrg 60bb068e1dSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61bb068e1dSmrg'g' are ignored when checking the name. 62bb068e1dSmrg 63bb068e1dSmrgSend bug reports to <bug-automake@gnu.org>." 64bb068e1dSmrg exit $? 65bb068e1dSmrg ;; 66bb068e1dSmrg 67bb068e1dSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68bb068e1dSmrg echo "missing $scriptversion (GNU Automake)" 69bb068e1dSmrg exit $? 70bb068e1dSmrg ;; 71bb068e1dSmrg 72bb068e1dSmrg -*) 73bb068e1dSmrg echo 1>&2 "$0: unknown '$1' option" 74bb068e1dSmrg echo 1>&2 "Try '$0 --help' for more information" 75bb068e1dSmrg exit 1 76bb068e1dSmrg ;; 77bb068e1dSmrg 78bb068e1dSmrgesac 79bb068e1dSmrg 80bb068e1dSmrg# Run the given program, remember its exit status. 81bb068e1dSmrg"$@"; st=$? 82bb068e1dSmrg 83bb068e1dSmrg# If it succeeded, we are done. 84bb068e1dSmrgtest $st -eq 0 && exit 0 85bb068e1dSmrg 86bb068e1dSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87bb068e1dSmrg# passed; such an option is passed most likely to detect whether the 88bb068e1dSmrg# program is present and works. 89bb068e1dSmrgcase $2 in --version|--help) exit $st;; esac 90bb068e1dSmrg 91bb068e1dSmrg# Exit code 63 means version mismatch. This often happens when the user 92bb068e1dSmrg# tries to use an ancient version of a tool on a file that requires a 93bb068e1dSmrg# minimum version. 94bb068e1dSmrgif test $st -eq 63; then 95bb068e1dSmrg msg="probably too old" 96bb068e1dSmrgelif test $st -eq 127; then 97bb068e1dSmrg # Program was missing. 98bb068e1dSmrg msg="missing on your system" 99bb068e1dSmrgelse 100bb068e1dSmrg # Program was found and executed, but failed. Give up. 101bb068e1dSmrg exit $st 102bb068e1dSmrgfi 103bb068e1dSmrg 104bb068e1dSmrgperl_URL=https://www.perl.org/ 105bb068e1dSmrgflex_URL=https://github.com/westes/flex 106bb068e1dSmrggnu_software_URL=https://www.gnu.org/software 107bb068e1dSmrg 108bb068e1dSmrgprogram_details () 109bb068e1dSmrg{ 110bb068e1dSmrg case $1 in 111bb068e1dSmrg aclocal|automake) 112bb068e1dSmrg echo "The '$1' program is part of the GNU Automake package:" 113bb068e1dSmrg echo "<$gnu_software_URL/automake>" 114bb068e1dSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115bb068e1dSmrg echo "<$gnu_software_URL/autoconf>" 116bb068e1dSmrg echo "<$gnu_software_URL/m4/>" 117bb068e1dSmrg echo "<$perl_URL>" 118bb068e1dSmrg ;; 119bb068e1dSmrg autoconf|autom4te|autoheader) 120bb068e1dSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121bb068e1dSmrg echo "<$gnu_software_URL/autoconf/>" 122bb068e1dSmrg echo "It also requires GNU m4 and Perl in order to run:" 123bb068e1dSmrg echo "<$gnu_software_URL/m4/>" 124bb068e1dSmrg echo "<$perl_URL>" 125bb068e1dSmrg ;; 126bb068e1dSmrg esac 127bb068e1dSmrg} 128bb068e1dSmrg 129bb068e1dSmrggive_advice () 130bb068e1dSmrg{ 131bb068e1dSmrg # Normalize program name to check for. 132bb068e1dSmrg normalized_program=`echo "$1" | sed ' 133bb068e1dSmrg s/^gnu-//; t 134bb068e1dSmrg s/^gnu//; t 135bb068e1dSmrg s/^g//; t'` 136bb068e1dSmrg 137bb068e1dSmrg printf '%s\n' "'$1' is $msg." 138bb068e1dSmrg 139bb068e1dSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140bb068e1dSmrg case $normalized_program in 141bb068e1dSmrg autoconf*) 142bb068e1dSmrg echo "You should only need it if you modified 'configure.ac'," 143bb068e1dSmrg echo "or m4 files included by it." 144bb068e1dSmrg program_details 'autoconf' 145bb068e1dSmrg ;; 146bb068e1dSmrg autoheader*) 147bb068e1dSmrg echo "You should only need it if you modified 'acconfig.h' or" 148bb068e1dSmrg echo "$configure_deps." 149bb068e1dSmrg program_details 'autoheader' 150bb068e1dSmrg ;; 151bb068e1dSmrg automake*) 152bb068e1dSmrg echo "You should only need it if you modified 'Makefile.am' or" 153bb068e1dSmrg echo "$configure_deps." 154bb068e1dSmrg program_details 'automake' 155bb068e1dSmrg ;; 156bb068e1dSmrg aclocal*) 157bb068e1dSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158bb068e1dSmrg echo "$configure_deps." 159bb068e1dSmrg program_details 'aclocal' 160bb068e1dSmrg ;; 161bb068e1dSmrg autom4te*) 162bb068e1dSmrg echo "You might have modified some maintainer files that require" 163bb068e1dSmrg echo "the 'autom4te' program to be rebuilt." 164bb068e1dSmrg program_details 'autom4te' 165bb068e1dSmrg ;; 166bb068e1dSmrg bison*|yacc*) 167bb068e1dSmrg echo "You should only need it if you modified a '.y' file." 168bb068e1dSmrg echo "You may want to install the GNU Bison package:" 169bb068e1dSmrg echo "<$gnu_software_URL/bison/>" 170bb068e1dSmrg ;; 171bb068e1dSmrg lex*|flex*) 172bb068e1dSmrg echo "You should only need it if you modified a '.l' file." 173bb068e1dSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174bb068e1dSmrg echo "<$flex_URL>" 175bb068e1dSmrg ;; 176bb068e1dSmrg help2man*) 177bb068e1dSmrg echo "You should only need it if you modified a dependency" \ 178bb068e1dSmrg "of a man page." 179bb068e1dSmrg echo "You may want to install the GNU Help2man package:" 180bb068e1dSmrg echo "<$gnu_software_URL/help2man/>" 181bb068e1dSmrg ;; 182bb068e1dSmrg makeinfo*) 183bb068e1dSmrg echo "You should only need it if you modified a '.texi' file, or" 184bb068e1dSmrg echo "any other file indirectly affecting the aspect of the manual." 185bb068e1dSmrg echo "You might want to install the Texinfo package:" 186bb068e1dSmrg echo "<$gnu_software_URL/texinfo/>" 187bb068e1dSmrg echo "The spurious makeinfo call might also be the consequence of" 188bb068e1dSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189bb068e1dSmrg echo "want to install GNU make:" 190bb068e1dSmrg echo "<$gnu_software_URL/make/>" 191bb068e1dSmrg ;; 192bb068e1dSmrg *) 193bb068e1dSmrg echo "You might have modified some files without having the proper" 194bb068e1dSmrg echo "tools for further handling them. Check the 'README' file, it" 195bb068e1dSmrg echo "often tells you about the needed prerequisites for installing" 196bb068e1dSmrg echo "this package. You may also peek at any GNU archive site, in" 197bb068e1dSmrg echo "case some other package contains this missing '$1' program." 198bb068e1dSmrg ;; 199bb068e1dSmrg esac 200bb068e1dSmrg} 201bb068e1dSmrg 202bb068e1dSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203bb068e1dSmrg -e '2,$s/^/ /' >&2 204bb068e1dSmrg 205bb068e1dSmrg# Propagate the correct exit status (expected to be 127 for a program 206bb068e1dSmrg# not found, 63 for a program that failed due to version mismatch). 207bb068e1dSmrgexit $st 208bb068e1dSmrg 209bb068e1dSmrg# Local variables: 210bb068e1dSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 211bb068e1dSmrg# time-stamp-start: "scriptversion=" 212bb068e1dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213bb068e1dSmrg# time-stamp-time-zone: "UTC0" 214bb068e1dSmrg# time-stamp-end: "; # UTC" 215bb068e1dSmrg# End: 216