10fa2845dSmrg#! /bin/sh 2f66be5ecSmrg# Common wrapper for a few potentially missing GNU programs. 30fa2845dSmrg 4a0d387c7Smrgscriptversion=2018-03-07.03; # UTC 50fa2845dSmrg 6a0d387c7Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7f66be5ecSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 80fa2845dSmrg 90fa2845dSmrg# This program is free software; you can redistribute it and/or modify 100fa2845dSmrg# it under the terms of the GNU General Public License as published by 110fa2845dSmrg# the Free Software Foundation; either version 2, or (at your option) 120fa2845dSmrg# any later version. 130fa2845dSmrg 140fa2845dSmrg# This program is distributed in the hope that it will be useful, 150fa2845dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 160fa2845dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 170fa2845dSmrg# GNU General Public License for more details. 180fa2845dSmrg 190fa2845dSmrg# You should have received a copy of the GNU General Public License 20a0d387c7Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 210fa2845dSmrg 220fa2845dSmrg# As a special exception to the GNU General Public License, if you 230fa2845dSmrg# distribute this file as part of a program that contains a 240fa2845dSmrg# configuration script generated by Autoconf, you may include it under 250fa2845dSmrg# the same distribution terms that you use for the rest of that program. 260fa2845dSmrg 270fa2845dSmrgif test $# -eq 0; then 28f66be5ecSmrg echo 1>&2 "Try '$0 --help' for more information" 290fa2845dSmrg exit 1 300fa2845dSmrgfi 310fa2845dSmrg 32f66be5ecSmrgcase $1 in 330fa2845dSmrg 34f66be5ecSmrg --is-lightweight) 35f66be5ecSmrg # Used by our autoconf macros to check whether the available missing 36f66be5ecSmrg # script is modern enough. 37f66be5ecSmrg exit 0 38f66be5ecSmrg ;; 390fa2845dSmrg 40f66be5ecSmrg --run) 41f66be5ecSmrg # Back-compat with the calling convention used by older automake. 42f66be5ecSmrg shift 43f66be5ecSmrg ;; 440fa2845dSmrg 450fa2845dSmrg -h|--h|--he|--hel|--help) 460fa2845dSmrg echo "\ 470fa2845dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 480fa2845dSmrg 49f66be5ecSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50f66be5ecSmrgto PROGRAM being missing or too old. 510fa2845dSmrg 520fa2845dSmrgOptions: 530fa2845dSmrg -h, --help display this help and exit 540fa2845dSmrg -v, --version output version information and exit 550fa2845dSmrg 560fa2845dSmrgSupported PROGRAM values: 57f66be5ecSmrg aclocal autoconf autoheader autom4te automake makeinfo 58f66be5ecSmrg bison yacc flex lex help2man 590fa2845dSmrg 60f66be5ecSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61f66be5ecSmrg'g' are ignored when checking the name. 627888fd0eSmrg 630fa2845dSmrgSend bug reports to <bug-automake@gnu.org>." 640fa2845dSmrg exit $? 650fa2845dSmrg ;; 660fa2845dSmrg 670fa2845dSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 680fa2845dSmrg echo "missing $scriptversion (GNU Automake)" 690fa2845dSmrg exit $? 700fa2845dSmrg ;; 710fa2845dSmrg 720fa2845dSmrg -*) 73f66be5ecSmrg echo 1>&2 "$0: unknown '$1' option" 74f66be5ecSmrg echo 1>&2 "Try '$0 --help' for more information" 750fa2845dSmrg exit 1 760fa2845dSmrg ;; 770fa2845dSmrg 780fa2845dSmrgesac 790fa2845dSmrg 80f66be5ecSmrg# Run the given program, remember its exit status. 81f66be5ecSmrg"$@"; st=$? 82f66be5ecSmrg 83f66be5ecSmrg# If it succeeded, we are done. 84f66be5ecSmrgtest $st -eq 0 && exit 0 85f66be5ecSmrg 86f66be5ecSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87f66be5ecSmrg# passed; such an option is passed most likely to detect whether the 88f66be5ecSmrg# program is present and works. 89f66be5ecSmrgcase $2 in --version|--help) exit $st;; esac 90f66be5ecSmrg 91f66be5ecSmrg# Exit code 63 means version mismatch. This often happens when the user 92f66be5ecSmrg# tries to use an ancient version of a tool on a file that requires a 93f66be5ecSmrg# minimum version. 94f66be5ecSmrgif test $st -eq 63; then 95f66be5ecSmrg msg="probably too old" 96f66be5ecSmrgelif test $st -eq 127; then 97f66be5ecSmrg # Program was missing. 98f66be5ecSmrg msg="missing on your system" 99f66be5ecSmrgelse 100f66be5ecSmrg # Program was found and executed, but failed. Give up. 101f66be5ecSmrg exit $st 102f66be5ecSmrgfi 1030fa2845dSmrg 104a0d387c7Smrgperl_URL=https://www.perl.org/ 105a0d387c7Smrgflex_URL=https://github.com/westes/flex 106a0d387c7Smrggnu_software_URL=https://www.gnu.org/software 107f66be5ecSmrg 108f66be5ecSmrgprogram_details () 109f66be5ecSmrg{ 110f66be5ecSmrg case $1 in 111f66be5ecSmrg aclocal|automake) 112f66be5ecSmrg echo "The '$1' program is part of the GNU Automake package:" 113f66be5ecSmrg echo "<$gnu_software_URL/automake>" 114f66be5ecSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115f66be5ecSmrg echo "<$gnu_software_URL/autoconf>" 116f66be5ecSmrg echo "<$gnu_software_URL/m4/>" 117f66be5ecSmrg echo "<$perl_URL>" 118f66be5ecSmrg ;; 119f66be5ecSmrg autoconf|autom4te|autoheader) 120f66be5ecSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121f66be5ecSmrg echo "<$gnu_software_URL/autoconf/>" 122f66be5ecSmrg echo "It also requires GNU m4 and Perl in order to run:" 123f66be5ecSmrg echo "<$gnu_software_URL/m4/>" 124f66be5ecSmrg echo "<$perl_URL>" 125f66be5ecSmrg ;; 126f66be5ecSmrg esac 127f66be5ecSmrg} 128f66be5ecSmrg 129f66be5ecSmrggive_advice () 130f66be5ecSmrg{ 131f66be5ecSmrg # Normalize program name to check for. 132f66be5ecSmrg normalized_program=`echo "$1" | sed ' 133f66be5ecSmrg s/^gnu-//; t 134f66be5ecSmrg s/^gnu//; t 135f66be5ecSmrg s/^g//; t'` 136f66be5ecSmrg 137f66be5ecSmrg printf '%s\n' "'$1' is $msg." 138f66be5ecSmrg 139f66be5ecSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140f66be5ecSmrg case $normalized_program in 141f66be5ecSmrg autoconf*) 142f66be5ecSmrg echo "You should only need it if you modified 'configure.ac'," 143f66be5ecSmrg echo "or m4 files included by it." 144f66be5ecSmrg program_details 'autoconf' 145f66be5ecSmrg ;; 146f66be5ecSmrg autoheader*) 147f66be5ecSmrg echo "You should only need it if you modified 'acconfig.h' or" 148f66be5ecSmrg echo "$configure_deps." 149f66be5ecSmrg program_details 'autoheader' 150f66be5ecSmrg ;; 151f66be5ecSmrg automake*) 152f66be5ecSmrg echo "You should only need it if you modified 'Makefile.am' or" 153f66be5ecSmrg echo "$configure_deps." 154f66be5ecSmrg program_details 'automake' 155f66be5ecSmrg ;; 156f66be5ecSmrg aclocal*) 157f66be5ecSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158f66be5ecSmrg echo "$configure_deps." 159f66be5ecSmrg program_details 'aclocal' 160f66be5ecSmrg ;; 161f66be5ecSmrg autom4te*) 162f66be5ecSmrg echo "You might have modified some maintainer files that require" 163f66be5ecSmrg echo "the 'autom4te' program to be rebuilt." 164f66be5ecSmrg program_details 'autom4te' 165f66be5ecSmrg ;; 166f66be5ecSmrg bison*|yacc*) 167f66be5ecSmrg echo "You should only need it if you modified a '.y' file." 168f66be5ecSmrg echo "You may want to install the GNU Bison package:" 169f66be5ecSmrg echo "<$gnu_software_URL/bison/>" 170f66be5ecSmrg ;; 171f66be5ecSmrg lex*|flex*) 172f66be5ecSmrg echo "You should only need it if you modified a '.l' file." 173f66be5ecSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174f66be5ecSmrg echo "<$flex_URL>" 175f66be5ecSmrg ;; 176f66be5ecSmrg help2man*) 177f66be5ecSmrg echo "You should only need it if you modified a dependency" \ 178f66be5ecSmrg "of a man page." 179f66be5ecSmrg echo "You may want to install the GNU Help2man package:" 180f66be5ecSmrg echo "<$gnu_software_URL/help2man/>" 181f66be5ecSmrg ;; 182f66be5ecSmrg makeinfo*) 183f66be5ecSmrg echo "You should only need it if you modified a '.texi' file, or" 184f66be5ecSmrg echo "any other file indirectly affecting the aspect of the manual." 185f66be5ecSmrg echo "You might want to install the Texinfo package:" 186f66be5ecSmrg echo "<$gnu_software_URL/texinfo/>" 187f66be5ecSmrg echo "The spurious makeinfo call might also be the consequence of" 188f66be5ecSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189f66be5ecSmrg echo "want to install GNU make:" 190f66be5ecSmrg echo "<$gnu_software_URL/make/>" 191f66be5ecSmrg ;; 192f66be5ecSmrg *) 193f66be5ecSmrg echo "You might have modified some files without having the proper" 194f66be5ecSmrg echo "tools for further handling them. Check the 'README' file, it" 195f66be5ecSmrg echo "often tells you about the needed prerequisites for installing" 196f66be5ecSmrg echo "this package. You may also peek at any GNU archive site, in" 197f66be5ecSmrg echo "case some other package contains this missing '$1' program." 198f66be5ecSmrg ;; 199f66be5ecSmrg esac 200f66be5ecSmrg} 201f66be5ecSmrg 202f66be5ecSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203f66be5ecSmrg -e '2,$s/^/ /' >&2 204f66be5ecSmrg 205f66be5ecSmrg# Propagate the correct exit status (expected to be 127 for a program 206f66be5ecSmrg# not found, 63 for a program that failed due to version mismatch). 207f66be5ecSmrgexit $st 2080fa2845dSmrg 2090fa2845dSmrg# Local variables: 210a0d387c7Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2110fa2845dSmrg# time-stamp-start: "scriptversion=" 2120fa2845dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213a0d387c7Smrg# time-stamp-time-zone: "UTC0" 2147888fd0eSmrg# time-stamp-end: "; # UTC" 2150fa2845dSmrg# End: 216