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