1e4da13eeSmacallan#! /bin/sh 225ad54caSmrg# Common wrapper for a few potentially missing GNU programs. 3e4da13eeSmacallan 425ad54caSmrgscriptversion=2018-03-07.03; # UTC 5e4da13eeSmacallan 625ad54caSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 725ad54caSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8e4da13eeSmacallan 9e4da13eeSmacallan# This program is free software; you can redistribute it and/or modify 10e4da13eeSmacallan# it under the terms of the GNU General Public License as published by 11e4da13eeSmacallan# the Free Software Foundation; either version 2, or (at your option) 12e4da13eeSmacallan# any later version. 13e4da13eeSmacallan 14e4da13eeSmacallan# This program is distributed in the hope that it will be useful, 15e4da13eeSmacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of 16e4da13eeSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17e4da13eeSmacallan# GNU General Public License for more details. 18e4da13eeSmacallan 19e4da13eeSmacallan# You should have received a copy of the GNU General Public License 2025ad54caSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21e4da13eeSmacallan 22e4da13eeSmacallan# As a special exception to the GNU General Public License, if you 23e4da13eeSmacallan# distribute this file as part of a program that contains a 24e4da13eeSmacallan# configuration script generated by Autoconf, you may include it under 25e4da13eeSmacallan# the same distribution terms that you use for the rest of that program. 26e4da13eeSmacallan 27e4da13eeSmacallanif test $# -eq 0; then 2865d490d0Smrg echo 1>&2 "Try '$0 --help' for more information" 29e4da13eeSmacallan exit 1 30e4da13eeSmacallanfi 31e4da13eeSmacallan 3225ad54caSmrgcase $1 in 33e4da13eeSmacallan 3425ad54caSmrg --is-lightweight) 3525ad54caSmrg # Used by our autoconf macros to check whether the available missing 3625ad54caSmrg # script is modern enough. 3725ad54caSmrg exit 0 3825ad54caSmrg ;; 39e4da13eeSmacallan 4025ad54caSmrg --run) 4125ad54caSmrg # Back-compat with the calling convention used by older automake. 4225ad54caSmrg shift 4325ad54caSmrg ;; 44e4da13eeSmacallan 45e4da13eeSmacallan -h|--h|--he|--hel|--help) 46e4da13eeSmacallan echo "\ 47e4da13eeSmacallan$0 [OPTION]... PROGRAM [ARGUMENT]... 48e4da13eeSmacallan 4925ad54caSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5025ad54caSmrgto PROGRAM being missing or too old. 51e4da13eeSmacallan 52e4da13eeSmacallanOptions: 53e4da13eeSmacallan -h, --help display this help and exit 54e4da13eeSmacallan -v, --version output version information and exit 55e4da13eeSmacallan 56e4da13eeSmacallanSupported PROGRAM values: 5725ad54caSmrg aclocal autoconf autoheader autom4te automake makeinfo 5825ad54caSmrg bison yacc flex lex help2man 5965d490d0Smrg 6065d490d0SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6165d490d0Smrg'g' are ignored when checking the name. 62e4da13eeSmacallan 63e4da13eeSmacallanSend bug reports to <bug-automake@gnu.org>." 64e4da13eeSmacallan exit $? 65e4da13eeSmacallan ;; 66e4da13eeSmacallan 67e4da13eeSmacallan -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68e4da13eeSmacallan echo "missing $scriptversion (GNU Automake)" 69e4da13eeSmacallan exit $? 70e4da13eeSmacallan ;; 71e4da13eeSmacallan 72e4da13eeSmacallan -*) 7325ad54caSmrg echo 1>&2 "$0: unknown '$1' option" 7465d490d0Smrg echo 1>&2 "Try '$0 --help' for more information" 75e4da13eeSmacallan exit 1 76e4da13eeSmacallan ;; 77e4da13eeSmacallan 78e4da13eeSmacallanesac 79e4da13eeSmacallan 8025ad54caSmrg# Run the given program, remember its exit status. 8125ad54caSmrg"$@"; st=$? 8225ad54caSmrg 8325ad54caSmrg# If it succeeded, we are done. 8425ad54caSmrgtest $st -eq 0 && exit 0 8525ad54caSmrg 8625ad54caSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 8725ad54caSmrg# passed; such an option is passed most likely to detect whether the 8825ad54caSmrg# program is present and works. 8925ad54caSmrgcase $2 in --version|--help) exit $st;; esac 9025ad54caSmrg 9125ad54caSmrg# Exit code 63 means version mismatch. This often happens when the user 9225ad54caSmrg# tries to use an ancient version of a tool on a file that requires a 9325ad54caSmrg# minimum version. 9425ad54caSmrgif test $st -eq 63; then 9525ad54caSmrg msg="probably too old" 9625ad54caSmrgelif test $st -eq 127; then 9725ad54caSmrg # Program was missing. 9825ad54caSmrg msg="missing on your system" 9925ad54caSmrgelse 10025ad54caSmrg # Program was found and executed, but failed. Give up. 10125ad54caSmrg exit $st 10225ad54caSmrgfi 103e4da13eeSmacallan 10425ad54caSmrgperl_URL=https://www.perl.org/ 10525ad54caSmrgflex_URL=https://github.com/westes/flex 10625ad54caSmrggnu_software_URL=https://www.gnu.org/software 10725ad54caSmrg 10825ad54caSmrgprogram_details () 10925ad54caSmrg{ 11025ad54caSmrg case $1 in 11125ad54caSmrg aclocal|automake) 11225ad54caSmrg echo "The '$1' program is part of the GNU Automake package:" 11325ad54caSmrg echo "<$gnu_software_URL/automake>" 11425ad54caSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11525ad54caSmrg echo "<$gnu_software_URL/autoconf>" 11625ad54caSmrg echo "<$gnu_software_URL/m4/>" 11725ad54caSmrg echo "<$perl_URL>" 11825ad54caSmrg ;; 11925ad54caSmrg autoconf|autom4te|autoheader) 12025ad54caSmrg echo "The '$1' program is part of the GNU Autoconf package:" 12125ad54caSmrg echo "<$gnu_software_URL/autoconf/>" 12225ad54caSmrg echo "It also requires GNU m4 and Perl in order to run:" 12325ad54caSmrg echo "<$gnu_software_URL/m4/>" 12425ad54caSmrg echo "<$perl_URL>" 12525ad54caSmrg ;; 12625ad54caSmrg esac 12725ad54caSmrg} 12825ad54caSmrg 12925ad54caSmrggive_advice () 13025ad54caSmrg{ 13125ad54caSmrg # Normalize program name to check for. 13225ad54caSmrg normalized_program=`echo "$1" | sed ' 13325ad54caSmrg s/^gnu-//; t 13425ad54caSmrg s/^gnu//; t 13525ad54caSmrg s/^g//; t'` 13625ad54caSmrg 13725ad54caSmrg printf '%s\n' "'$1' is $msg." 13825ad54caSmrg 13925ad54caSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14025ad54caSmrg case $normalized_program in 14125ad54caSmrg autoconf*) 14225ad54caSmrg echo "You should only need it if you modified 'configure.ac'," 14325ad54caSmrg echo "or m4 files included by it." 14425ad54caSmrg program_details 'autoconf' 14525ad54caSmrg ;; 14625ad54caSmrg autoheader*) 14725ad54caSmrg echo "You should only need it if you modified 'acconfig.h' or" 14825ad54caSmrg echo "$configure_deps." 14925ad54caSmrg program_details 'autoheader' 15025ad54caSmrg ;; 15125ad54caSmrg automake*) 15225ad54caSmrg echo "You should only need it if you modified 'Makefile.am' or" 15325ad54caSmrg echo "$configure_deps." 15425ad54caSmrg program_details 'automake' 15525ad54caSmrg ;; 15625ad54caSmrg aclocal*) 15725ad54caSmrg echo "You should only need it if you modified 'acinclude.m4' or" 15825ad54caSmrg echo "$configure_deps." 15925ad54caSmrg program_details 'aclocal' 16025ad54caSmrg ;; 16125ad54caSmrg autom4te*) 16225ad54caSmrg echo "You might have modified some maintainer files that require" 16325ad54caSmrg echo "the 'autom4te' program to be rebuilt." 16425ad54caSmrg program_details 'autom4te' 16525ad54caSmrg ;; 16625ad54caSmrg bison*|yacc*) 16725ad54caSmrg echo "You should only need it if you modified a '.y' file." 16825ad54caSmrg echo "You may want to install the GNU Bison package:" 16925ad54caSmrg echo "<$gnu_software_URL/bison/>" 17025ad54caSmrg ;; 17125ad54caSmrg lex*|flex*) 17225ad54caSmrg echo "You should only need it if you modified a '.l' file." 17325ad54caSmrg echo "You may want to install the Fast Lexical Analyzer package:" 17425ad54caSmrg echo "<$flex_URL>" 17525ad54caSmrg ;; 17625ad54caSmrg help2man*) 17725ad54caSmrg echo "You should only need it if you modified a dependency" \ 17825ad54caSmrg "of a man page." 17925ad54caSmrg echo "You may want to install the GNU Help2man package:" 18025ad54caSmrg echo "<$gnu_software_URL/help2man/>" 181e4da13eeSmacallan ;; 18225ad54caSmrg makeinfo*) 18325ad54caSmrg echo "You should only need it if you modified a '.texi' file, or" 18425ad54caSmrg echo "any other file indirectly affecting the aspect of the manual." 18525ad54caSmrg echo "You might want to install the Texinfo package:" 18625ad54caSmrg echo "<$gnu_software_URL/texinfo/>" 18725ad54caSmrg echo "The spurious makeinfo call might also be the consequence of" 18825ad54caSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18925ad54caSmrg echo "want to install GNU make:" 19025ad54caSmrg echo "<$gnu_software_URL/make/>" 19125ad54caSmrg ;; 19225ad54caSmrg *) 19325ad54caSmrg echo "You might have modified some files without having the proper" 19425ad54caSmrg echo "tools for further handling them. Check the 'README' file, it" 19525ad54caSmrg echo "often tells you about the needed prerequisites for installing" 19625ad54caSmrg echo "this package. You may also peek at any GNU archive site, in" 19725ad54caSmrg echo "case some other package contains this missing '$1' program." 19825ad54caSmrg ;; 19925ad54caSmrg esac 20025ad54caSmrg} 20125ad54caSmrg 20225ad54caSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20325ad54caSmrg -e '2,$s/^/ /' >&2 20425ad54caSmrg 20525ad54caSmrg# Propagate the correct exit status (expected to be 127 for a program 20625ad54caSmrg# not found, 63 for a program that failed due to version mismatch). 20725ad54caSmrgexit $st 208e4da13eeSmacallan 209e4da13eeSmacallan# Local variables: 21025ad54caSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 211e4da13eeSmacallan# time-stamp-start: "scriptversion=" 212e4da13eeSmacallan# time-stamp-format: "%:y-%02m-%02d.%02H" 21325ad54caSmrg# time-stamp-time-zone: "UTC0" 21465d490d0Smrg# time-stamp-end: "; # UTC" 215e4da13eeSmacallan# End: 216