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