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