14fb28925Smrg#! /bin/sh 2df58931aSmrg# Common wrapper for a few potentially missing GNU programs. 3b66d1acbSmrg 41c145c9fSmrgscriptversion=2018-03-07.03; # UTC 5b66d1acbSmrg 61c145c9fSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7df58931aSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 84fb28925Smrg 94fb28925Smrg# This program is free software; you can redistribute it and/or modify 104fb28925Smrg# it under the terms of the GNU General Public License as published by 114fb28925Smrg# the Free Software Foundation; either version 2, or (at your option) 124fb28925Smrg# any later version. 134fb28925Smrg 144fb28925Smrg# This program is distributed in the hope that it will be useful, 154fb28925Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 164fb28925Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 174fb28925Smrg# GNU General Public License for more details. 184fb28925Smrg 194fb28925Smrg# You should have received a copy of the GNU General Public License 201c145c9fSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 214fb28925Smrg 224fb28925Smrg# As a special exception to the GNU General Public License, if you 234fb28925Smrg# distribute this file as part of a program that contains a 244fb28925Smrg# configuration script generated by Autoconf, you may include it under 254fb28925Smrg# the same distribution terms that you use for the rest of that program. 264fb28925Smrg 274fb28925Smrgif test $# -eq 0; then 28df58931aSmrg echo 1>&2 "Try '$0 --help' for more information" 294fb28925Smrg exit 1 304fb28925Smrgfi 314fb28925Smrg 32df58931aSmrgcase $1 in 334fb28925Smrg 34df58931aSmrg --is-lightweight) 35df58931aSmrg # Used by our autoconf macros to check whether the available missing 36df58931aSmrg # script is modern enough. 37df58931aSmrg exit 0 38df58931aSmrg ;; 39b66d1acbSmrg 40df58931aSmrg --run) 41df58931aSmrg # Back-compat with the calling convention used by older automake. 42df58931aSmrg shift 43df58931aSmrg ;; 444fb28925Smrg 454fb28925Smrg -h|--h|--he|--hel|--help) 464fb28925Smrg echo "\ 474fb28925Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 484fb28925Smrg 49df58931aSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50df58931aSmrgto PROGRAM being missing or too old. 514fb28925Smrg 524fb28925SmrgOptions: 534fb28925Smrg -h, --help display this help and exit 544fb28925Smrg -v, --version output version information and exit 554fb28925Smrg 564fb28925SmrgSupported PROGRAM values: 57df58931aSmrg aclocal autoconf autoheader autom4te automake makeinfo 58df58931aSmrg bison yacc flex lex help2man 59b66d1acbSmrg 60df58931aSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61df58931aSmrg'g' are ignored when checking the name. 62b66d1acbSmrg 63b66d1acbSmrgSend bug reports to <bug-automake@gnu.org>." 64b66d1acbSmrg exit $? 654fb28925Smrg ;; 664fb28925Smrg 674fb28925Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68b66d1acbSmrg echo "missing $scriptversion (GNU Automake)" 69b66d1acbSmrg exit $? 704fb28925Smrg ;; 714fb28925Smrg 724fb28925Smrg -*) 73df58931aSmrg echo 1>&2 "$0: unknown '$1' option" 74df58931aSmrg echo 1>&2 "Try '$0 --help' for more information" 754fb28925Smrg exit 1 764fb28925Smrg ;; 774fb28925Smrg 78b66d1acbSmrgesac 79b66d1acbSmrg 80df58931aSmrg# Run the given program, remember its exit status. 81df58931aSmrg"$@"; st=$? 82df58931aSmrg 83df58931aSmrg# If it succeeded, we are done. 84df58931aSmrgtest $st -eq 0 && exit 0 85df58931aSmrg 86df58931aSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87df58931aSmrg# passed; such an option is passed most likely to detect whether the 88df58931aSmrg# program is present and works. 89df58931aSmrgcase $2 in --version|--help) exit $st;; esac 90df58931aSmrg 91df58931aSmrg# Exit code 63 means version mismatch. This often happens when the user 92df58931aSmrg# tries to use an ancient version of a tool on a file that requires a 93df58931aSmrg# minimum version. 94df58931aSmrgif test $st -eq 63; then 95df58931aSmrg msg="probably too old" 96df58931aSmrgelif test $st -eq 127; then 97df58931aSmrg # Program was missing. 98df58931aSmrg msg="missing on your system" 99df58931aSmrgelse 100df58931aSmrg # Program was found and executed, but failed. Give up. 101df58931aSmrg exit $st 102df58931aSmrgfi 1034fb28925Smrg 1041c145c9fSmrgperl_URL=https://www.perl.org/ 1051c145c9fSmrgflex_URL=https://github.com/westes/flex 1061c145c9fSmrggnu_software_URL=https://www.gnu.org/software 107df58931aSmrg 108df58931aSmrgprogram_details () 109df58931aSmrg{ 110df58931aSmrg case $1 in 111df58931aSmrg aclocal|automake) 112df58931aSmrg echo "The '$1' program is part of the GNU Automake package:" 113df58931aSmrg echo "<$gnu_software_URL/automake>" 114df58931aSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115df58931aSmrg echo "<$gnu_software_URL/autoconf>" 116df58931aSmrg echo "<$gnu_software_URL/m4/>" 117df58931aSmrg echo "<$perl_URL>" 118df58931aSmrg ;; 119df58931aSmrg autoconf|autom4te|autoheader) 120df58931aSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121df58931aSmrg echo "<$gnu_software_URL/autoconf/>" 122df58931aSmrg echo "It also requires GNU m4 and Perl in order to run:" 123df58931aSmrg echo "<$gnu_software_URL/m4/>" 124df58931aSmrg echo "<$perl_URL>" 125df58931aSmrg ;; 126df58931aSmrg esac 127df58931aSmrg} 128df58931aSmrg 129df58931aSmrggive_advice () 130df58931aSmrg{ 131df58931aSmrg # Normalize program name to check for. 132df58931aSmrg normalized_program=`echo "$1" | sed ' 133df58931aSmrg s/^gnu-//; t 134df58931aSmrg s/^gnu//; t 135df58931aSmrg s/^g//; t'` 136df58931aSmrg 137df58931aSmrg printf '%s\n' "'$1' is $msg." 138df58931aSmrg 139df58931aSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140df58931aSmrg case $normalized_program in 141df58931aSmrg autoconf*) 142df58931aSmrg echo "You should only need it if you modified 'configure.ac'," 143df58931aSmrg echo "or m4 files included by it." 144df58931aSmrg program_details 'autoconf' 145df58931aSmrg ;; 146df58931aSmrg autoheader*) 147df58931aSmrg echo "You should only need it if you modified 'acconfig.h' or" 148df58931aSmrg echo "$configure_deps." 149df58931aSmrg program_details 'autoheader' 150df58931aSmrg ;; 151df58931aSmrg automake*) 152df58931aSmrg echo "You should only need it if you modified 'Makefile.am' or" 153df58931aSmrg echo "$configure_deps." 154df58931aSmrg program_details 'automake' 155df58931aSmrg ;; 156df58931aSmrg aclocal*) 157df58931aSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158df58931aSmrg echo "$configure_deps." 159df58931aSmrg program_details 'aclocal' 160df58931aSmrg ;; 161df58931aSmrg autom4te*) 162df58931aSmrg echo "You might have modified some maintainer files that require" 1634929c8f8Smrg echo "the 'autom4te' program to be rebuilt." 164df58931aSmrg program_details 'autom4te' 165df58931aSmrg ;; 166df58931aSmrg bison*|yacc*) 167df58931aSmrg echo "You should only need it if you modified a '.y' file." 168df58931aSmrg echo "You may want to install the GNU Bison package:" 169df58931aSmrg echo "<$gnu_software_URL/bison/>" 170df58931aSmrg ;; 171df58931aSmrg lex*|flex*) 172df58931aSmrg echo "You should only need it if you modified a '.l' file." 173df58931aSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174df58931aSmrg echo "<$flex_URL>" 175df58931aSmrg ;; 176df58931aSmrg help2man*) 177df58931aSmrg echo "You should only need it if you modified a dependency" \ 178df58931aSmrg "of a man page." 179df58931aSmrg echo "You may want to install the GNU Help2man package:" 180df58931aSmrg echo "<$gnu_software_URL/help2man/>" 181df58931aSmrg ;; 182df58931aSmrg makeinfo*) 183df58931aSmrg echo "You should only need it if you modified a '.texi' file, or" 184df58931aSmrg echo "any other file indirectly affecting the aspect of the manual." 185df58931aSmrg echo "You might want to install the Texinfo package:" 186df58931aSmrg echo "<$gnu_software_URL/texinfo/>" 187df58931aSmrg echo "The spurious makeinfo call might also be the consequence of" 188df58931aSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189df58931aSmrg echo "want to install GNU make:" 190df58931aSmrg echo "<$gnu_software_URL/make/>" 191df58931aSmrg ;; 192df58931aSmrg *) 193df58931aSmrg echo "You might have modified some files without having the proper" 194df58931aSmrg echo "tools for further handling them. Check the 'README' file, it" 195df58931aSmrg echo "often tells you about the needed prerequisites for installing" 196df58931aSmrg echo "this package. You may also peek at any GNU archive site, in" 197df58931aSmrg echo "case some other package contains this missing '$1' program." 198df58931aSmrg ;; 199df58931aSmrg esac 200df58931aSmrg} 201df58931aSmrg 202df58931aSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203df58931aSmrg -e '2,$s/^/ /' >&2 204df58931aSmrg 205df58931aSmrg# Propagate the correct exit status (expected to be 127 for a program 206df58931aSmrg# not found, 63 for a program that failed due to version mismatch). 207df58931aSmrgexit $st 208b66d1acbSmrg 209b66d1acbSmrg# Local variables: 2101c145c9fSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 211b66d1acbSmrg# time-stamp-start: "scriptversion=" 212b66d1acbSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2131c145c9fSmrg# time-stamp-time-zone: "UTC0" 214b66d1acbSmrg# time-stamp-end: "; # UTC" 215b66d1acbSmrg# End: 216