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