1bd1da9d7Smrg#! /bin/sh 2899129b3Smrg# Common wrapper for a few potentially missing GNU programs. 3bd1da9d7Smrg 46ad5a0e2Smrgscriptversion=2018-03-07.03; # UTC 5bd1da9d7Smrg 6a392d4f3Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7899129b3Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8bd1da9d7Smrg 9bd1da9d7Smrg# This program is free software; you can redistribute it and/or modify 10bd1da9d7Smrg# it under the terms of the GNU General Public License as published by 11bd1da9d7Smrg# the Free Software Foundation; either version 2, or (at your option) 12bd1da9d7Smrg# any later version. 13bd1da9d7Smrg 14bd1da9d7Smrg# This program is distributed in the hope that it will be useful, 15bd1da9d7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16bd1da9d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17bd1da9d7Smrg# GNU General Public License for more details. 18bd1da9d7Smrg 19bd1da9d7Smrg# You should have received a copy of the GNU General Public License 206ad5a0e2Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21bd1da9d7Smrg 22bd1da9d7Smrg# As a special exception to the GNU General Public License, if you 23bd1da9d7Smrg# distribute this file as part of a program that contains a 24bd1da9d7Smrg# configuration script generated by Autoconf, you may include it under 25bd1da9d7Smrg# the same distribution terms that you use for the rest of that program. 26bd1da9d7Smrg 27bd1da9d7Smrgif test $# -eq 0; then 28899129b3Smrg echo 1>&2 "Try '$0 --help' for more information" 29bd1da9d7Smrg exit 1 30bd1da9d7Smrgfi 31bd1da9d7Smrg 32899129b3Smrgcase $1 in 33bd1da9d7Smrg 34899129b3Smrg --is-lightweight) 35899129b3Smrg # Used by our autoconf macros to check whether the available missing 36899129b3Smrg # script is modern enough. 37899129b3Smrg exit 0 38899129b3Smrg ;; 39bd1da9d7Smrg 40899129b3Smrg --run) 41899129b3Smrg # Back-compat with the calling convention used by older automake. 42899129b3Smrg shift 43899129b3Smrg ;; 44bd1da9d7Smrg 45bd1da9d7Smrg -h|--h|--he|--hel|--help) 46bd1da9d7Smrg echo "\ 47bd1da9d7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48bd1da9d7Smrg 49899129b3SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50899129b3Smrgto PROGRAM being missing or too old. 51bd1da9d7Smrg 52bd1da9d7SmrgOptions: 53bd1da9d7Smrg -h, --help display this help and exit 54bd1da9d7Smrg -v, --version output version information and exit 55bd1da9d7Smrg 56bd1da9d7SmrgSupported PROGRAM values: 57899129b3Smrg aclocal autoconf autoheader autom4te automake makeinfo 58899129b3Smrg bison yacc flex lex help2man 59bd1da9d7Smrg 60899129b3SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61899129b3Smrg'g' are ignored when checking the name. 625bcb6992Smrg 63bd1da9d7SmrgSend bug reports to <bug-automake@gnu.org>." 64bd1da9d7Smrg exit $? 65bd1da9d7Smrg ;; 66bd1da9d7Smrg 67bd1da9d7Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68bd1da9d7Smrg echo "missing $scriptversion (GNU Automake)" 69bd1da9d7Smrg exit $? 70bd1da9d7Smrg ;; 71bd1da9d7Smrg 72bd1da9d7Smrg -*) 73899129b3Smrg echo 1>&2 "$0: unknown '$1' option" 74899129b3Smrg echo 1>&2 "Try '$0 --help' for more information" 75bd1da9d7Smrg exit 1 76bd1da9d7Smrg ;; 77bd1da9d7Smrg 78bd1da9d7Smrgesac 79bd1da9d7Smrg 80899129b3Smrg# Run the given program, remember its exit status. 81899129b3Smrg"$@"; st=$? 82899129b3Smrg 83899129b3Smrg# If it succeeded, we are done. 84899129b3Smrgtest $st -eq 0 && exit 0 85899129b3Smrg 86899129b3Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87899129b3Smrg# passed; such an option is passed most likely to detect whether the 88899129b3Smrg# program is present and works. 89899129b3Smrgcase $2 in --version|--help) exit $st;; esac 90899129b3Smrg 91899129b3Smrg# Exit code 63 means version mismatch. This often happens when the user 92899129b3Smrg# tries to use an ancient version of a tool on a file that requires a 93899129b3Smrg# minimum version. 94899129b3Smrgif test $st -eq 63; then 95899129b3Smrg msg="probably too old" 96899129b3Smrgelif test $st -eq 127; then 97899129b3Smrg # Program was missing. 98899129b3Smrg msg="missing on your system" 99899129b3Smrgelse 100899129b3Smrg # Program was found and executed, but failed. Give up. 101899129b3Smrg exit $st 102899129b3Smrgfi 103bd1da9d7Smrg 1046ad5a0e2Smrgperl_URL=https://www.perl.org/ 1056ad5a0e2Smrgflex_URL=https://github.com/westes/flex 1066ad5a0e2Smrggnu_software_URL=https://www.gnu.org/software 107899129b3Smrg 108899129b3Smrgprogram_details () 109899129b3Smrg{ 110899129b3Smrg case $1 in 111899129b3Smrg aclocal|automake) 112899129b3Smrg echo "The '$1' program is part of the GNU Automake package:" 113899129b3Smrg echo "<$gnu_software_URL/automake>" 114899129b3Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115899129b3Smrg echo "<$gnu_software_URL/autoconf>" 116899129b3Smrg echo "<$gnu_software_URL/m4/>" 117899129b3Smrg echo "<$perl_URL>" 118899129b3Smrg ;; 119899129b3Smrg autoconf|autom4te|autoheader) 120899129b3Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121899129b3Smrg echo "<$gnu_software_URL/autoconf/>" 122899129b3Smrg echo "It also requires GNU m4 and Perl in order to run:" 123899129b3Smrg echo "<$gnu_software_URL/m4/>" 124899129b3Smrg echo "<$perl_URL>" 125899129b3Smrg ;; 126899129b3Smrg esac 127899129b3Smrg} 128899129b3Smrg 129899129b3Smrggive_advice () 130899129b3Smrg{ 131899129b3Smrg # Normalize program name to check for. 132899129b3Smrg normalized_program=`echo "$1" | sed ' 133899129b3Smrg s/^gnu-//; t 134899129b3Smrg s/^gnu//; t 135899129b3Smrg s/^g//; t'` 136899129b3Smrg 137899129b3Smrg printf '%s\n' "'$1' is $msg." 138899129b3Smrg 139899129b3Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140899129b3Smrg case $normalized_program in 141899129b3Smrg autoconf*) 142899129b3Smrg echo "You should only need it if you modified 'configure.ac'," 143899129b3Smrg echo "or m4 files included by it." 144899129b3Smrg program_details 'autoconf' 145899129b3Smrg ;; 146899129b3Smrg autoheader*) 147899129b3Smrg echo "You should only need it if you modified 'acconfig.h' or" 148899129b3Smrg echo "$configure_deps." 149899129b3Smrg program_details 'autoheader' 150899129b3Smrg ;; 151899129b3Smrg automake*) 152899129b3Smrg echo "You should only need it if you modified 'Makefile.am' or" 153899129b3Smrg echo "$configure_deps." 154899129b3Smrg program_details 'automake' 155899129b3Smrg ;; 156899129b3Smrg aclocal*) 157899129b3Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158899129b3Smrg echo "$configure_deps." 159899129b3Smrg program_details 'aclocal' 160899129b3Smrg ;; 161899129b3Smrg autom4te*) 162899129b3Smrg echo "You might have modified some maintainer files that require" 163e6d2e958Smrg echo "the 'autom4te' program to be rebuilt." 164899129b3Smrg program_details 'autom4te' 165899129b3Smrg ;; 166899129b3Smrg bison*|yacc*) 167899129b3Smrg echo "You should only need it if you modified a '.y' file." 168899129b3Smrg echo "You may want to install the GNU Bison package:" 169899129b3Smrg echo "<$gnu_software_URL/bison/>" 170899129b3Smrg ;; 171899129b3Smrg lex*|flex*) 172899129b3Smrg echo "You should only need it if you modified a '.l' file." 173899129b3Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174899129b3Smrg echo "<$flex_URL>" 175899129b3Smrg ;; 176899129b3Smrg help2man*) 177899129b3Smrg echo "You should only need it if you modified a dependency" \ 178899129b3Smrg "of a man page." 179899129b3Smrg echo "You may want to install the GNU Help2man package:" 180899129b3Smrg echo "<$gnu_software_URL/help2man/>" 181899129b3Smrg ;; 182899129b3Smrg makeinfo*) 183899129b3Smrg echo "You should only need it if you modified a '.texi' file, or" 184899129b3Smrg echo "any other file indirectly affecting the aspect of the manual." 185899129b3Smrg echo "You might want to install the Texinfo package:" 186899129b3Smrg echo "<$gnu_software_URL/texinfo/>" 187899129b3Smrg echo "The spurious makeinfo call might also be the consequence of" 188899129b3Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189899129b3Smrg echo "want to install GNU make:" 190899129b3Smrg echo "<$gnu_software_URL/make/>" 191899129b3Smrg ;; 192899129b3Smrg *) 193899129b3Smrg echo "You might have modified some files without having the proper" 194899129b3Smrg echo "tools for further handling them. Check the 'README' file, it" 195899129b3Smrg echo "often tells you about the needed prerequisites for installing" 196899129b3Smrg echo "this package. You may also peek at any GNU archive site, in" 197899129b3Smrg echo "case some other package contains this missing '$1' program." 198899129b3Smrg ;; 199899129b3Smrg esac 200899129b3Smrg} 201899129b3Smrg 202899129b3Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203899129b3Smrg -e '2,$s/^/ /' >&2 204899129b3Smrg 205899129b3Smrg# Propagate the correct exit status (expected to be 127 for a program 206899129b3Smrg# not found, 63 for a program that failed due to version mismatch). 207899129b3Smrgexit $st 208bd1da9d7Smrg 209bd1da9d7Smrg# Local variables: 2106ad5a0e2Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211bd1da9d7Smrg# time-stamp-start: "scriptversion=" 212bd1da9d7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2136ad5a0e2Smrg# time-stamp-time-zone: "UTC0" 2145bcb6992Smrg# time-stamp-end: "; # UTC" 215bd1da9d7Smrg# End: 216