13294c433Smrg#! /bin/sh 2f403ce92Smrg# Common wrapper for a few potentially missing GNU programs. 39bc46bd4Smrg 4f403ce92Smrgscriptversion=2018-03-07.03; # UTC 59bc46bd4Smrg 6f403ce92Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7f403ce92Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 83294c433Smrg 93294c433Smrg# This program is free software; you can redistribute it and/or modify 103294c433Smrg# it under the terms of the GNU General Public License as published by 113294c433Smrg# the Free Software Foundation; either version 2, or (at your option) 123294c433Smrg# any later version. 133294c433Smrg 143294c433Smrg# This program is distributed in the hope that it will be useful, 153294c433Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 163294c433Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 173294c433Smrg# GNU General Public License for more details. 183294c433Smrg 193294c433Smrg# You should have received a copy of the GNU General Public License 20f403ce92Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 213294c433Smrg 223294c433Smrg# As a special exception to the GNU General Public License, if you 233294c433Smrg# distribute this file as part of a program that contains a 243294c433Smrg# configuration script generated by Autoconf, you may include it under 253294c433Smrg# the same distribution terms that you use for the rest of that program. 263294c433Smrg 273294c433Smrgif test $# -eq 0; then 28f403ce92Smrg echo 1>&2 "Try '$0 --help' for more information" 293294c433Smrg exit 1 303294c433Smrgfi 313294c433Smrg 32f403ce92Smrgcase $1 in 333294c433Smrg 34f403ce92Smrg --is-lightweight) 35f403ce92Smrg # Used by our autoconf macros to check whether the available missing 36f403ce92Smrg # script is modern enough. 37f403ce92Smrg exit 0 38f403ce92Smrg ;; 399bc46bd4Smrg 40f403ce92Smrg --run) 41f403ce92Smrg # Back-compat with the calling convention used by older automake. 42f403ce92Smrg shift 43f403ce92Smrg ;; 443294c433Smrg 453294c433Smrg -h|--h|--he|--hel|--help) 463294c433Smrg echo "\ 473294c433Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 483294c433Smrg 49f403ce92SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50f403ce92Smrgto PROGRAM being missing or too old. 513294c433Smrg 523294c433SmrgOptions: 533294c433Smrg -h, --help display this help and exit 543294c433Smrg -v, --version output version information and exit 553294c433Smrg 563294c433SmrgSupported PROGRAM values: 57f403ce92Smrg aclocal autoconf autoheader autom4te automake makeinfo 58f403ce92Smrg bison yacc flex lex help2man 599bc46bd4Smrg 60f403ce92SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61f403ce92Smrg'g' are ignored when checking the name. 629bc46bd4Smrg 639bc46bd4SmrgSend bug reports to <bug-automake@gnu.org>." 649bc46bd4Smrg exit $? 653294c433Smrg ;; 663294c433Smrg 673294c433Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 689bc46bd4Smrg echo "missing $scriptversion (GNU Automake)" 699bc46bd4Smrg exit $? 703294c433Smrg ;; 713294c433Smrg 723294c433Smrg -*) 73f403ce92Smrg echo 1>&2 "$0: unknown '$1' option" 74f403ce92Smrg echo 1>&2 "Try '$0 --help' for more information" 753294c433Smrg exit 1 763294c433Smrg ;; 773294c433Smrg 789bc46bd4Smrgesac 799bc46bd4Smrg 80f403ce92Smrg# Run the given program, remember its exit status. 81f403ce92Smrg"$@"; st=$? 82f403ce92Smrg 83f403ce92Smrg# If it succeeded, we are done. 84f403ce92Smrgtest $st -eq 0 && exit 0 85f403ce92Smrg 86f403ce92Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87f403ce92Smrg# passed; such an option is passed most likely to detect whether the 88f403ce92Smrg# program is present and works. 89f403ce92Smrgcase $2 in --version|--help) exit $st;; esac 90f403ce92Smrg 91f403ce92Smrg# Exit code 63 means version mismatch. This often happens when the user 92f403ce92Smrg# tries to use an ancient version of a tool on a file that requires a 93f403ce92Smrg# minimum version. 94f403ce92Smrgif test $st -eq 63; then 95f403ce92Smrg msg="probably too old" 96f403ce92Smrgelif test $st -eq 127; then 97f403ce92Smrg # Program was missing. 98f403ce92Smrg msg="missing on your system" 99f403ce92Smrgelse 100f403ce92Smrg # Program was found and executed, but failed. Give up. 101f403ce92Smrg exit $st 102f403ce92Smrgfi 1033294c433Smrg 104f403ce92Smrgperl_URL=https://www.perl.org/ 105f403ce92Smrgflex_URL=https://github.com/westes/flex 106f403ce92Smrggnu_software_URL=https://www.gnu.org/software 107f403ce92Smrg 108f403ce92Smrgprogram_details () 109f403ce92Smrg{ 110f403ce92Smrg case $1 in 111f403ce92Smrg aclocal|automake) 112f403ce92Smrg echo "The '$1' program is part of the GNU Automake package:" 113f403ce92Smrg echo "<$gnu_software_URL/automake>" 114f403ce92Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115f403ce92Smrg echo "<$gnu_software_URL/autoconf>" 116f403ce92Smrg echo "<$gnu_software_URL/m4/>" 117f403ce92Smrg echo "<$perl_URL>" 118f403ce92Smrg ;; 119f403ce92Smrg autoconf|autom4te|autoheader) 120f403ce92Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121f403ce92Smrg echo "<$gnu_software_URL/autoconf/>" 122f403ce92Smrg echo "It also requires GNU m4 and Perl in order to run:" 123f403ce92Smrg echo "<$gnu_software_URL/m4/>" 124f403ce92Smrg echo "<$perl_URL>" 125f403ce92Smrg ;; 126f403ce92Smrg esac 127f403ce92Smrg} 128f403ce92Smrg 129f403ce92Smrggive_advice () 130f403ce92Smrg{ 131f403ce92Smrg # Normalize program name to check for. 132f403ce92Smrg normalized_program=`echo "$1" | sed ' 133f403ce92Smrg s/^gnu-//; t 134f403ce92Smrg s/^gnu//; t 135f403ce92Smrg s/^g//; t'` 136f403ce92Smrg 137f403ce92Smrg printf '%s\n' "'$1' is $msg." 138f403ce92Smrg 139f403ce92Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140f403ce92Smrg case $normalized_program in 141f403ce92Smrg autoconf*) 142f403ce92Smrg echo "You should only need it if you modified 'configure.ac'," 143f403ce92Smrg echo "or m4 files included by it." 144f403ce92Smrg program_details 'autoconf' 145f403ce92Smrg ;; 146f403ce92Smrg autoheader*) 147f403ce92Smrg echo "You should only need it if you modified 'acconfig.h' or" 148f403ce92Smrg echo "$configure_deps." 149f403ce92Smrg program_details 'autoheader' 150f403ce92Smrg ;; 151f403ce92Smrg automake*) 152f403ce92Smrg echo "You should only need it if you modified 'Makefile.am' or" 153f403ce92Smrg echo "$configure_deps." 154f403ce92Smrg program_details 'automake' 155f403ce92Smrg ;; 156f403ce92Smrg aclocal*) 157f403ce92Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158f403ce92Smrg echo "$configure_deps." 159f403ce92Smrg program_details 'aclocal' 160f403ce92Smrg ;; 161f403ce92Smrg autom4te*) 162f403ce92Smrg echo "You might have modified some maintainer files that require" 163f403ce92Smrg echo "the 'autom4te' program to be rebuilt." 164f403ce92Smrg program_details 'autom4te' 165f403ce92Smrg ;; 166f403ce92Smrg bison*|yacc*) 167f403ce92Smrg echo "You should only need it if you modified a '.y' file." 168f403ce92Smrg echo "You may want to install the GNU Bison package:" 169f403ce92Smrg echo "<$gnu_software_URL/bison/>" 170f403ce92Smrg ;; 171f403ce92Smrg lex*|flex*) 172f403ce92Smrg echo "You should only need it if you modified a '.l' file." 173f403ce92Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174f403ce92Smrg echo "<$flex_URL>" 175f403ce92Smrg ;; 176f403ce92Smrg help2man*) 177f403ce92Smrg echo "You should only need it if you modified a dependency" \ 178f403ce92Smrg "of a man page." 179f403ce92Smrg echo "You may want to install the GNU Help2man package:" 180f403ce92Smrg echo "<$gnu_software_URL/help2man/>" 181f403ce92Smrg ;; 182f403ce92Smrg makeinfo*) 183f403ce92Smrg echo "You should only need it if you modified a '.texi' file, or" 184f403ce92Smrg echo "any other file indirectly affecting the aspect of the manual." 185f403ce92Smrg echo "You might want to install the Texinfo package:" 186f403ce92Smrg echo "<$gnu_software_URL/texinfo/>" 187f403ce92Smrg echo "The spurious makeinfo call might also be the consequence of" 188f403ce92Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189f403ce92Smrg echo "want to install GNU make:" 190f403ce92Smrg echo "<$gnu_software_URL/make/>" 191f403ce92Smrg ;; 192f403ce92Smrg *) 193f403ce92Smrg echo "You might have modified some files without having the proper" 194f403ce92Smrg echo "tools for further handling them. Check the 'README' file, it" 195f403ce92Smrg echo "often tells you about the needed prerequisites for installing" 196f403ce92Smrg echo "this package. You may also peek at any GNU archive site, in" 197f403ce92Smrg echo "case some other package contains this missing '$1' program." 198f403ce92Smrg ;; 199f403ce92Smrg esac 200f403ce92Smrg} 201f403ce92Smrg 202f403ce92Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203f403ce92Smrg -e '2,$s/^/ /' >&2 204f403ce92Smrg 205f403ce92Smrg# Propagate the correct exit status (expected to be 127 for a program 206f403ce92Smrg# not found, 63 for a program that failed due to version mismatch). 207f403ce92Smrgexit $st 2089bc46bd4Smrg 2099bc46bd4Smrg# Local variables: 210f403ce92Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2119bc46bd4Smrg# time-stamp-start: "scriptversion=" 2129bc46bd4Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213f403ce92Smrg# time-stamp-time-zone: "UTC0" 2149bc46bd4Smrg# time-stamp-end: "; # UTC" 2159bc46bd4Smrg# End: 216