166fe65f6Smrg#! /bin/sh 2c6a6acfbSmrg# Common wrapper for a few potentially missing GNU programs. 366fe65f6Smrg 4bc77032bSmrgscriptversion=2018-03-07.03; # UTC 566fe65f6Smrg 6bc77032bSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7c6a6acfbSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 866fe65f6Smrg 966fe65f6Smrg# This program is free software; you can redistribute it and/or modify 1066fe65f6Smrg# it under the terms of the GNU General Public License as published by 1166fe65f6Smrg# the Free Software Foundation; either version 2, or (at your option) 1266fe65f6Smrg# any later version. 1366fe65f6Smrg 1466fe65f6Smrg# This program is distributed in the hope that it will be useful, 1566fe65f6Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1666fe65f6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1766fe65f6Smrg# GNU General Public License for more details. 1866fe65f6Smrg 1966fe65f6Smrg# You should have received a copy of the GNU General Public License 20bc77032bSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2166fe65f6Smrg 2266fe65f6Smrg# As a special exception to the GNU General Public License, if you 2366fe65f6Smrg# distribute this file as part of a program that contains a 2466fe65f6Smrg# configuration script generated by Autoconf, you may include it under 2566fe65f6Smrg# the same distribution terms that you use for the rest of that program. 2666fe65f6Smrg 2766fe65f6Smrgif test $# -eq 0; then 28c6a6acfbSmrg echo 1>&2 "Try '$0 --help' for more information" 2966fe65f6Smrg exit 1 3066fe65f6Smrgfi 3166fe65f6Smrg 32c6a6acfbSmrgcase $1 in 3366fe65f6Smrg 34c6a6acfbSmrg --is-lightweight) 35c6a6acfbSmrg # Used by our autoconf macros to check whether the available missing 36c6a6acfbSmrg # script is modern enough. 37c6a6acfbSmrg exit 0 38c6a6acfbSmrg ;; 3966fe65f6Smrg 40c6a6acfbSmrg --run) 41c6a6acfbSmrg # Back-compat with the calling convention used by older automake. 42c6a6acfbSmrg shift 43c6a6acfbSmrg ;; 4466fe65f6Smrg 4566fe65f6Smrg -h|--h|--he|--hel|--help) 4666fe65f6Smrg echo "\ 4766fe65f6Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4866fe65f6Smrg 49c6a6acfbSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50c6a6acfbSmrgto PROGRAM being missing or too old. 5166fe65f6Smrg 5266fe65f6SmrgOptions: 5366fe65f6Smrg -h, --help display this help and exit 5466fe65f6Smrg -v, --version output version information and exit 5566fe65f6Smrg 5666fe65f6SmrgSupported PROGRAM values: 57c6a6acfbSmrg aclocal autoconf autoheader autom4te automake makeinfo 58c6a6acfbSmrg bison yacc flex lex help2man 5966fe65f6Smrg 60c6a6acfbSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61c6a6acfbSmrg'g' are ignored when checking the name. 62a9274bcdSmrg 6366fe65f6SmrgSend bug reports to <bug-automake@gnu.org>." 6466fe65f6Smrg exit $? 6566fe65f6Smrg ;; 6666fe65f6Smrg 6766fe65f6Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6866fe65f6Smrg echo "missing $scriptversion (GNU Automake)" 6966fe65f6Smrg exit $? 7066fe65f6Smrg ;; 7166fe65f6Smrg 7266fe65f6Smrg -*) 73c6a6acfbSmrg echo 1>&2 "$0: unknown '$1' option" 74c6a6acfbSmrg echo 1>&2 "Try '$0 --help' for more information" 7566fe65f6Smrg exit 1 7666fe65f6Smrg ;; 7766fe65f6Smrg 7866fe65f6Smrgesac 7966fe65f6Smrg 80c6a6acfbSmrg# Run the given program, remember its exit status. 81c6a6acfbSmrg"$@"; st=$? 82c6a6acfbSmrg 83c6a6acfbSmrg# If it succeeded, we are done. 84c6a6acfbSmrgtest $st -eq 0 && exit 0 85c6a6acfbSmrg 86c6a6acfbSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87c6a6acfbSmrg# passed; such an option is passed most likely to detect whether the 88c6a6acfbSmrg# program is present and works. 89c6a6acfbSmrgcase $2 in --version|--help) exit $st;; esac 90c6a6acfbSmrg 91c6a6acfbSmrg# Exit code 63 means version mismatch. This often happens when the user 92c6a6acfbSmrg# tries to use an ancient version of a tool on a file that requires a 93c6a6acfbSmrg# minimum version. 94c6a6acfbSmrgif test $st -eq 63; then 95c6a6acfbSmrg msg="probably too old" 96c6a6acfbSmrgelif test $st -eq 127; then 97c6a6acfbSmrg # Program was missing. 98c6a6acfbSmrg msg="missing on your system" 99c6a6acfbSmrgelse 100c6a6acfbSmrg # Program was found and executed, but failed. Give up. 101c6a6acfbSmrg exit $st 102c6a6acfbSmrgfi 10366fe65f6Smrg 104bc77032bSmrgperl_URL=https://www.perl.org/ 105bc77032bSmrgflex_URL=https://github.com/westes/flex 106bc77032bSmrggnu_software_URL=https://www.gnu.org/software 107c6a6acfbSmrg 108c6a6acfbSmrgprogram_details () 109c6a6acfbSmrg{ 110c6a6acfbSmrg case $1 in 111c6a6acfbSmrg aclocal|automake) 112c6a6acfbSmrg echo "The '$1' program is part of the GNU Automake package:" 113c6a6acfbSmrg echo "<$gnu_software_URL/automake>" 114c6a6acfbSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115c6a6acfbSmrg echo "<$gnu_software_URL/autoconf>" 116c6a6acfbSmrg echo "<$gnu_software_URL/m4/>" 117c6a6acfbSmrg echo "<$perl_URL>" 118c6a6acfbSmrg ;; 119c6a6acfbSmrg autoconf|autom4te|autoheader) 120c6a6acfbSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121c6a6acfbSmrg echo "<$gnu_software_URL/autoconf/>" 122c6a6acfbSmrg echo "It also requires GNU m4 and Perl in order to run:" 123c6a6acfbSmrg echo "<$gnu_software_URL/m4/>" 124c6a6acfbSmrg echo "<$perl_URL>" 125c6a6acfbSmrg ;; 126c6a6acfbSmrg esac 127c6a6acfbSmrg} 128c6a6acfbSmrg 129c6a6acfbSmrggive_advice () 130c6a6acfbSmrg{ 131c6a6acfbSmrg # Normalize program name to check for. 132c6a6acfbSmrg normalized_program=`echo "$1" | sed ' 133c6a6acfbSmrg s/^gnu-//; t 134c6a6acfbSmrg s/^gnu//; t 135c6a6acfbSmrg s/^g//; t'` 136c6a6acfbSmrg 137c6a6acfbSmrg printf '%s\n' "'$1' is $msg." 138c6a6acfbSmrg 139c6a6acfbSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140c6a6acfbSmrg case $normalized_program in 141c6a6acfbSmrg autoconf*) 142c6a6acfbSmrg echo "You should only need it if you modified 'configure.ac'," 143c6a6acfbSmrg echo "or m4 files included by it." 144c6a6acfbSmrg program_details 'autoconf' 145c6a6acfbSmrg ;; 146c6a6acfbSmrg autoheader*) 147c6a6acfbSmrg echo "You should only need it if you modified 'acconfig.h' or" 148c6a6acfbSmrg echo "$configure_deps." 149c6a6acfbSmrg program_details 'autoheader' 150c6a6acfbSmrg ;; 151c6a6acfbSmrg automake*) 152c6a6acfbSmrg echo "You should only need it if you modified 'Makefile.am' or" 153c6a6acfbSmrg echo "$configure_deps." 154c6a6acfbSmrg program_details 'automake' 155c6a6acfbSmrg ;; 156c6a6acfbSmrg aclocal*) 157c6a6acfbSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158c6a6acfbSmrg echo "$configure_deps." 159c6a6acfbSmrg program_details 'aclocal' 160c6a6acfbSmrg ;; 161c6a6acfbSmrg autom4te*) 162c6a6acfbSmrg echo "You might have modified some maintainer files that require" 163c6a6acfbSmrg echo "the 'autom4te' program to be rebuilt." 164c6a6acfbSmrg program_details 'autom4te' 165c6a6acfbSmrg ;; 166c6a6acfbSmrg bison*|yacc*) 167c6a6acfbSmrg echo "You should only need it if you modified a '.y' file." 168c6a6acfbSmrg echo "You may want to install the GNU Bison package:" 169c6a6acfbSmrg echo "<$gnu_software_URL/bison/>" 170c6a6acfbSmrg ;; 171c6a6acfbSmrg lex*|flex*) 172c6a6acfbSmrg echo "You should only need it if you modified a '.l' file." 173c6a6acfbSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174c6a6acfbSmrg echo "<$flex_URL>" 175c6a6acfbSmrg ;; 176c6a6acfbSmrg help2man*) 177c6a6acfbSmrg echo "You should only need it if you modified a dependency" \ 178c6a6acfbSmrg "of a man page." 179c6a6acfbSmrg echo "You may want to install the GNU Help2man package:" 180c6a6acfbSmrg echo "<$gnu_software_URL/help2man/>" 181c6a6acfbSmrg ;; 182c6a6acfbSmrg makeinfo*) 183c6a6acfbSmrg echo "You should only need it if you modified a '.texi' file, or" 184c6a6acfbSmrg echo "any other file indirectly affecting the aspect of the manual." 185c6a6acfbSmrg echo "You might want to install the Texinfo package:" 186c6a6acfbSmrg echo "<$gnu_software_URL/texinfo/>" 187c6a6acfbSmrg echo "The spurious makeinfo call might also be the consequence of" 188c6a6acfbSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189c6a6acfbSmrg echo "want to install GNU make:" 190c6a6acfbSmrg echo "<$gnu_software_URL/make/>" 191c6a6acfbSmrg ;; 192c6a6acfbSmrg *) 193c6a6acfbSmrg echo "You might have modified some files without having the proper" 194c6a6acfbSmrg echo "tools for further handling them. Check the 'README' file, it" 195c6a6acfbSmrg echo "often tells you about the needed prerequisites for installing" 196c6a6acfbSmrg echo "this package. You may also peek at any GNU archive site, in" 197c6a6acfbSmrg echo "case some other package contains this missing '$1' program." 198c6a6acfbSmrg ;; 199c6a6acfbSmrg esac 200c6a6acfbSmrg} 201c6a6acfbSmrg 202c6a6acfbSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203c6a6acfbSmrg -e '2,$s/^/ /' >&2 204c6a6acfbSmrg 205c6a6acfbSmrg# Propagate the correct exit status (expected to be 127 for a program 206c6a6acfbSmrg# not found, 63 for a program that failed due to version mismatch). 207c6a6acfbSmrgexit $st 20866fe65f6Smrg 20966fe65f6Smrg# Local variables: 210bc77032bSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 21166fe65f6Smrg# time-stamp-start: "scriptversion=" 21266fe65f6Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213bc77032bSmrg# time-stamp-time-zone: "UTC0" 214a9274bcdSmrg# time-stamp-end: "; # UTC" 21566fe65f6Smrg# End: 216