167f05d30Smrg#! /bin/sh 2e90eff46Smrg# Common wrapper for a few potentially missing GNU programs. 3fffe5102Smrg 4051ceee6Smrgscriptversion=2018-03-07.03; # UTC 5fffe5102Smrg 6051ceee6Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7e90eff46Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 867f05d30Smrg 967f05d30Smrg# This program is free software; you can redistribute it and/or modify 1067f05d30Smrg# it under the terms of the GNU General Public License as published by 1167f05d30Smrg# the Free Software Foundation; either version 2, or (at your option) 1267f05d30Smrg# any later version. 1367f05d30Smrg 1467f05d30Smrg# This program is distributed in the hope that it will be useful, 1567f05d30Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1667f05d30Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1767f05d30Smrg# GNU General Public License for more details. 1867f05d30Smrg 1967f05d30Smrg# You should have received a copy of the GNU General Public License 20051ceee6Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2167f05d30Smrg 2267f05d30Smrg# As a special exception to the GNU General Public License, if you 2367f05d30Smrg# distribute this file as part of a program that contains a 2467f05d30Smrg# configuration script generated by Autoconf, you may include it under 2567f05d30Smrg# the same distribution terms that you use for the rest of that program. 2667f05d30Smrg 2767f05d30Smrgif test $# -eq 0; then 28e90eff46Smrg echo 1>&2 "Try '$0 --help' for more information" 2967f05d30Smrg exit 1 3067f05d30Smrgfi 3167f05d30Smrg 32e90eff46Smrgcase $1 in 3367f05d30Smrg 34e90eff46Smrg --is-lightweight) 35e90eff46Smrg # Used by our autoconf macros to check whether the available missing 36e90eff46Smrg # script is modern enough. 37e90eff46Smrg exit 0 38e90eff46Smrg ;; 39fffe5102Smrg 40e90eff46Smrg --run) 41e90eff46Smrg # Back-compat with the calling convention used by older automake. 42e90eff46Smrg shift 43e90eff46Smrg ;; 4467f05d30Smrg 4567f05d30Smrg -h|--h|--he|--hel|--help) 4667f05d30Smrg echo "\ 4767f05d30Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4867f05d30Smrg 49e90eff46SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50e90eff46Smrgto PROGRAM being missing or too old. 5167f05d30Smrg 5267f05d30SmrgOptions: 5367f05d30Smrg -h, --help display this help and exit 5467f05d30Smrg -v, --version output version information and exit 5567f05d30Smrg 5667f05d30SmrgSupported PROGRAM values: 57e90eff46Smrg aclocal autoconf autoheader autom4te automake makeinfo 58e90eff46Smrg bison yacc flex lex help2man 59fffe5102Smrg 60e90eff46SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61e90eff46Smrg'g' are ignored when checking the name. 62fffe5102Smrg 63fffe5102SmrgSend bug reports to <bug-automake@gnu.org>." 64fffe5102Smrg exit $? 6567f05d30Smrg ;; 6667f05d30Smrg 6767f05d30Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68fffe5102Smrg echo "missing $scriptversion (GNU Automake)" 69fffe5102Smrg exit $? 7067f05d30Smrg ;; 7167f05d30Smrg 7267f05d30Smrg -*) 73e90eff46Smrg echo 1>&2 "$0: unknown '$1' option" 74e90eff46Smrg echo 1>&2 "Try '$0 --help' for more information" 7567f05d30Smrg exit 1 7667f05d30Smrg ;; 7767f05d30Smrg 78fffe5102Smrgesac 79fffe5102Smrg 80e90eff46Smrg# Run the given program, remember its exit status. 81e90eff46Smrg"$@"; st=$? 82e90eff46Smrg 83e90eff46Smrg# If it succeeded, we are done. 84e90eff46Smrgtest $st -eq 0 && exit 0 85e90eff46Smrg 86e90eff46Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87e90eff46Smrg# passed; such an option is passed most likely to detect whether the 88e90eff46Smrg# program is present and works. 89e90eff46Smrgcase $2 in --version|--help) exit $st;; esac 90e90eff46Smrg 91e90eff46Smrg# Exit code 63 means version mismatch. This often happens when the user 92e90eff46Smrg# tries to use an ancient version of a tool on a file that requires a 93e90eff46Smrg# minimum version. 94e90eff46Smrgif test $st -eq 63; then 95e90eff46Smrg msg="probably too old" 96e90eff46Smrgelif test $st -eq 127; then 97e90eff46Smrg # Program was missing. 98e90eff46Smrg msg="missing on your system" 99e90eff46Smrgelse 100e90eff46Smrg # Program was found and executed, but failed. Give up. 101e90eff46Smrg exit $st 102e90eff46Smrgfi 10367f05d30Smrg 104051ceee6Smrgperl_URL=https://www.perl.org/ 105051ceee6Smrgflex_URL=https://github.com/westes/flex 106051ceee6Smrggnu_software_URL=https://www.gnu.org/software 107e90eff46Smrg 108e90eff46Smrgprogram_details () 109e90eff46Smrg{ 110e90eff46Smrg case $1 in 111e90eff46Smrg aclocal|automake) 112e90eff46Smrg echo "The '$1' program is part of the GNU Automake package:" 113e90eff46Smrg echo "<$gnu_software_URL/automake>" 114e90eff46Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115e90eff46Smrg echo "<$gnu_software_URL/autoconf>" 116e90eff46Smrg echo "<$gnu_software_URL/m4/>" 117e90eff46Smrg echo "<$perl_URL>" 118e90eff46Smrg ;; 119e90eff46Smrg autoconf|autom4te|autoheader) 120e90eff46Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121e90eff46Smrg echo "<$gnu_software_URL/autoconf/>" 122e90eff46Smrg echo "It also requires GNU m4 and Perl in order to run:" 123e90eff46Smrg echo "<$gnu_software_URL/m4/>" 124e90eff46Smrg echo "<$perl_URL>" 125e90eff46Smrg ;; 126e90eff46Smrg esac 127e90eff46Smrg} 128e90eff46Smrg 129e90eff46Smrggive_advice () 130e90eff46Smrg{ 131e90eff46Smrg # Normalize program name to check for. 132e90eff46Smrg normalized_program=`echo "$1" | sed ' 133e90eff46Smrg s/^gnu-//; t 134e90eff46Smrg s/^gnu//; t 135e90eff46Smrg s/^g//; t'` 136e90eff46Smrg 137e90eff46Smrg printf '%s\n' "'$1' is $msg." 138e90eff46Smrg 139e90eff46Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140e90eff46Smrg case $normalized_program in 141e90eff46Smrg autoconf*) 142e90eff46Smrg echo "You should only need it if you modified 'configure.ac'," 143e90eff46Smrg echo "or m4 files included by it." 144e90eff46Smrg program_details 'autoconf' 145e90eff46Smrg ;; 146e90eff46Smrg autoheader*) 147e90eff46Smrg echo "You should only need it if you modified 'acconfig.h' or" 148e90eff46Smrg echo "$configure_deps." 149e90eff46Smrg program_details 'autoheader' 150e90eff46Smrg ;; 151e90eff46Smrg automake*) 152e90eff46Smrg echo "You should only need it if you modified 'Makefile.am' or" 153e90eff46Smrg echo "$configure_deps." 154e90eff46Smrg program_details 'automake' 155e90eff46Smrg ;; 156e90eff46Smrg aclocal*) 157e90eff46Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158e90eff46Smrg echo "$configure_deps." 159e90eff46Smrg program_details 'aclocal' 160e90eff46Smrg ;; 161e90eff46Smrg autom4te*) 162e90eff46Smrg echo "You might have modified some maintainer files that require" 163e90eff46Smrg echo "the 'autom4te' program to be rebuilt." 164e90eff46Smrg program_details 'autom4te' 165e90eff46Smrg ;; 166e90eff46Smrg bison*|yacc*) 167e90eff46Smrg echo "You should only need it if you modified a '.y' file." 168e90eff46Smrg echo "You may want to install the GNU Bison package:" 169e90eff46Smrg echo "<$gnu_software_URL/bison/>" 170e90eff46Smrg ;; 171e90eff46Smrg lex*|flex*) 172e90eff46Smrg echo "You should only need it if you modified a '.l' file." 173e90eff46Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174e90eff46Smrg echo "<$flex_URL>" 175e90eff46Smrg ;; 176e90eff46Smrg help2man*) 177e90eff46Smrg echo "You should only need it if you modified a dependency" \ 178e90eff46Smrg "of a man page." 179e90eff46Smrg echo "You may want to install the GNU Help2man package:" 180e90eff46Smrg echo "<$gnu_software_URL/help2man/>" 181e90eff46Smrg ;; 182e90eff46Smrg makeinfo*) 183e90eff46Smrg echo "You should only need it if you modified a '.texi' file, or" 184e90eff46Smrg echo "any other file indirectly affecting the aspect of the manual." 185e90eff46Smrg echo "You might want to install the Texinfo package:" 186e90eff46Smrg echo "<$gnu_software_URL/texinfo/>" 187e90eff46Smrg echo "The spurious makeinfo call might also be the consequence of" 188e90eff46Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189e90eff46Smrg echo "want to install GNU make:" 190e90eff46Smrg echo "<$gnu_software_URL/make/>" 191e90eff46Smrg ;; 192e90eff46Smrg *) 193e90eff46Smrg echo "You might have modified some files without having the proper" 194e90eff46Smrg echo "tools for further handling them. Check the 'README' file, it" 195e90eff46Smrg echo "often tells you about the needed prerequisites for installing" 196e90eff46Smrg echo "this package. You may also peek at any GNU archive site, in" 197e90eff46Smrg echo "case some other package contains this missing '$1' program." 198e90eff46Smrg ;; 199e90eff46Smrg esac 200e90eff46Smrg} 201e90eff46Smrg 202e90eff46Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203e90eff46Smrg -e '2,$s/^/ /' >&2 204e90eff46Smrg 205e90eff46Smrg# Propagate the correct exit status (expected to be 127 for a program 206e90eff46Smrg# not found, 63 for a program that failed due to version mismatch). 207e90eff46Smrgexit $st 208fffe5102Smrg 209fffe5102Smrg# Local variables: 210051ceee6Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211fffe5102Smrg# time-stamp-start: "scriptversion=" 212fffe5102Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213051ceee6Smrg# time-stamp-time-zone: "UTC0" 214fffe5102Smrg# time-stamp-end: "; # UTC" 215fffe5102Smrg# End: 216