1ff7e0accSmrg#! /bin/sh 205bee9bcSmrg# Common wrapper for a few potentially missing GNU programs. 3ff7e0accSmrg 42163f7f8Smrgscriptversion=2018-03-07.03; # UTC 5ff7e0accSmrg 62163f7f8Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 705bee9bcSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8ff7e0accSmrg 9ff7e0accSmrg# This program is free software; you can redistribute it and/or modify 10ff7e0accSmrg# it under the terms of the GNU General Public License as published by 11ff7e0accSmrg# the Free Software Foundation; either version 2, or (at your option) 12ff7e0accSmrg# any later version. 13ff7e0accSmrg 14ff7e0accSmrg# This program is distributed in the hope that it will be useful, 15ff7e0accSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16ff7e0accSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17ff7e0accSmrg# GNU General Public License for more details. 18ff7e0accSmrg 19ff7e0accSmrg# You should have received a copy of the GNU General Public License 202163f7f8Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21ff7e0accSmrg 22ff7e0accSmrg# As a special exception to the GNU General Public License, if you 23ff7e0accSmrg# distribute this file as part of a program that contains a 24ff7e0accSmrg# configuration script generated by Autoconf, you may include it under 25ff7e0accSmrg# the same distribution terms that you use for the rest of that program. 26ff7e0accSmrg 27ff7e0accSmrgif test $# -eq 0; then 2805bee9bcSmrg echo 1>&2 "Try '$0 --help' for more information" 29ff7e0accSmrg exit 1 30ff7e0accSmrgfi 31ff7e0accSmrg 3205bee9bcSmrgcase $1 in 33ff7e0accSmrg 3405bee9bcSmrg --is-lightweight) 3505bee9bcSmrg # Used by our autoconf macros to check whether the available missing 3605bee9bcSmrg # script is modern enough. 3705bee9bcSmrg exit 0 3805bee9bcSmrg ;; 39ff7e0accSmrg 4005bee9bcSmrg --run) 4105bee9bcSmrg # Back-compat with the calling convention used by older automake. 4205bee9bcSmrg shift 4305bee9bcSmrg ;; 44ff7e0accSmrg 45ff7e0accSmrg -h|--h|--he|--hel|--help) 46ff7e0accSmrg echo "\ 47ff7e0accSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48ff7e0accSmrg 4905bee9bcSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5005bee9bcSmrgto PROGRAM being missing or too old. 51ff7e0accSmrg 52ff7e0accSmrgOptions: 53ff7e0accSmrg -h, --help display this help and exit 54ff7e0accSmrg -v, --version output version information and exit 55ff7e0accSmrg 56ff7e0accSmrgSupported PROGRAM values: 5705bee9bcSmrg aclocal autoconf autoheader autom4te automake makeinfo 5805bee9bcSmrg bison yacc flex lex help2man 59ff7e0accSmrg 6005bee9bcSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6105bee9bcSmrg'g' are ignored when checking the name. 6210998002Smrg 63ff7e0accSmrgSend bug reports to <bug-automake@gnu.org>." 64ff7e0accSmrg exit $? 65ff7e0accSmrg ;; 66ff7e0accSmrg 67ff7e0accSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68ff7e0accSmrg echo "missing $scriptversion (GNU Automake)" 69ff7e0accSmrg exit $? 70ff7e0accSmrg ;; 71ff7e0accSmrg 72ff7e0accSmrg -*) 7305bee9bcSmrg echo 1>&2 "$0: unknown '$1' option" 7405bee9bcSmrg echo 1>&2 "Try '$0 --help' for more information" 75ff7e0accSmrg exit 1 76ff7e0accSmrg ;; 77ff7e0accSmrg 78ff7e0accSmrgesac 79ff7e0accSmrg 8005bee9bcSmrg# Run the given program, remember its exit status. 8105bee9bcSmrg"$@"; st=$? 8205bee9bcSmrg 8305bee9bcSmrg# If it succeeded, we are done. 8405bee9bcSmrgtest $st -eq 0 && exit 0 8505bee9bcSmrg 8605bee9bcSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 8705bee9bcSmrg# passed; such an option is passed most likely to detect whether the 8805bee9bcSmrg# program is present and works. 8905bee9bcSmrgcase $2 in --version|--help) exit $st;; esac 9005bee9bcSmrg 9105bee9bcSmrg# Exit code 63 means version mismatch. This often happens when the user 9205bee9bcSmrg# tries to use an ancient version of a tool on a file that requires a 9305bee9bcSmrg# minimum version. 9405bee9bcSmrgif test $st -eq 63; then 9505bee9bcSmrg msg="probably too old" 9605bee9bcSmrgelif test $st -eq 127; then 9705bee9bcSmrg # Program was missing. 9805bee9bcSmrg msg="missing on your system" 9905bee9bcSmrgelse 10005bee9bcSmrg # Program was found and executed, but failed. Give up. 10105bee9bcSmrg exit $st 10205bee9bcSmrgfi 103ff7e0accSmrg 1042163f7f8Smrgperl_URL=https://www.perl.org/ 1052163f7f8Smrgflex_URL=https://github.com/westes/flex 1062163f7f8Smrggnu_software_URL=https://www.gnu.org/software 10705bee9bcSmrg 10805bee9bcSmrgprogram_details () 10905bee9bcSmrg{ 11005bee9bcSmrg case $1 in 11105bee9bcSmrg aclocal|automake) 11205bee9bcSmrg echo "The '$1' program is part of the GNU Automake package:" 11305bee9bcSmrg echo "<$gnu_software_URL/automake>" 11405bee9bcSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11505bee9bcSmrg echo "<$gnu_software_URL/autoconf>" 11605bee9bcSmrg echo "<$gnu_software_URL/m4/>" 11705bee9bcSmrg echo "<$perl_URL>" 11805bee9bcSmrg ;; 11905bee9bcSmrg autoconf|autom4te|autoheader) 12005bee9bcSmrg echo "The '$1' program is part of the GNU Autoconf package:" 12105bee9bcSmrg echo "<$gnu_software_URL/autoconf/>" 12205bee9bcSmrg echo "It also requires GNU m4 and Perl in order to run:" 12305bee9bcSmrg echo "<$gnu_software_URL/m4/>" 12405bee9bcSmrg echo "<$perl_URL>" 12505bee9bcSmrg ;; 12605bee9bcSmrg esac 12705bee9bcSmrg} 12805bee9bcSmrg 12905bee9bcSmrggive_advice () 13005bee9bcSmrg{ 13105bee9bcSmrg # Normalize program name to check for. 13205bee9bcSmrg normalized_program=`echo "$1" | sed ' 13305bee9bcSmrg s/^gnu-//; t 13405bee9bcSmrg s/^gnu//; t 13505bee9bcSmrg s/^g//; t'` 13605bee9bcSmrg 13705bee9bcSmrg printf '%s\n' "'$1' is $msg." 13805bee9bcSmrg 13905bee9bcSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14005bee9bcSmrg case $normalized_program in 14105bee9bcSmrg autoconf*) 14205bee9bcSmrg echo "You should only need it if you modified 'configure.ac'," 14305bee9bcSmrg echo "or m4 files included by it." 14405bee9bcSmrg program_details 'autoconf' 14505bee9bcSmrg ;; 14605bee9bcSmrg autoheader*) 14705bee9bcSmrg echo "You should only need it if you modified 'acconfig.h' or" 14805bee9bcSmrg echo "$configure_deps." 14905bee9bcSmrg program_details 'autoheader' 15005bee9bcSmrg ;; 15105bee9bcSmrg automake*) 15205bee9bcSmrg echo "You should only need it if you modified 'Makefile.am' or" 15305bee9bcSmrg echo "$configure_deps." 15405bee9bcSmrg program_details 'automake' 15505bee9bcSmrg ;; 15605bee9bcSmrg aclocal*) 15705bee9bcSmrg echo "You should only need it if you modified 'acinclude.m4' or" 15805bee9bcSmrg echo "$configure_deps." 15905bee9bcSmrg program_details 'aclocal' 16005bee9bcSmrg ;; 16105bee9bcSmrg autom4te*) 16205bee9bcSmrg echo "You might have modified some maintainer files that require" 1630c91c449Smrg echo "the 'autom4te' program to be rebuilt." 16405bee9bcSmrg program_details 'autom4te' 16505bee9bcSmrg ;; 16605bee9bcSmrg bison*|yacc*) 16705bee9bcSmrg echo "You should only need it if you modified a '.y' file." 16805bee9bcSmrg echo "You may want to install the GNU Bison package:" 16905bee9bcSmrg echo "<$gnu_software_URL/bison/>" 17005bee9bcSmrg ;; 17105bee9bcSmrg lex*|flex*) 17205bee9bcSmrg echo "You should only need it if you modified a '.l' file." 17305bee9bcSmrg echo "You may want to install the Fast Lexical Analyzer package:" 17405bee9bcSmrg echo "<$flex_URL>" 17505bee9bcSmrg ;; 17605bee9bcSmrg help2man*) 17705bee9bcSmrg echo "You should only need it if you modified a dependency" \ 17805bee9bcSmrg "of a man page." 17905bee9bcSmrg echo "You may want to install the GNU Help2man package:" 18005bee9bcSmrg echo "<$gnu_software_URL/help2man/>" 18105bee9bcSmrg ;; 18205bee9bcSmrg makeinfo*) 18305bee9bcSmrg echo "You should only need it if you modified a '.texi' file, or" 18405bee9bcSmrg echo "any other file indirectly affecting the aspect of the manual." 18505bee9bcSmrg echo "You might want to install the Texinfo package:" 18605bee9bcSmrg echo "<$gnu_software_URL/texinfo/>" 18705bee9bcSmrg echo "The spurious makeinfo call might also be the consequence of" 18805bee9bcSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18905bee9bcSmrg echo "want to install GNU make:" 19005bee9bcSmrg echo "<$gnu_software_URL/make/>" 19105bee9bcSmrg ;; 19205bee9bcSmrg *) 19305bee9bcSmrg echo "You might have modified some files without having the proper" 19405bee9bcSmrg echo "tools for further handling them. Check the 'README' file, it" 19505bee9bcSmrg echo "often tells you about the needed prerequisites for installing" 19605bee9bcSmrg echo "this package. You may also peek at any GNU archive site, in" 19705bee9bcSmrg echo "case some other package contains this missing '$1' program." 19805bee9bcSmrg ;; 19905bee9bcSmrg esac 20005bee9bcSmrg} 20105bee9bcSmrg 20205bee9bcSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20305bee9bcSmrg -e '2,$s/^/ /' >&2 20405bee9bcSmrg 20505bee9bcSmrg# Propagate the correct exit status (expected to be 127 for a program 20605bee9bcSmrg# not found, 63 for a program that failed due to version mismatch). 20705bee9bcSmrgexit $st 208ff7e0accSmrg 209ff7e0accSmrg# Local variables: 2102163f7f8Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211ff7e0accSmrg# time-stamp-start: "scriptversion=" 212ff7e0accSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2132163f7f8Smrg# time-stamp-time-zone: "UTC0" 21410998002Smrg# time-stamp-end: "; # UTC" 215ff7e0accSmrg# End: 216