1b7d53ee5Smrg#! /bin/sh 287402a6fSmrg# Common wrapper for a few potentially missing GNU programs. 32ceb2653Smrg 487402a6fSmrgscriptversion=2018-03-07.03; # UTC 52ceb2653Smrg 687402a6fSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 787402a6fSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8b7d53ee5Smrg 9b7d53ee5Smrg# This program is free software; you can redistribute it and/or modify 10b7d53ee5Smrg# it under the terms of the GNU General Public License as published by 11b7d53ee5Smrg# the Free Software Foundation; either version 2, or (at your option) 12b7d53ee5Smrg# any later version. 13b7d53ee5Smrg 14b7d53ee5Smrg# This program is distributed in the hope that it will be useful, 15b7d53ee5Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16b7d53ee5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17b7d53ee5Smrg# GNU General Public License for more details. 18b7d53ee5Smrg 19b7d53ee5Smrg# You should have received a copy of the GNU General Public License 2087402a6fSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21b7d53ee5Smrg 22b7d53ee5Smrg# As a special exception to the GNU General Public License, if you 23b7d53ee5Smrg# distribute this file as part of a program that contains a 24b7d53ee5Smrg# configuration script generated by Autoconf, you may include it under 25b7d53ee5Smrg# the same distribution terms that you use for the rest of that program. 26b7d53ee5Smrg 27b7d53ee5Smrgif test $# -eq 0; then 2887402a6fSmrg echo 1>&2 "Try '$0 --help' for more information" 29b7d53ee5Smrg exit 1 30b7d53ee5Smrgfi 31b7d53ee5Smrg 3287402a6fSmrgcase $1 in 33b7d53ee5Smrg 3487402a6fSmrg --is-lightweight) 3587402a6fSmrg # Used by our autoconf macros to check whether the available missing 3687402a6fSmrg # script is modern enough. 3787402a6fSmrg exit 0 3887402a6fSmrg ;; 392ceb2653Smrg 4087402a6fSmrg --run) 4187402a6fSmrg # Back-compat with the calling convention used by older automake. 4287402a6fSmrg shift 4387402a6fSmrg ;; 44b7d53ee5Smrg 45b7d53ee5Smrg -h|--h|--he|--hel|--help) 46b7d53ee5Smrg echo "\ 47b7d53ee5Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48b7d53ee5Smrg 4987402a6fSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5087402a6fSmrgto PROGRAM being missing or too old. 51b7d53ee5Smrg 52b7d53ee5SmrgOptions: 53b7d53ee5Smrg -h, --help display this help and exit 54b7d53ee5Smrg -v, --version output version information and exit 55b7d53ee5Smrg 56b7d53ee5SmrgSupported PROGRAM values: 5787402a6fSmrg aclocal autoconf autoheader autom4te automake makeinfo 5887402a6fSmrg bison yacc flex lex help2man 592ceb2653Smrg 6087402a6fSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6187402a6fSmrg'g' are ignored when checking the name. 622ceb2653Smrg 632ceb2653SmrgSend bug reports to <bug-automake@gnu.org>." 642ceb2653Smrg exit $? 65b7d53ee5Smrg ;; 66b7d53ee5Smrg 67b7d53ee5Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 682ceb2653Smrg echo "missing $scriptversion (GNU Automake)" 692ceb2653Smrg exit $? 70b7d53ee5Smrg ;; 71b7d53ee5Smrg 72b7d53ee5Smrg -*) 7387402a6fSmrg echo 1>&2 "$0: unknown '$1' option" 7487402a6fSmrg echo 1>&2 "Try '$0 --help' for more information" 75b7d53ee5Smrg exit 1 76b7d53ee5Smrg ;; 77b7d53ee5Smrg 782ceb2653Smrgesac 792ceb2653Smrg 8087402a6fSmrg# Run the given program, remember its exit status. 8187402a6fSmrg"$@"; st=$? 8287402a6fSmrg 8387402a6fSmrg# If it succeeded, we are done. 8487402a6fSmrgtest $st -eq 0 && exit 0 8587402a6fSmrg 8687402a6fSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 8787402a6fSmrg# passed; such an option is passed most likely to detect whether the 8887402a6fSmrg# program is present and works. 8987402a6fSmrgcase $2 in --version|--help) exit $st;; esac 9087402a6fSmrg 9187402a6fSmrg# Exit code 63 means version mismatch. This often happens when the user 9287402a6fSmrg# tries to use an ancient version of a tool on a file that requires a 9387402a6fSmrg# minimum version. 9487402a6fSmrgif test $st -eq 63; then 9587402a6fSmrg msg="probably too old" 9687402a6fSmrgelif test $st -eq 127; then 9787402a6fSmrg # Program was missing. 9887402a6fSmrg msg="missing on your system" 9987402a6fSmrgelse 10087402a6fSmrg # Program was found and executed, but failed. Give up. 10187402a6fSmrg exit $st 10287402a6fSmrgfi 103b7d53ee5Smrg 10487402a6fSmrgperl_URL=https://www.perl.org/ 10587402a6fSmrgflex_URL=https://github.com/westes/flex 10687402a6fSmrggnu_software_URL=https://www.gnu.org/software 10787402a6fSmrg 10887402a6fSmrgprogram_details () 10987402a6fSmrg{ 11087402a6fSmrg case $1 in 11187402a6fSmrg aclocal|automake) 11287402a6fSmrg echo "The '$1' program is part of the GNU Automake package:" 11387402a6fSmrg echo "<$gnu_software_URL/automake>" 11487402a6fSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11587402a6fSmrg echo "<$gnu_software_URL/autoconf>" 11687402a6fSmrg echo "<$gnu_software_URL/m4/>" 11787402a6fSmrg echo "<$perl_URL>" 11887402a6fSmrg ;; 11987402a6fSmrg autoconf|autom4te|autoheader) 12087402a6fSmrg echo "The '$1' program is part of the GNU Autoconf package:" 12187402a6fSmrg echo "<$gnu_software_URL/autoconf/>" 12287402a6fSmrg echo "It also requires GNU m4 and Perl in order to run:" 12387402a6fSmrg echo "<$gnu_software_URL/m4/>" 12487402a6fSmrg echo "<$perl_URL>" 12587402a6fSmrg ;; 12687402a6fSmrg esac 12787402a6fSmrg} 12887402a6fSmrg 12987402a6fSmrggive_advice () 13087402a6fSmrg{ 13187402a6fSmrg # Normalize program name to check for. 13287402a6fSmrg normalized_program=`echo "$1" | sed ' 13387402a6fSmrg s/^gnu-//; t 13487402a6fSmrg s/^gnu//; t 13587402a6fSmrg s/^g//; t'` 13687402a6fSmrg 13787402a6fSmrg printf '%s\n' "'$1' is $msg." 13887402a6fSmrg 13987402a6fSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14087402a6fSmrg case $normalized_program in 14187402a6fSmrg autoconf*) 14287402a6fSmrg echo "You should only need it if you modified 'configure.ac'," 14387402a6fSmrg echo "or m4 files included by it." 14487402a6fSmrg program_details 'autoconf' 14587402a6fSmrg ;; 14687402a6fSmrg autoheader*) 14787402a6fSmrg echo "You should only need it if you modified 'acconfig.h' or" 14887402a6fSmrg echo "$configure_deps." 14987402a6fSmrg program_details 'autoheader' 15087402a6fSmrg ;; 15187402a6fSmrg automake*) 15287402a6fSmrg echo "You should only need it if you modified 'Makefile.am' or" 15387402a6fSmrg echo "$configure_deps." 15487402a6fSmrg program_details 'automake' 15587402a6fSmrg ;; 15687402a6fSmrg aclocal*) 15787402a6fSmrg echo "You should only need it if you modified 'acinclude.m4' or" 15887402a6fSmrg echo "$configure_deps." 15987402a6fSmrg program_details 'aclocal' 16087402a6fSmrg ;; 16187402a6fSmrg autom4te*) 16287402a6fSmrg echo "You might have modified some maintainer files that require" 16387402a6fSmrg echo "the 'autom4te' program to be rebuilt." 16487402a6fSmrg program_details 'autom4te' 16587402a6fSmrg ;; 16687402a6fSmrg bison*|yacc*) 16787402a6fSmrg echo "You should only need it if you modified a '.y' file." 16887402a6fSmrg echo "You may want to install the GNU Bison package:" 16987402a6fSmrg echo "<$gnu_software_URL/bison/>" 17087402a6fSmrg ;; 17187402a6fSmrg lex*|flex*) 17287402a6fSmrg echo "You should only need it if you modified a '.l' file." 17387402a6fSmrg echo "You may want to install the Fast Lexical Analyzer package:" 17487402a6fSmrg echo "<$flex_URL>" 17587402a6fSmrg ;; 17687402a6fSmrg help2man*) 17787402a6fSmrg echo "You should only need it if you modified a dependency" \ 17887402a6fSmrg "of a man page." 17987402a6fSmrg echo "You may want to install the GNU Help2man package:" 18087402a6fSmrg echo "<$gnu_software_URL/help2man/>" 18187402a6fSmrg ;; 18287402a6fSmrg makeinfo*) 18387402a6fSmrg echo "You should only need it if you modified a '.texi' file, or" 18487402a6fSmrg echo "any other file indirectly affecting the aspect of the manual." 18587402a6fSmrg echo "You might want to install the Texinfo package:" 18687402a6fSmrg echo "<$gnu_software_URL/texinfo/>" 18787402a6fSmrg echo "The spurious makeinfo call might also be the consequence of" 18887402a6fSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18987402a6fSmrg echo "want to install GNU make:" 19087402a6fSmrg echo "<$gnu_software_URL/make/>" 19187402a6fSmrg ;; 19287402a6fSmrg *) 19387402a6fSmrg echo "You might have modified some files without having the proper" 19487402a6fSmrg echo "tools for further handling them. Check the 'README' file, it" 19587402a6fSmrg echo "often tells you about the needed prerequisites for installing" 19687402a6fSmrg echo "this package. You may also peek at any GNU archive site, in" 19787402a6fSmrg echo "case some other package contains this missing '$1' program." 19887402a6fSmrg ;; 19987402a6fSmrg esac 20087402a6fSmrg} 20187402a6fSmrg 20287402a6fSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20387402a6fSmrg -e '2,$s/^/ /' >&2 20487402a6fSmrg 20587402a6fSmrg# Propagate the correct exit status (expected to be 127 for a program 20687402a6fSmrg# not found, 63 for a program that failed due to version mismatch). 20787402a6fSmrgexit $st 2082ceb2653Smrg 2092ceb2653Smrg# Local variables: 21087402a6fSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2112ceb2653Smrg# time-stamp-start: "scriptversion=" 2122ceb2653Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 21387402a6fSmrg# time-stamp-time-zone: "UTC0" 2142ceb2653Smrg# time-stamp-end: "; # UTC" 2152ceb2653Smrg# End: 216