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