116910e25Smrg#! /bin/sh 276c9c3baSmrg# Common wrapper for a few potentially missing GNU programs. 39c125d91Smrg 4ed89697eSmrgscriptversion=2018-03-07.03; # UTC 59c125d91Smrg 6ed89697eSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 776c9c3baSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 816910e25Smrg 916910e25Smrg# This program is free software; you can redistribute it and/or modify 1016910e25Smrg# it under the terms of the GNU General Public License as published by 1116910e25Smrg# the Free Software Foundation; either version 2, or (at your option) 1216910e25Smrg# any later version. 1316910e25Smrg 1416910e25Smrg# This program is distributed in the hope that it will be useful, 1516910e25Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1616910e25Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1716910e25Smrg# GNU General Public License for more details. 1816910e25Smrg 1916910e25Smrg# You should have received a copy of the GNU General Public License 20ed89697eSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2116910e25Smrg 2216910e25Smrg# As a special exception to the GNU General Public License, if you 2316910e25Smrg# distribute this file as part of a program that contains a 2416910e25Smrg# configuration script generated by Autoconf, you may include it under 2516910e25Smrg# the same distribution terms that you use for the rest of that program. 2616910e25Smrg 2716910e25Smrgif test $# -eq 0; then 2876c9c3baSmrg echo 1>&2 "Try '$0 --help' for more information" 2916910e25Smrg exit 1 3016910e25Smrgfi 3116910e25Smrg 3276c9c3baSmrgcase $1 in 3316910e25Smrg 3476c9c3baSmrg --is-lightweight) 3576c9c3baSmrg # Used by our autoconf macros to check whether the available missing 3676c9c3baSmrg # script is modern enough. 3776c9c3baSmrg exit 0 3876c9c3baSmrg ;; 399c125d91Smrg 4076c9c3baSmrg --run) 4176c9c3baSmrg # Back-compat with the calling convention used by older automake. 4276c9c3baSmrg shift 4376c9c3baSmrg ;; 4416910e25Smrg 4516910e25Smrg -h|--h|--he|--hel|--help) 4616910e25Smrg echo "\ 4716910e25Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4816910e25Smrg 4976c9c3baSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5076c9c3baSmrgto PROGRAM being missing or too old. 5116910e25Smrg 5216910e25SmrgOptions: 5316910e25Smrg -h, --help display this help and exit 5416910e25Smrg -v, --version output version information and exit 5516910e25Smrg 5616910e25SmrgSupported PROGRAM values: 5776c9c3baSmrg aclocal autoconf autoheader autom4te automake makeinfo 5876c9c3baSmrg bison yacc flex lex help2man 599c125d91Smrg 6076c9c3baSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6176c9c3baSmrg'g' are ignored when checking the name. 629c125d91Smrg 639c125d91SmrgSend bug reports to <bug-automake@gnu.org>." 649c125d91Smrg exit $? 6516910e25Smrg ;; 6616910e25Smrg 6716910e25Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 689c125d91Smrg echo "missing $scriptversion (GNU Automake)" 699c125d91Smrg exit $? 7016910e25Smrg ;; 7116910e25Smrg 7216910e25Smrg -*) 7376c9c3baSmrg echo 1>&2 "$0: unknown '$1' option" 7476c9c3baSmrg echo 1>&2 "Try '$0 --help' for more information" 7516910e25Smrg exit 1 7616910e25Smrg ;; 7716910e25Smrg 789c125d91Smrgesac 799c125d91Smrg 8076c9c3baSmrg# Run the given program, remember its exit status. 8176c9c3baSmrg"$@"; st=$? 8276c9c3baSmrg 8376c9c3baSmrg# If it succeeded, we are done. 8476c9c3baSmrgtest $st -eq 0 && exit 0 8576c9c3baSmrg 8676c9c3baSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 8776c9c3baSmrg# passed; such an option is passed most likely to detect whether the 8876c9c3baSmrg# program is present and works. 8976c9c3baSmrgcase $2 in --version|--help) exit $st;; esac 9076c9c3baSmrg 9176c9c3baSmrg# Exit code 63 means version mismatch. This often happens when the user 9276c9c3baSmrg# tries to use an ancient version of a tool on a file that requires a 9376c9c3baSmrg# minimum version. 9476c9c3baSmrgif test $st -eq 63; then 9576c9c3baSmrg msg="probably too old" 9676c9c3baSmrgelif test $st -eq 127; then 9776c9c3baSmrg # Program was missing. 9876c9c3baSmrg msg="missing on your system" 9976c9c3baSmrgelse 10076c9c3baSmrg # Program was found and executed, but failed. Give up. 10176c9c3baSmrg exit $st 10276c9c3baSmrgfi 10316910e25Smrg 104ed89697eSmrgperl_URL=https://www.perl.org/ 105ed89697eSmrgflex_URL=https://github.com/westes/flex 106ed89697eSmrggnu_software_URL=https://www.gnu.org/software 10776c9c3baSmrg 10876c9c3baSmrgprogram_details () 10976c9c3baSmrg{ 11076c9c3baSmrg case $1 in 11176c9c3baSmrg aclocal|automake) 11276c9c3baSmrg echo "The '$1' program is part of the GNU Automake package:" 11376c9c3baSmrg echo "<$gnu_software_URL/automake>" 11476c9c3baSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11576c9c3baSmrg echo "<$gnu_software_URL/autoconf>" 11676c9c3baSmrg echo "<$gnu_software_URL/m4/>" 11776c9c3baSmrg echo "<$perl_URL>" 11876c9c3baSmrg ;; 11976c9c3baSmrg autoconf|autom4te|autoheader) 12076c9c3baSmrg echo "The '$1' program is part of the GNU Autoconf package:" 12176c9c3baSmrg echo "<$gnu_software_URL/autoconf/>" 12276c9c3baSmrg echo "It also requires GNU m4 and Perl in order to run:" 12376c9c3baSmrg echo "<$gnu_software_URL/m4/>" 12476c9c3baSmrg echo "<$perl_URL>" 12576c9c3baSmrg ;; 12676c9c3baSmrg esac 12776c9c3baSmrg} 12876c9c3baSmrg 12976c9c3baSmrggive_advice () 13076c9c3baSmrg{ 13176c9c3baSmrg # Normalize program name to check for. 13276c9c3baSmrg normalized_program=`echo "$1" | sed ' 13376c9c3baSmrg s/^gnu-//; t 13476c9c3baSmrg s/^gnu//; t 13576c9c3baSmrg s/^g//; t'` 13676c9c3baSmrg 13776c9c3baSmrg printf '%s\n' "'$1' is $msg." 13876c9c3baSmrg 13976c9c3baSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14076c9c3baSmrg case $normalized_program in 14176c9c3baSmrg autoconf*) 14276c9c3baSmrg echo "You should only need it if you modified 'configure.ac'," 14376c9c3baSmrg echo "or m4 files included by it." 14476c9c3baSmrg program_details 'autoconf' 14576c9c3baSmrg ;; 14676c9c3baSmrg autoheader*) 14776c9c3baSmrg echo "You should only need it if you modified 'acconfig.h' or" 14876c9c3baSmrg echo "$configure_deps." 14976c9c3baSmrg program_details 'autoheader' 15076c9c3baSmrg ;; 15176c9c3baSmrg automake*) 15276c9c3baSmrg echo "You should only need it if you modified 'Makefile.am' or" 15376c9c3baSmrg echo "$configure_deps." 15476c9c3baSmrg program_details 'automake' 15576c9c3baSmrg ;; 15676c9c3baSmrg aclocal*) 15776c9c3baSmrg echo "You should only need it if you modified 'acinclude.m4' or" 15876c9c3baSmrg echo "$configure_deps." 15976c9c3baSmrg program_details 'aclocal' 16076c9c3baSmrg ;; 16176c9c3baSmrg autom4te*) 16276c9c3baSmrg echo "You might have modified some maintainer files that require" 16376c9c3baSmrg echo "the 'autom4te' program to be rebuilt." 16476c9c3baSmrg program_details 'autom4te' 16576c9c3baSmrg ;; 16676c9c3baSmrg bison*|yacc*) 16776c9c3baSmrg echo "You should only need it if you modified a '.y' file." 16876c9c3baSmrg echo "You may want to install the GNU Bison package:" 16976c9c3baSmrg echo "<$gnu_software_URL/bison/>" 17076c9c3baSmrg ;; 17176c9c3baSmrg lex*|flex*) 17276c9c3baSmrg echo "You should only need it if you modified a '.l' file." 17376c9c3baSmrg echo "You may want to install the Fast Lexical Analyzer package:" 17476c9c3baSmrg echo "<$flex_URL>" 17576c9c3baSmrg ;; 17676c9c3baSmrg help2man*) 17776c9c3baSmrg echo "You should only need it if you modified a dependency" \ 17876c9c3baSmrg "of a man page." 17976c9c3baSmrg echo "You may want to install the GNU Help2man package:" 18076c9c3baSmrg echo "<$gnu_software_URL/help2man/>" 18176c9c3baSmrg ;; 18276c9c3baSmrg makeinfo*) 18376c9c3baSmrg echo "You should only need it if you modified a '.texi' file, or" 18476c9c3baSmrg echo "any other file indirectly affecting the aspect of the manual." 18576c9c3baSmrg echo "You might want to install the Texinfo package:" 18676c9c3baSmrg echo "<$gnu_software_URL/texinfo/>" 18776c9c3baSmrg echo "The spurious makeinfo call might also be the consequence of" 18876c9c3baSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18976c9c3baSmrg echo "want to install GNU make:" 19076c9c3baSmrg echo "<$gnu_software_URL/make/>" 19176c9c3baSmrg ;; 19276c9c3baSmrg *) 19376c9c3baSmrg echo "You might have modified some files without having the proper" 19476c9c3baSmrg echo "tools for further handling them. Check the 'README' file, it" 19576c9c3baSmrg echo "often tells you about the needed prerequisites for installing" 19676c9c3baSmrg echo "this package. You may also peek at any GNU archive site, in" 19776c9c3baSmrg echo "case some other package contains this missing '$1' program." 19876c9c3baSmrg ;; 19976c9c3baSmrg esac 20076c9c3baSmrg} 20176c9c3baSmrg 20276c9c3baSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20376c9c3baSmrg -e '2,$s/^/ /' >&2 20476c9c3baSmrg 20576c9c3baSmrg# Propagate the correct exit status (expected to be 127 for a program 20676c9c3baSmrg# not found, 63 for a program that failed due to version mismatch). 20776c9c3baSmrgexit $st 2089c125d91Smrg 2099c125d91Smrg# Local variables: 210ed89697eSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2119c125d91Smrg# time-stamp-start: "scriptversion=" 2129c125d91Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213ed89697eSmrg# time-stamp-time-zone: "UTC0" 2149c125d91Smrg# time-stamp-end: "; # UTC" 2159c125d91Smrg# End: 216