missing revision da2e2ef6
1145b7b3cSmrg#! /bin/sh 2b7d26471Smrg# Common wrapper for a few potentially missing GNU programs. 3145b7b3cSmrg 4da2e2ef6Smrgscriptversion=2018-03-07.03; # UTC 5145b7b3cSmrg 6da2e2ef6Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7b7d26471Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8145b7b3cSmrg 9145b7b3cSmrg# This program is free software; you can redistribute it and/or modify 10145b7b3cSmrg# it under the terms of the GNU General Public License as published by 11145b7b3cSmrg# the Free Software Foundation; either version 2, or (at your option) 12145b7b3cSmrg# any later version. 13145b7b3cSmrg 14145b7b3cSmrg# This program is distributed in the hope that it will be useful, 15145b7b3cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16145b7b3cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17145b7b3cSmrg# GNU General Public License for more details. 18145b7b3cSmrg 19145b7b3cSmrg# You should have received a copy of the GNU General Public License 20da2e2ef6Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21145b7b3cSmrg 22145b7b3cSmrg# As a special exception to the GNU General Public License, if you 23145b7b3cSmrg# distribute this file as part of a program that contains a 24145b7b3cSmrg# configuration script generated by Autoconf, you may include it under 25145b7b3cSmrg# the same distribution terms that you use for the rest of that program. 26145b7b3cSmrg 27145b7b3cSmrgif test $# -eq 0; then 28b7d26471Smrg echo 1>&2 "Try '$0 --help' for more information" 29145b7b3cSmrg exit 1 30145b7b3cSmrgfi 31145b7b3cSmrg 32b7d26471Smrgcase $1 in 33145b7b3cSmrg 34b7d26471Smrg --is-lightweight) 35b7d26471Smrg # Used by our autoconf macros to check whether the available missing 36b7d26471Smrg # script is modern enough. 37b7d26471Smrg exit 0 38b7d26471Smrg ;; 39145b7b3cSmrg 40b7d26471Smrg --run) 41b7d26471Smrg # Back-compat with the calling convention used by older automake. 42b7d26471Smrg shift 43b7d26471Smrg ;; 44145b7b3cSmrg 45145b7b3cSmrg -h|--h|--he|--hel|--help) 46145b7b3cSmrg echo "\ 47145b7b3cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48145b7b3cSmrg 49b7d26471SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50b7d26471Smrgto PROGRAM being missing or too old. 51145b7b3cSmrg 52145b7b3cSmrgOptions: 53145b7b3cSmrg -h, --help display this help and exit 54145b7b3cSmrg -v, --version output version information and exit 55145b7b3cSmrg 56145b7b3cSmrgSupported PROGRAM values: 57b7d26471Smrg aclocal autoconf autoheader autom4te automake makeinfo 58b7d26471Smrg bison yacc flex lex help2man 59145b7b3cSmrg 60b7d26471SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61b7d26471Smrg'g' are ignored when checking the name. 62578741aaSmrg 63145b7b3cSmrgSend bug reports to <bug-automake@gnu.org>." 64145b7b3cSmrg exit $? 65145b7b3cSmrg ;; 66145b7b3cSmrg 67145b7b3cSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68145b7b3cSmrg echo "missing $scriptversion (GNU Automake)" 69145b7b3cSmrg exit $? 70145b7b3cSmrg ;; 71145b7b3cSmrg 72145b7b3cSmrg -*) 73b7d26471Smrg echo 1>&2 "$0: unknown '$1' option" 74b7d26471Smrg echo 1>&2 "Try '$0 --help' for more information" 75145b7b3cSmrg exit 1 76145b7b3cSmrg ;; 77145b7b3cSmrg 78145b7b3cSmrgesac 79145b7b3cSmrg 80b7d26471Smrg# Run the given program, remember its exit status. 81b7d26471Smrg"$@"; st=$? 82b7d26471Smrg 83b7d26471Smrg# If it succeeded, we are done. 84b7d26471Smrgtest $st -eq 0 && exit 0 85b7d26471Smrg 86b7d26471Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87b7d26471Smrg# passed; such an option is passed most likely to detect whether the 88b7d26471Smrg# program is present and works. 89b7d26471Smrgcase $2 in --version|--help) exit $st;; esac 90b7d26471Smrg 91b7d26471Smrg# Exit code 63 means version mismatch. This often happens when the user 92b7d26471Smrg# tries to use an ancient version of a tool on a file that requires a 93b7d26471Smrg# minimum version. 94b7d26471Smrgif test $st -eq 63; then 95b7d26471Smrg msg="probably too old" 96b7d26471Smrgelif test $st -eq 127; then 97b7d26471Smrg # Program was missing. 98b7d26471Smrg msg="missing on your system" 99b7d26471Smrgelse 100b7d26471Smrg # Program was found and executed, but failed. Give up. 101b7d26471Smrg exit $st 102b7d26471Smrgfi 103145b7b3cSmrg 104da2e2ef6Smrgperl_URL=https://www.perl.org/ 105da2e2ef6Smrgflex_URL=https://github.com/westes/flex 106da2e2ef6Smrggnu_software_URL=https://www.gnu.org/software 107b7d26471Smrg 108b7d26471Smrgprogram_details () 109b7d26471Smrg{ 110b7d26471Smrg case $1 in 111b7d26471Smrg aclocal|automake) 112b7d26471Smrg echo "The '$1' program is part of the GNU Automake package:" 113b7d26471Smrg echo "<$gnu_software_URL/automake>" 114b7d26471Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115b7d26471Smrg echo "<$gnu_software_URL/autoconf>" 116b7d26471Smrg echo "<$gnu_software_URL/m4/>" 117b7d26471Smrg echo "<$perl_URL>" 118b7d26471Smrg ;; 119b7d26471Smrg autoconf|autom4te|autoheader) 120b7d26471Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121b7d26471Smrg echo "<$gnu_software_URL/autoconf/>" 122b7d26471Smrg echo "It also requires GNU m4 and Perl in order to run:" 123b7d26471Smrg echo "<$gnu_software_URL/m4/>" 124b7d26471Smrg echo "<$perl_URL>" 125b7d26471Smrg ;; 126b7d26471Smrg esac 127b7d26471Smrg} 128b7d26471Smrg 129b7d26471Smrggive_advice () 130b7d26471Smrg{ 131b7d26471Smrg # Normalize program name to check for. 132b7d26471Smrg normalized_program=`echo "$1" | sed ' 133b7d26471Smrg s/^gnu-//; t 134b7d26471Smrg s/^gnu//; t 135b7d26471Smrg s/^g//; t'` 136b7d26471Smrg 137b7d26471Smrg printf '%s\n' "'$1' is $msg." 138b7d26471Smrg 139b7d26471Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140b7d26471Smrg case $normalized_program in 141b7d26471Smrg autoconf*) 142b7d26471Smrg echo "You should only need it if you modified 'configure.ac'," 143b7d26471Smrg echo "or m4 files included by it." 144b7d26471Smrg program_details 'autoconf' 145b7d26471Smrg ;; 146b7d26471Smrg autoheader*) 147b7d26471Smrg echo "You should only need it if you modified 'acconfig.h' or" 148b7d26471Smrg echo "$configure_deps." 149b7d26471Smrg program_details 'autoheader' 150b7d26471Smrg ;; 151b7d26471Smrg automake*) 152b7d26471Smrg echo "You should only need it if you modified 'Makefile.am' or" 153b7d26471Smrg echo "$configure_deps." 154b7d26471Smrg program_details 'automake' 155b7d26471Smrg ;; 156b7d26471Smrg aclocal*) 157b7d26471Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158b7d26471Smrg echo "$configure_deps." 159b7d26471Smrg program_details 'aclocal' 160b7d26471Smrg ;; 161b7d26471Smrg autom4te*) 162b7d26471Smrg echo "You might have modified some maintainer files that require" 163b7d26471Smrg echo "the 'autom4te' program to be rebuilt." 164b7d26471Smrg program_details 'autom4te' 165b7d26471Smrg ;; 166b7d26471Smrg bison*|yacc*) 167b7d26471Smrg echo "You should only need it if you modified a '.y' file." 168b7d26471Smrg echo "You may want to install the GNU Bison package:" 169b7d26471Smrg echo "<$gnu_software_URL/bison/>" 170b7d26471Smrg ;; 171b7d26471Smrg lex*|flex*) 172b7d26471Smrg echo "You should only need it if you modified a '.l' file." 173b7d26471Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174b7d26471Smrg echo "<$flex_URL>" 175b7d26471Smrg ;; 176b7d26471Smrg help2man*) 177b7d26471Smrg echo "You should only need it if you modified a dependency" \ 178b7d26471Smrg "of a man page." 179b7d26471Smrg echo "You may want to install the GNU Help2man package:" 180b7d26471Smrg echo "<$gnu_software_URL/help2man/>" 181b7d26471Smrg ;; 182b7d26471Smrg makeinfo*) 183b7d26471Smrg echo "You should only need it if you modified a '.texi' file, or" 184b7d26471Smrg echo "any other file indirectly affecting the aspect of the manual." 185b7d26471Smrg echo "You might want to install the Texinfo package:" 186b7d26471Smrg echo "<$gnu_software_URL/texinfo/>" 187b7d26471Smrg echo "The spurious makeinfo call might also be the consequence of" 188b7d26471Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189b7d26471Smrg echo "want to install GNU make:" 190b7d26471Smrg echo "<$gnu_software_URL/make/>" 191b7d26471Smrg ;; 192b7d26471Smrg *) 193b7d26471Smrg echo "You might have modified some files without having the proper" 194b7d26471Smrg echo "tools for further handling them. Check the 'README' file, it" 195b7d26471Smrg echo "often tells you about the needed prerequisites for installing" 196b7d26471Smrg echo "this package. You may also peek at any GNU archive site, in" 197b7d26471Smrg echo "case some other package contains this missing '$1' program." 198b7d26471Smrg ;; 199b7d26471Smrg esac 200b7d26471Smrg} 201b7d26471Smrg 202b7d26471Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203b7d26471Smrg -e '2,$s/^/ /' >&2 204b7d26471Smrg 205b7d26471Smrg# Propagate the correct exit status (expected to be 127 for a program 206b7d26471Smrg# not found, 63 for a program that failed due to version mismatch). 207b7d26471Smrgexit $st 208145b7b3cSmrg 209145b7b3cSmrg# Local variables: 210da2e2ef6Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211145b7b3cSmrg# time-stamp-start: "scriptversion=" 212145b7b3cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213da2e2ef6Smrg# time-stamp-time-zone: "UTC0" 214578741aaSmrg# time-stamp-end: "; # UTC" 215145b7b3cSmrg# End: 216