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