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