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