145bc899bSmrg#! /bin/sh 2c97b1c41Smrg# Common wrapper for a few potentially missing GNU programs. 345bc899bSmrg 4a0c41156Smrgscriptversion=2018-03-07.03; # UTC 545bc899bSmrg 6e8b4ed9fSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7c97b1c41Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 845bc899bSmrg 945bc899bSmrg# This program is free software; you can redistribute it and/or modify 1045bc899bSmrg# it under the terms of the GNU General Public License as published by 1145bc899bSmrg# the Free Software Foundation; either version 2, or (at your option) 1245bc899bSmrg# any later version. 1345bc899bSmrg 1445bc899bSmrg# This program is distributed in the hope that it will be useful, 1545bc899bSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1645bc899bSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1745bc899bSmrg# GNU General Public License for more details. 1845bc899bSmrg 1945bc899bSmrg# You should have received a copy of the GNU General Public License 20a0c41156Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2145bc899bSmrg 2245bc899bSmrg# As a special exception to the GNU General Public License, if you 2345bc899bSmrg# distribute this file as part of a program that contains a 2445bc899bSmrg# configuration script generated by Autoconf, you may include it under 2545bc899bSmrg# the same distribution terms that you use for the rest of that program. 2645bc899bSmrg 2745bc899bSmrgif test $# -eq 0; then 28c97b1c41Smrg echo 1>&2 "Try '$0 --help' for more information" 2945bc899bSmrg exit 1 3045bc899bSmrgfi 3145bc899bSmrg 32c97b1c41Smrgcase $1 in 3345bc899bSmrg 34c97b1c41Smrg --is-lightweight) 35c97b1c41Smrg # Used by our autoconf macros to check whether the available missing 36c97b1c41Smrg # script is modern enough. 37c97b1c41Smrg exit 0 38c97b1c41Smrg ;; 3945bc899bSmrg 40c97b1c41Smrg --run) 41c97b1c41Smrg # Back-compat with the calling convention used by older automake. 42c97b1c41Smrg shift 43c97b1c41Smrg ;; 4445bc899bSmrg 4545bc899bSmrg -h|--h|--he|--hel|--help) 4645bc899bSmrg echo "\ 4745bc899bSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4845bc899bSmrg 49c97b1c41SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50c97b1c41Smrgto PROGRAM being missing or too old. 5145bc899bSmrg 5245bc899bSmrgOptions: 5345bc899bSmrg -h, --help display this help and exit 5445bc899bSmrg -v, --version output version information and exit 5545bc899bSmrg 5645bc899bSmrgSupported PROGRAM values: 57c97b1c41Smrg aclocal autoconf autoheader autom4te automake makeinfo 58c97b1c41Smrg bison yacc flex lex help2man 5945bc899bSmrg 60c97b1c41SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61c97b1c41Smrg'g' are ignored when checking the name. 62b40a6198Smrg 6345bc899bSmrgSend bug reports to <bug-automake@gnu.org>." 6445bc899bSmrg exit $? 6545bc899bSmrg ;; 6645bc899bSmrg 6745bc899bSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6845bc899bSmrg echo "missing $scriptversion (GNU Automake)" 6945bc899bSmrg exit $? 7045bc899bSmrg ;; 7145bc899bSmrg 7245bc899bSmrg -*) 73c97b1c41Smrg echo 1>&2 "$0: unknown '$1' option" 74c97b1c41Smrg echo 1>&2 "Try '$0 --help' for more information" 7545bc899bSmrg exit 1 7645bc899bSmrg ;; 7745bc899bSmrg 7845bc899bSmrgesac 7945bc899bSmrg 80c97b1c41Smrg# Run the given program, remember its exit status. 81c97b1c41Smrg"$@"; st=$? 82c97b1c41Smrg 83c97b1c41Smrg# If it succeeded, we are done. 84c97b1c41Smrgtest $st -eq 0 && exit 0 85c97b1c41Smrg 86c97b1c41Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87c97b1c41Smrg# passed; such an option is passed most likely to detect whether the 88c97b1c41Smrg# program is present and works. 89c97b1c41Smrgcase $2 in --version|--help) exit $st;; esac 90c97b1c41Smrg 91c97b1c41Smrg# Exit code 63 means version mismatch. This often happens when the user 92c97b1c41Smrg# tries to use an ancient version of a tool on a file that requires a 93c97b1c41Smrg# minimum version. 94c97b1c41Smrgif test $st -eq 63; then 95c97b1c41Smrg msg="probably too old" 96c97b1c41Smrgelif test $st -eq 127; then 97c97b1c41Smrg # Program was missing. 98c97b1c41Smrg msg="missing on your system" 99c97b1c41Smrgelse 100c97b1c41Smrg # Program was found and executed, but failed. Give up. 101c97b1c41Smrg exit $st 102c97b1c41Smrgfi 10345bc899bSmrg 104a0c41156Smrgperl_URL=https://www.perl.org/ 105a0c41156Smrgflex_URL=https://github.com/westes/flex 106a0c41156Smrggnu_software_URL=https://www.gnu.org/software 107c97b1c41Smrg 108c97b1c41Smrgprogram_details () 109c97b1c41Smrg{ 110c97b1c41Smrg case $1 in 111c97b1c41Smrg aclocal|automake) 112c97b1c41Smrg echo "The '$1' program is part of the GNU Automake package:" 113c97b1c41Smrg echo "<$gnu_software_URL/automake>" 114c97b1c41Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115c97b1c41Smrg echo "<$gnu_software_URL/autoconf>" 116c97b1c41Smrg echo "<$gnu_software_URL/m4/>" 117c97b1c41Smrg echo "<$perl_URL>" 118c97b1c41Smrg ;; 119c97b1c41Smrg autoconf|autom4te|autoheader) 120c97b1c41Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121c97b1c41Smrg echo "<$gnu_software_URL/autoconf/>" 122c97b1c41Smrg echo "It also requires GNU m4 and Perl in order to run:" 123c97b1c41Smrg echo "<$gnu_software_URL/m4/>" 124c97b1c41Smrg echo "<$perl_URL>" 125c97b1c41Smrg ;; 126c97b1c41Smrg esac 127c97b1c41Smrg} 128c97b1c41Smrg 129c97b1c41Smrggive_advice () 130c97b1c41Smrg{ 131c97b1c41Smrg # Normalize program name to check for. 132c97b1c41Smrg normalized_program=`echo "$1" | sed ' 133c97b1c41Smrg s/^gnu-//; t 134c97b1c41Smrg s/^gnu//; t 135c97b1c41Smrg s/^g//; t'` 136c97b1c41Smrg 137c97b1c41Smrg printf '%s\n' "'$1' is $msg." 138c97b1c41Smrg 139c97b1c41Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140c97b1c41Smrg case $normalized_program in 141c97b1c41Smrg autoconf*) 142c97b1c41Smrg echo "You should only need it if you modified 'configure.ac'," 143c97b1c41Smrg echo "or m4 files included by it." 144c97b1c41Smrg program_details 'autoconf' 145c97b1c41Smrg ;; 146c97b1c41Smrg autoheader*) 147c97b1c41Smrg echo "You should only need it if you modified 'acconfig.h' or" 148c97b1c41Smrg echo "$configure_deps." 149c97b1c41Smrg program_details 'autoheader' 150c97b1c41Smrg ;; 151c97b1c41Smrg automake*) 152c97b1c41Smrg echo "You should only need it if you modified 'Makefile.am' or" 153c97b1c41Smrg echo "$configure_deps." 154c97b1c41Smrg program_details 'automake' 155c97b1c41Smrg ;; 156c97b1c41Smrg aclocal*) 157c97b1c41Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158c97b1c41Smrg echo "$configure_deps." 159c97b1c41Smrg program_details 'aclocal' 160c97b1c41Smrg ;; 161c97b1c41Smrg autom4te*) 162c97b1c41Smrg echo "You might have modified some maintainer files that require" 16357ba8e8bSmrg echo "the 'autom4te' program to be rebuilt." 164c97b1c41Smrg program_details 'autom4te' 165c97b1c41Smrg ;; 166c97b1c41Smrg bison*|yacc*) 167c97b1c41Smrg echo "You should only need it if you modified a '.y' file." 168c97b1c41Smrg echo "You may want to install the GNU Bison package:" 169c97b1c41Smrg echo "<$gnu_software_URL/bison/>" 170c97b1c41Smrg ;; 171c97b1c41Smrg lex*|flex*) 172c97b1c41Smrg echo "You should only need it if you modified a '.l' file." 173c97b1c41Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174c97b1c41Smrg echo "<$flex_URL>" 175c97b1c41Smrg ;; 176c97b1c41Smrg help2man*) 177c97b1c41Smrg echo "You should only need it if you modified a dependency" \ 178c97b1c41Smrg "of a man page." 179c97b1c41Smrg echo "You may want to install the GNU Help2man package:" 180c97b1c41Smrg echo "<$gnu_software_URL/help2man/>" 18145bc899bSmrg ;; 182c97b1c41Smrg makeinfo*) 183c97b1c41Smrg echo "You should only need it if you modified a '.texi' file, or" 184c97b1c41Smrg echo "any other file indirectly affecting the aspect of the manual." 185c97b1c41Smrg echo "You might want to install the Texinfo package:" 186c97b1c41Smrg echo "<$gnu_software_URL/texinfo/>" 187c97b1c41Smrg echo "The spurious makeinfo call might also be the consequence of" 188c97b1c41Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189c97b1c41Smrg echo "want to install GNU make:" 190c97b1c41Smrg echo "<$gnu_software_URL/make/>" 191c97b1c41Smrg ;; 192c97b1c41Smrg *) 193c97b1c41Smrg echo "You might have modified some files without having the proper" 194c97b1c41Smrg echo "tools for further handling them. Check the 'README' file, it" 195c97b1c41Smrg echo "often tells you about the needed prerequisites for installing" 196c97b1c41Smrg echo "this package. You may also peek at any GNU archive site, in" 197c97b1c41Smrg echo "case some other package contains this missing '$1' program." 198c97b1c41Smrg ;; 199c97b1c41Smrg esac 200c97b1c41Smrg} 201c97b1c41Smrg 202c97b1c41Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203c97b1c41Smrg -e '2,$s/^/ /' >&2 204c97b1c41Smrg 205c97b1c41Smrg# Propagate the correct exit status (expected to be 127 for a program 206c97b1c41Smrg# not found, 63 for a program that failed due to version mismatch). 207c97b1c41Smrgexit $st 20845bc899bSmrg 20945bc899bSmrg# Local variables: 210a0c41156Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 21145bc899bSmrg# time-stamp-start: "scriptversion=" 21245bc899bSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213f2408745Smrg# time-stamp-time-zone: "UTC0" 214b40a6198Smrg# time-stamp-end: "; # UTC" 21545bc899bSmrg# End: 216