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