11a30de1fSmrg#! /bin/sh 2a733a5bfSmrg# Common wrapper for a few potentially missing GNU programs. 31a30de1fSmrg 46eaa481cSmrgscriptversion=2018-03-07.03; # UTC 51a30de1fSmrg 66eaa481cSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7a733a5bfSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 81a30de1fSmrg 91a30de1fSmrg# This program is free software; you can redistribute it and/or modify 101a30de1fSmrg# it under the terms of the GNU General Public License as published by 111a30de1fSmrg# the Free Software Foundation; either version 2, or (at your option) 121a30de1fSmrg# any later version. 131a30de1fSmrg 141a30de1fSmrg# This program is distributed in the hope that it will be useful, 151a30de1fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 161a30de1fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171a30de1fSmrg# GNU General Public License for more details. 181a30de1fSmrg 191a30de1fSmrg# You should have received a copy of the GNU General Public License 206eaa481cSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 211a30de1fSmrg 221a30de1fSmrg# As a special exception to the GNU General Public License, if you 231a30de1fSmrg# distribute this file as part of a program that contains a 241a30de1fSmrg# configuration script generated by Autoconf, you may include it under 251a30de1fSmrg# the same distribution terms that you use for the rest of that program. 261a30de1fSmrg 271a30de1fSmrgif test $# -eq 0; then 28a733a5bfSmrg echo 1>&2 "Try '$0 --help' for more information" 291a30de1fSmrg exit 1 301a30de1fSmrgfi 311a30de1fSmrg 32a733a5bfSmrgcase $1 in 331a30de1fSmrg 34a733a5bfSmrg --is-lightweight) 35a733a5bfSmrg # Used by our autoconf macros to check whether the available missing 36a733a5bfSmrg # script is modern enough. 37a733a5bfSmrg exit 0 38a733a5bfSmrg ;; 391a30de1fSmrg 40a733a5bfSmrg --run) 41a733a5bfSmrg # Back-compat with the calling convention used by older automake. 42a733a5bfSmrg shift 43a733a5bfSmrg ;; 441a30de1fSmrg 451a30de1fSmrg -h|--h|--he|--hel|--help) 461a30de1fSmrg echo "\ 471a30de1fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 481a30de1fSmrg 49a733a5bfSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50a733a5bfSmrgto PROGRAM being missing or too old. 511a30de1fSmrg 521a30de1fSmrgOptions: 531a30de1fSmrg -h, --help display this help and exit 541a30de1fSmrg -v, --version output version information and exit 551a30de1fSmrg 561a30de1fSmrgSupported PROGRAM values: 57a733a5bfSmrg aclocal autoconf autoheader autom4te automake makeinfo 58a733a5bfSmrg bison yacc flex lex help2man 591a30de1fSmrg 60a733a5bfSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61a733a5bfSmrg'g' are ignored when checking the name. 62b7fb5eacSmrg 631a30de1fSmrgSend bug reports to <bug-automake@gnu.org>." 641a30de1fSmrg exit $? 651a30de1fSmrg ;; 661a30de1fSmrg 671a30de1fSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 681a30de1fSmrg echo "missing $scriptversion (GNU Automake)" 691a30de1fSmrg exit $? 701a30de1fSmrg ;; 711a30de1fSmrg 721a30de1fSmrg -*) 73a733a5bfSmrg echo 1>&2 "$0: unknown '$1' option" 74a733a5bfSmrg echo 1>&2 "Try '$0 --help' for more information" 751a30de1fSmrg exit 1 761a30de1fSmrg ;; 771a30de1fSmrg 781a30de1fSmrgesac 791a30de1fSmrg 80a733a5bfSmrg# Run the given program, remember its exit status. 81a733a5bfSmrg"$@"; st=$? 82a733a5bfSmrg 83a733a5bfSmrg# If it succeeded, we are done. 84a733a5bfSmrgtest $st -eq 0 && exit 0 85a733a5bfSmrg 86a733a5bfSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87a733a5bfSmrg# passed; such an option is passed most likely to detect whether the 88a733a5bfSmrg# program is present and works. 89a733a5bfSmrgcase $2 in --version|--help) exit $st;; esac 90a733a5bfSmrg 91a733a5bfSmrg# Exit code 63 means version mismatch. This often happens when the user 92a733a5bfSmrg# tries to use an ancient version of a tool on a file that requires a 93a733a5bfSmrg# minimum version. 94a733a5bfSmrgif test $st -eq 63; then 95a733a5bfSmrg msg="probably too old" 96a733a5bfSmrgelif test $st -eq 127; then 97a733a5bfSmrg # Program was missing. 98a733a5bfSmrg msg="missing on your system" 99a733a5bfSmrgelse 100a733a5bfSmrg # Program was found and executed, but failed. Give up. 101a733a5bfSmrg exit $st 102a733a5bfSmrgfi 1031a30de1fSmrg 1046eaa481cSmrgperl_URL=https://www.perl.org/ 1056eaa481cSmrgflex_URL=https://github.com/westes/flex 1066eaa481cSmrggnu_software_URL=https://www.gnu.org/software 107a733a5bfSmrg 108a733a5bfSmrgprogram_details () 109a733a5bfSmrg{ 110a733a5bfSmrg case $1 in 111a733a5bfSmrg aclocal|automake) 112a733a5bfSmrg echo "The '$1' program is part of the GNU Automake package:" 113a733a5bfSmrg echo "<$gnu_software_URL/automake>" 114a733a5bfSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115a733a5bfSmrg echo "<$gnu_software_URL/autoconf>" 116a733a5bfSmrg echo "<$gnu_software_URL/m4/>" 117a733a5bfSmrg echo "<$perl_URL>" 118a733a5bfSmrg ;; 119a733a5bfSmrg autoconf|autom4te|autoheader) 120a733a5bfSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121a733a5bfSmrg echo "<$gnu_software_URL/autoconf/>" 122a733a5bfSmrg echo "It also requires GNU m4 and Perl in order to run:" 123a733a5bfSmrg echo "<$gnu_software_URL/m4/>" 124a733a5bfSmrg echo "<$perl_URL>" 125a733a5bfSmrg ;; 126a733a5bfSmrg esac 127a733a5bfSmrg} 128a733a5bfSmrg 129a733a5bfSmrggive_advice () 130a733a5bfSmrg{ 131a733a5bfSmrg # Normalize program name to check for. 132a733a5bfSmrg normalized_program=`echo "$1" | sed ' 133a733a5bfSmrg s/^gnu-//; t 134a733a5bfSmrg s/^gnu//; t 135a733a5bfSmrg s/^g//; t'` 136a733a5bfSmrg 137a733a5bfSmrg printf '%s\n' "'$1' is $msg." 138a733a5bfSmrg 139a733a5bfSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140a733a5bfSmrg case $normalized_program in 141a733a5bfSmrg autoconf*) 142a733a5bfSmrg echo "You should only need it if you modified 'configure.ac'," 143a733a5bfSmrg echo "or m4 files included by it." 144a733a5bfSmrg program_details 'autoconf' 145a733a5bfSmrg ;; 146a733a5bfSmrg autoheader*) 147a733a5bfSmrg echo "You should only need it if you modified 'acconfig.h' or" 148a733a5bfSmrg echo "$configure_deps." 149a733a5bfSmrg program_details 'autoheader' 150a733a5bfSmrg ;; 151a733a5bfSmrg automake*) 152a733a5bfSmrg echo "You should only need it if you modified 'Makefile.am' or" 153a733a5bfSmrg echo "$configure_deps." 154a733a5bfSmrg program_details 'automake' 155a733a5bfSmrg ;; 156a733a5bfSmrg aclocal*) 157a733a5bfSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158a733a5bfSmrg echo "$configure_deps." 159a733a5bfSmrg program_details 'aclocal' 160a733a5bfSmrg ;; 161a733a5bfSmrg autom4te*) 162a733a5bfSmrg echo "You might have modified some maintainer files that require" 1631b983734Smrg echo "the 'autom4te' program to be rebuilt." 164a733a5bfSmrg program_details 'autom4te' 165a733a5bfSmrg ;; 166a733a5bfSmrg bison*|yacc*) 167a733a5bfSmrg echo "You should only need it if you modified a '.y' file." 168a733a5bfSmrg echo "You may want to install the GNU Bison package:" 169a733a5bfSmrg echo "<$gnu_software_URL/bison/>" 170a733a5bfSmrg ;; 171a733a5bfSmrg lex*|flex*) 172a733a5bfSmrg echo "You should only need it if you modified a '.l' file." 173a733a5bfSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174a733a5bfSmrg echo "<$flex_URL>" 175a733a5bfSmrg ;; 176a733a5bfSmrg help2man*) 177a733a5bfSmrg echo "You should only need it if you modified a dependency" \ 178a733a5bfSmrg "of a man page." 179a733a5bfSmrg echo "You may want to install the GNU Help2man package:" 180a733a5bfSmrg echo "<$gnu_software_URL/help2man/>" 181a733a5bfSmrg ;; 182a733a5bfSmrg makeinfo*) 183a733a5bfSmrg echo "You should only need it if you modified a '.texi' file, or" 184a733a5bfSmrg echo "any other file indirectly affecting the aspect of the manual." 185a733a5bfSmrg echo "You might want to install the Texinfo package:" 186a733a5bfSmrg echo "<$gnu_software_URL/texinfo/>" 187a733a5bfSmrg echo "The spurious makeinfo call might also be the consequence of" 188a733a5bfSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189a733a5bfSmrg echo "want to install GNU make:" 190a733a5bfSmrg echo "<$gnu_software_URL/make/>" 191a733a5bfSmrg ;; 192a733a5bfSmrg *) 193a733a5bfSmrg echo "You might have modified some files without having the proper" 194a733a5bfSmrg echo "tools for further handling them. Check the 'README' file, it" 195a733a5bfSmrg echo "often tells you about the needed prerequisites for installing" 196a733a5bfSmrg echo "this package. You may also peek at any GNU archive site, in" 197a733a5bfSmrg echo "case some other package contains this missing '$1' program." 198a733a5bfSmrg ;; 199a733a5bfSmrg esac 200a733a5bfSmrg} 201a733a5bfSmrg 202a733a5bfSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203a733a5bfSmrg -e '2,$s/^/ /' >&2 204a733a5bfSmrg 205a733a5bfSmrg# Propagate the correct exit status (expected to be 127 for a program 206a733a5bfSmrg# not found, 63 for a program that failed due to version mismatch). 207a733a5bfSmrgexit $st 2081a30de1fSmrg 2091a30de1fSmrg# Local variables: 2106eaa481cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2111a30de1fSmrg# time-stamp-start: "scriptversion=" 2121a30de1fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2136eaa481cSmrg# time-stamp-time-zone: "UTC0" 214b7fb5eacSmrg# time-stamp-end: "; # UTC" 2151a30de1fSmrg# End: 216