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