1023b3b36Smrg#! /bin/sh 2023b3b36Smrg# Common wrapper for a few potentially missing GNU programs. 3023b3b36Smrg 4023b3b36Smrgscriptversion=2018-03-07.03; # UTC 5023b3b36Smrg 6023b3b36Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7023b3b36Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8023b3b36Smrg 9023b3b36Smrg# This program is free software; you can redistribute it and/or modify 10023b3b36Smrg# it under the terms of the GNU General Public License as published by 11023b3b36Smrg# the Free Software Foundation; either version 2, or (at your option) 12023b3b36Smrg# any later version. 13023b3b36Smrg 14023b3b36Smrg# This program is distributed in the hope that it will be useful, 15023b3b36Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16023b3b36Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17023b3b36Smrg# GNU General Public License for more details. 18023b3b36Smrg 19023b3b36Smrg# You should have received a copy of the GNU General Public License 20023b3b36Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21023b3b36Smrg 22023b3b36Smrg# As a special exception to the GNU General Public License, if you 23023b3b36Smrg# distribute this file as part of a program that contains a 24023b3b36Smrg# configuration script generated by Autoconf, you may include it under 25023b3b36Smrg# the same distribution terms that you use for the rest of that program. 26023b3b36Smrg 27023b3b36Smrgif test $# -eq 0; then 28023b3b36Smrg echo 1>&2 "Try '$0 --help' for more information" 29023b3b36Smrg exit 1 30023b3b36Smrgfi 31023b3b36Smrg 32023b3b36Smrgcase $1 in 33023b3b36Smrg 34023b3b36Smrg --is-lightweight) 35023b3b36Smrg # Used by our autoconf macros to check whether the available missing 36023b3b36Smrg # script is modern enough. 37023b3b36Smrg exit 0 38023b3b36Smrg ;; 39023b3b36Smrg 40023b3b36Smrg --run) 41023b3b36Smrg # Back-compat with the calling convention used by older automake. 42023b3b36Smrg shift 43023b3b36Smrg ;; 44023b3b36Smrg 45023b3b36Smrg -h|--h|--he|--hel|--help) 46023b3b36Smrg echo "\ 47023b3b36Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48023b3b36Smrg 49023b3b36SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50023b3b36Smrgto PROGRAM being missing or too old. 51023b3b36Smrg 52023b3b36SmrgOptions: 53023b3b36Smrg -h, --help display this help and exit 54023b3b36Smrg -v, --version output version information and exit 55023b3b36Smrg 56023b3b36SmrgSupported PROGRAM values: 57023b3b36Smrg aclocal autoconf autoheader autom4te automake makeinfo 58023b3b36Smrg bison yacc flex lex help2man 59023b3b36Smrg 60023b3b36SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61023b3b36Smrg'g' are ignored when checking the name. 62023b3b36Smrg 63023b3b36SmrgSend bug reports to <bug-automake@gnu.org>." 64023b3b36Smrg exit $? 65023b3b36Smrg ;; 66023b3b36Smrg 67023b3b36Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68023b3b36Smrg echo "missing $scriptversion (GNU Automake)" 69023b3b36Smrg exit $? 70023b3b36Smrg ;; 71023b3b36Smrg 72023b3b36Smrg -*) 73023b3b36Smrg echo 1>&2 "$0: unknown '$1' option" 74023b3b36Smrg echo 1>&2 "Try '$0 --help' for more information" 75023b3b36Smrg exit 1 76023b3b36Smrg ;; 77023b3b36Smrg 78023b3b36Smrgesac 79023b3b36Smrg 80023b3b36Smrg# Run the given program, remember its exit status. 81023b3b36Smrg"$@"; st=$? 82023b3b36Smrg 83023b3b36Smrg# If it succeeded, we are done. 84023b3b36Smrgtest $st -eq 0 && exit 0 85023b3b36Smrg 86023b3b36Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87023b3b36Smrg# passed; such an option is passed most likely to detect whether the 88023b3b36Smrg# program is present and works. 89023b3b36Smrgcase $2 in --version|--help) exit $st;; esac 90023b3b36Smrg 91023b3b36Smrg# Exit code 63 means version mismatch. This often happens when the user 92023b3b36Smrg# tries to use an ancient version of a tool on a file that requires a 93023b3b36Smrg# minimum version. 94023b3b36Smrgif test $st -eq 63; then 95023b3b36Smrg msg="probably too old" 96023b3b36Smrgelif test $st -eq 127; then 97023b3b36Smrg # Program was missing. 98023b3b36Smrg msg="missing on your system" 99023b3b36Smrgelse 100023b3b36Smrg # Program was found and executed, but failed. Give up. 101023b3b36Smrg exit $st 102023b3b36Smrgfi 103023b3b36Smrg 104023b3b36Smrgperl_URL=https://www.perl.org/ 105023b3b36Smrgflex_URL=https://github.com/westes/flex 106023b3b36Smrggnu_software_URL=https://www.gnu.org/software 107023b3b36Smrg 108023b3b36Smrgprogram_details () 109023b3b36Smrg{ 110023b3b36Smrg case $1 in 111023b3b36Smrg aclocal|automake) 112023b3b36Smrg echo "The '$1' program is part of the GNU Automake package:" 113023b3b36Smrg echo "<$gnu_software_URL/automake>" 114023b3b36Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115023b3b36Smrg echo "<$gnu_software_URL/autoconf>" 116023b3b36Smrg echo "<$gnu_software_URL/m4/>" 117023b3b36Smrg echo "<$perl_URL>" 118023b3b36Smrg ;; 119023b3b36Smrg autoconf|autom4te|autoheader) 120023b3b36Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121023b3b36Smrg echo "<$gnu_software_URL/autoconf/>" 122023b3b36Smrg echo "It also requires GNU m4 and Perl in order to run:" 123023b3b36Smrg echo "<$gnu_software_URL/m4/>" 124023b3b36Smrg echo "<$perl_URL>" 125023b3b36Smrg ;; 126023b3b36Smrg esac 127023b3b36Smrg} 128023b3b36Smrg 129023b3b36Smrggive_advice () 130023b3b36Smrg{ 131023b3b36Smrg # Normalize program name to check for. 132023b3b36Smrg normalized_program=`echo "$1" | sed ' 133023b3b36Smrg s/^gnu-//; t 134023b3b36Smrg s/^gnu//; t 135023b3b36Smrg s/^g//; t'` 136023b3b36Smrg 137023b3b36Smrg printf '%s\n' "'$1' is $msg." 138023b3b36Smrg 139023b3b36Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140023b3b36Smrg case $normalized_program in 141023b3b36Smrg autoconf*) 142023b3b36Smrg echo "You should only need it if you modified 'configure.ac'," 143023b3b36Smrg echo "or m4 files included by it." 144023b3b36Smrg program_details 'autoconf' 145023b3b36Smrg ;; 146023b3b36Smrg autoheader*) 147023b3b36Smrg echo "You should only need it if you modified 'acconfig.h' or" 148023b3b36Smrg echo "$configure_deps." 149023b3b36Smrg program_details 'autoheader' 150023b3b36Smrg ;; 151023b3b36Smrg automake*) 152023b3b36Smrg echo "You should only need it if you modified 'Makefile.am' or" 153023b3b36Smrg echo "$configure_deps." 154023b3b36Smrg program_details 'automake' 155023b3b36Smrg ;; 156023b3b36Smrg aclocal*) 157023b3b36Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158023b3b36Smrg echo "$configure_deps." 159023b3b36Smrg program_details 'aclocal' 160023b3b36Smrg ;; 161023b3b36Smrg autom4te*) 162023b3b36Smrg echo "You might have modified some maintainer files that require" 163023b3b36Smrg echo "the 'autom4te' program to be rebuilt." 164023b3b36Smrg program_details 'autom4te' 165023b3b36Smrg ;; 166023b3b36Smrg bison*|yacc*) 167023b3b36Smrg echo "You should only need it if you modified a '.y' file." 168023b3b36Smrg echo "You may want to install the GNU Bison package:" 169023b3b36Smrg echo "<$gnu_software_URL/bison/>" 170023b3b36Smrg ;; 171023b3b36Smrg lex*|flex*) 172023b3b36Smrg echo "You should only need it if you modified a '.l' file." 173023b3b36Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174023b3b36Smrg echo "<$flex_URL>" 175023b3b36Smrg ;; 176023b3b36Smrg help2man*) 177023b3b36Smrg echo "You should only need it if you modified a dependency" \ 178023b3b36Smrg "of a man page." 179023b3b36Smrg echo "You may want to install the GNU Help2man package:" 180023b3b36Smrg echo "<$gnu_software_URL/help2man/>" 181023b3b36Smrg ;; 182023b3b36Smrg makeinfo*) 183023b3b36Smrg echo "You should only need it if you modified a '.texi' file, or" 184023b3b36Smrg echo "any other file indirectly affecting the aspect of the manual." 185023b3b36Smrg echo "You might want to install the Texinfo package:" 186023b3b36Smrg echo "<$gnu_software_URL/texinfo/>" 187023b3b36Smrg echo "The spurious makeinfo call might also be the consequence of" 188023b3b36Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189023b3b36Smrg echo "want to install GNU make:" 190023b3b36Smrg echo "<$gnu_software_URL/make/>" 191023b3b36Smrg ;; 192023b3b36Smrg *) 193023b3b36Smrg echo "You might have modified some files without having the proper" 194023b3b36Smrg echo "tools for further handling them. Check the 'README' file, it" 195023b3b36Smrg echo "often tells you about the needed prerequisites for installing" 196023b3b36Smrg echo "this package. You may also peek at any GNU archive site, in" 197023b3b36Smrg echo "case some other package contains this missing '$1' program." 198023b3b36Smrg ;; 199023b3b36Smrg esac 200023b3b36Smrg} 201023b3b36Smrg 202023b3b36Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203023b3b36Smrg -e '2,$s/^/ /' >&2 204023b3b36Smrg 205023b3b36Smrg# Propagate the correct exit status (expected to be 127 for a program 206023b3b36Smrg# not found, 63 for a program that failed due to version mismatch). 207023b3b36Smrgexit $st 208023b3b36Smrg 209023b3b36Smrg# Local variables: 210023b3b36Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211023b3b36Smrg# time-stamp-start: "scriptversion=" 212023b3b36Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213023b3b36Smrg# time-stamp-time-zone: "UTC0" 214023b3b36Smrg# time-stamp-end: "; # UTC" 215023b3b36Smrg# End: 216