1fd0c672fSmrg#! /bin/sh 2953c684bSmrg# Common wrapper for a few potentially missing GNU programs. 3fd0c672fSmrg 443ecf206Smrgscriptversion=2018-03-07.03; # UTC 5fd0c672fSmrg 643ecf206Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7953c684bSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8fd0c672fSmrg 9fd0c672fSmrg# This program is free software; you can redistribute it and/or modify 10fd0c672fSmrg# it under the terms of the GNU General Public License as published by 11fd0c672fSmrg# the Free Software Foundation; either version 2, or (at your option) 12fd0c672fSmrg# any later version. 13fd0c672fSmrg 14fd0c672fSmrg# This program is distributed in the hope that it will be useful, 15fd0c672fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16fd0c672fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17fd0c672fSmrg# GNU General Public License for more details. 18fd0c672fSmrg 19fd0c672fSmrg# You should have received a copy of the GNU General Public License 2043ecf206Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21fd0c672fSmrg 22fd0c672fSmrg# As a special exception to the GNU General Public License, if you 23fd0c672fSmrg# distribute this file as part of a program that contains a 24fd0c672fSmrg# configuration script generated by Autoconf, you may include it under 25fd0c672fSmrg# the same distribution terms that you use for the rest of that program. 26fd0c672fSmrg 27fd0c672fSmrgif test $# -eq 0; then 28953c684bSmrg echo 1>&2 "Try '$0 --help' for more information" 29fd0c672fSmrg exit 1 30fd0c672fSmrgfi 31fd0c672fSmrg 32953c684bSmrgcase $1 in 33fd0c672fSmrg 34953c684bSmrg --is-lightweight) 35953c684bSmrg # Used by our autoconf macros to check whether the available missing 36953c684bSmrg # script is modern enough. 37953c684bSmrg exit 0 38953c684bSmrg ;; 39fd0c672fSmrg 40953c684bSmrg --run) 41953c684bSmrg # Back-compat with the calling convention used by older automake. 42953c684bSmrg shift 43953c684bSmrg ;; 44fd0c672fSmrg 45fd0c672fSmrg -h|--h|--he|--hel|--help) 46fd0c672fSmrg echo "\ 47fd0c672fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48fd0c672fSmrg 49953c684bSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50953c684bSmrgto PROGRAM being missing or too old. 51fd0c672fSmrg 52fd0c672fSmrgOptions: 53fd0c672fSmrg -h, --help display this help and exit 54fd0c672fSmrg -v, --version output version information and exit 55fd0c672fSmrg 56fd0c672fSmrgSupported PROGRAM values: 57953c684bSmrg aclocal autoconf autoheader autom4te automake makeinfo 58953c684bSmrg bison yacc flex lex help2man 59fd0c672fSmrg 60953c684bSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61953c684bSmrg'g' are ignored when checking the name. 6248e69166Smrg 63fd0c672fSmrgSend bug reports to <bug-automake@gnu.org>." 64fd0c672fSmrg exit $? 65fd0c672fSmrg ;; 66fd0c672fSmrg 67fd0c672fSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68fd0c672fSmrg echo "missing $scriptversion (GNU Automake)" 69fd0c672fSmrg exit $? 70fd0c672fSmrg ;; 71fd0c672fSmrg 72fd0c672fSmrg -*) 73953c684bSmrg echo 1>&2 "$0: unknown '$1' option" 74953c684bSmrg echo 1>&2 "Try '$0 --help' for more information" 75fd0c672fSmrg exit 1 76fd0c672fSmrg ;; 77fd0c672fSmrg 78fd0c672fSmrgesac 79fd0c672fSmrg 80953c684bSmrg# Run the given program, remember its exit status. 81953c684bSmrg"$@"; st=$? 82953c684bSmrg 83953c684bSmrg# If it succeeded, we are done. 84953c684bSmrgtest $st -eq 0 && exit 0 85953c684bSmrg 86953c684bSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87953c684bSmrg# passed; such an option is passed most likely to detect whether the 88953c684bSmrg# program is present and works. 89953c684bSmrgcase $2 in --version|--help) exit $st;; esac 90953c684bSmrg 91953c684bSmrg# Exit code 63 means version mismatch. This often happens when the user 92953c684bSmrg# tries to use an ancient version of a tool on a file that requires a 93953c684bSmrg# minimum version. 94953c684bSmrgif test $st -eq 63; then 95953c684bSmrg msg="probably too old" 96953c684bSmrgelif test $st -eq 127; then 97953c684bSmrg # Program was missing. 98953c684bSmrg msg="missing on your system" 99953c684bSmrgelse 100953c684bSmrg # Program was found and executed, but failed. Give up. 101953c684bSmrg exit $st 102953c684bSmrgfi 103fd0c672fSmrg 10443ecf206Smrgperl_URL=https://www.perl.org/ 10543ecf206Smrgflex_URL=https://github.com/westes/flex 10643ecf206Smrggnu_software_URL=https://www.gnu.org/software 107953c684bSmrg 108953c684bSmrgprogram_details () 109953c684bSmrg{ 110953c684bSmrg case $1 in 111953c684bSmrg aclocal|automake) 112953c684bSmrg echo "The '$1' program is part of the GNU Automake package:" 113953c684bSmrg echo "<$gnu_software_URL/automake>" 114953c684bSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115953c684bSmrg echo "<$gnu_software_URL/autoconf>" 116953c684bSmrg echo "<$gnu_software_URL/m4/>" 117953c684bSmrg echo "<$perl_URL>" 118953c684bSmrg ;; 119953c684bSmrg autoconf|autom4te|autoheader) 120953c684bSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121953c684bSmrg echo "<$gnu_software_URL/autoconf/>" 122953c684bSmrg echo "It also requires GNU m4 and Perl in order to run:" 123953c684bSmrg echo "<$gnu_software_URL/m4/>" 124953c684bSmrg echo "<$perl_URL>" 125953c684bSmrg ;; 126953c684bSmrg esac 127953c684bSmrg} 128953c684bSmrg 129953c684bSmrggive_advice () 130953c684bSmrg{ 131953c684bSmrg # Normalize program name to check for. 132953c684bSmrg normalized_program=`echo "$1" | sed ' 133953c684bSmrg s/^gnu-//; t 134953c684bSmrg s/^gnu//; t 135953c684bSmrg s/^g//; t'` 136953c684bSmrg 137953c684bSmrg printf '%s\n' "'$1' is $msg." 138953c684bSmrg 139953c684bSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140953c684bSmrg case $normalized_program in 141953c684bSmrg autoconf*) 142953c684bSmrg echo "You should only need it if you modified 'configure.ac'," 143953c684bSmrg echo "or m4 files included by it." 144953c684bSmrg program_details 'autoconf' 145953c684bSmrg ;; 146953c684bSmrg autoheader*) 147953c684bSmrg echo "You should only need it if you modified 'acconfig.h' or" 148953c684bSmrg echo "$configure_deps." 149953c684bSmrg program_details 'autoheader' 150953c684bSmrg ;; 151953c684bSmrg automake*) 152953c684bSmrg echo "You should only need it if you modified 'Makefile.am' or" 153953c684bSmrg echo "$configure_deps." 154953c684bSmrg program_details 'automake' 155953c684bSmrg ;; 156953c684bSmrg aclocal*) 157953c684bSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158953c684bSmrg echo "$configure_deps." 159953c684bSmrg program_details 'aclocal' 160953c684bSmrg ;; 161953c684bSmrg autom4te*) 162953c684bSmrg echo "You might have modified some maintainer files that require" 1638846b520Smrg echo "the 'autom4te' program to be rebuilt." 164953c684bSmrg program_details 'autom4te' 165953c684bSmrg ;; 166953c684bSmrg bison*|yacc*) 167953c684bSmrg echo "You should only need it if you modified a '.y' file." 168953c684bSmrg echo "You may want to install the GNU Bison package:" 169953c684bSmrg echo "<$gnu_software_URL/bison/>" 170953c684bSmrg ;; 171953c684bSmrg lex*|flex*) 172953c684bSmrg echo "You should only need it if you modified a '.l' file." 173953c684bSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174953c684bSmrg echo "<$flex_URL>" 175953c684bSmrg ;; 176953c684bSmrg help2man*) 177953c684bSmrg echo "You should only need it if you modified a dependency" \ 178953c684bSmrg "of a man page." 179953c684bSmrg echo "You may want to install the GNU Help2man package:" 180953c684bSmrg echo "<$gnu_software_URL/help2man/>" 181953c684bSmrg ;; 182953c684bSmrg makeinfo*) 183953c684bSmrg echo "You should only need it if you modified a '.texi' file, or" 184953c684bSmrg echo "any other file indirectly affecting the aspect of the manual." 185953c684bSmrg echo "You might want to install the Texinfo package:" 186953c684bSmrg echo "<$gnu_software_URL/texinfo/>" 187953c684bSmrg echo "The spurious makeinfo call might also be the consequence of" 188953c684bSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189953c684bSmrg echo "want to install GNU make:" 190953c684bSmrg echo "<$gnu_software_URL/make/>" 191953c684bSmrg ;; 192953c684bSmrg *) 193953c684bSmrg echo "You might have modified some files without having the proper" 194953c684bSmrg echo "tools for further handling them. Check the 'README' file, it" 195953c684bSmrg echo "often tells you about the needed prerequisites for installing" 196953c684bSmrg echo "this package. You may also peek at any GNU archive site, in" 197953c684bSmrg echo "case some other package contains this missing '$1' program." 198953c684bSmrg ;; 199953c684bSmrg esac 200953c684bSmrg} 201953c684bSmrg 202953c684bSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203953c684bSmrg -e '2,$s/^/ /' >&2 204953c684bSmrg 205953c684bSmrg# Propagate the correct exit status (expected to be 127 for a program 206953c684bSmrg# not found, 63 for a program that failed due to version mismatch). 207953c684bSmrgexit $st 208fd0c672fSmrg 209fd0c672fSmrg# Local variables: 21043ecf206Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211fd0c672fSmrg# time-stamp-start: "scriptversion=" 212fd0c672fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 21343ecf206Smrg# time-stamp-time-zone: "UTC0" 21448e69166Smrg# time-stamp-end: "; # UTC" 215fd0c672fSmrg# End: 216