15dfecf96Smrg#! /bin/sh 2f765521fSmrg# Common wrapper for a few potentially missing GNU programs. 35dfecf96Smrg 496d43ffdSmrgscriptversion=2018-03-07.03; # UTC 55dfecf96Smrg 696d43ffdSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7f765521fSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 85dfecf96Smrg 95dfecf96Smrg# This program is free software; you can redistribute it and/or modify 105dfecf96Smrg# it under the terms of the GNU General Public License as published by 115dfecf96Smrg# the Free Software Foundation; either version 2, or (at your option) 125dfecf96Smrg# any later version. 135dfecf96Smrg 145dfecf96Smrg# This program is distributed in the hope that it will be useful, 155dfecf96Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 165dfecf96Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 175dfecf96Smrg# GNU General Public License for more details. 185dfecf96Smrg 195dfecf96Smrg# You should have received a copy of the GNU General Public License 2096d43ffdSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 215dfecf96Smrg 225dfecf96Smrg# As a special exception to the GNU General Public License, if you 235dfecf96Smrg# distribute this file as part of a program that contains a 245dfecf96Smrg# configuration script generated by Autoconf, you may include it under 255dfecf96Smrg# the same distribution terms that you use for the rest of that program. 265dfecf96Smrg 275dfecf96Smrgif test $# -eq 0; then 28f765521fSmrg echo 1>&2 "Try '$0 --help' for more information" 295dfecf96Smrg exit 1 305dfecf96Smrgfi 315dfecf96Smrg 32f765521fSmrgcase $1 in 335dfecf96Smrg 34f765521fSmrg --is-lightweight) 35f765521fSmrg # Used by our autoconf macros to check whether the available missing 36f765521fSmrg # script is modern enough. 37f765521fSmrg exit 0 38f765521fSmrg ;; 395dfecf96Smrg 40f765521fSmrg --run) 41f765521fSmrg # Back-compat with the calling convention used by older automake. 42f765521fSmrg shift 43f765521fSmrg ;; 445dfecf96Smrg 455dfecf96Smrg -h|--h|--he|--hel|--help) 465dfecf96Smrg echo "\ 475dfecf96Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 485dfecf96Smrg 49f765521fSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50f765521fSmrgto PROGRAM being missing or too old. 515dfecf96Smrg 525dfecf96SmrgOptions: 535dfecf96Smrg -h, --help display this help and exit 545dfecf96Smrg -v, --version output version information and exit 555dfecf96Smrg 565dfecf96SmrgSupported PROGRAM values: 57f765521fSmrg aclocal autoconf autoheader autom4te automake makeinfo 58f765521fSmrg bison yacc flex lex help2man 595dfecf96Smrg 60f765521fSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61f765521fSmrg'g' are ignored when checking the name. 62c05e22d7Smrg 635dfecf96SmrgSend bug reports to <bug-automake@gnu.org>." 645dfecf96Smrg exit $? 655dfecf96Smrg ;; 665dfecf96Smrg 675dfecf96Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 685dfecf96Smrg echo "missing $scriptversion (GNU Automake)" 695dfecf96Smrg exit $? 705dfecf96Smrg ;; 715dfecf96Smrg 725dfecf96Smrg -*) 73f765521fSmrg echo 1>&2 "$0: unknown '$1' option" 74f765521fSmrg echo 1>&2 "Try '$0 --help' for more information" 755dfecf96Smrg exit 1 765dfecf96Smrg ;; 775dfecf96Smrg 785dfecf96Smrgesac 795dfecf96Smrg 80f765521fSmrg# Run the given program, remember its exit status. 81f765521fSmrg"$@"; st=$? 82f765521fSmrg 83f765521fSmrg# If it succeeded, we are done. 84f765521fSmrgtest $st -eq 0 && exit 0 85f765521fSmrg 86f765521fSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87f765521fSmrg# passed; such an option is passed most likely to detect whether the 88f765521fSmrg# program is present and works. 89f765521fSmrgcase $2 in --version|--help) exit $st;; esac 90f765521fSmrg 91f765521fSmrg# Exit code 63 means version mismatch. This often happens when the user 92f765521fSmrg# tries to use an ancient version of a tool on a file that requires a 93f765521fSmrg# minimum version. 94f765521fSmrgif test $st -eq 63; then 95f765521fSmrg msg="probably too old" 96f765521fSmrgelif test $st -eq 127; then 97f765521fSmrg # Program was missing. 98f765521fSmrg msg="missing on your system" 99f765521fSmrgelse 100f765521fSmrg # Program was found and executed, but failed. Give up. 101f765521fSmrg exit $st 102f765521fSmrgfi 1035dfecf96Smrg 10496d43ffdSmrgperl_URL=https://www.perl.org/ 10596d43ffdSmrgflex_URL=https://github.com/westes/flex 10696d43ffdSmrggnu_software_URL=https://www.gnu.org/software 107f765521fSmrg 108f765521fSmrgprogram_details () 109f765521fSmrg{ 110f765521fSmrg case $1 in 111f765521fSmrg aclocal|automake) 112f765521fSmrg echo "The '$1' program is part of the GNU Automake package:" 113f765521fSmrg echo "<$gnu_software_URL/automake>" 114f765521fSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115f765521fSmrg echo "<$gnu_software_URL/autoconf>" 116f765521fSmrg echo "<$gnu_software_URL/m4/>" 117f765521fSmrg echo "<$perl_URL>" 118f765521fSmrg ;; 119f765521fSmrg autoconf|autom4te|autoheader) 120f765521fSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121f765521fSmrg echo "<$gnu_software_URL/autoconf/>" 122f765521fSmrg echo "It also requires GNU m4 and Perl in order to run:" 123f765521fSmrg echo "<$gnu_software_URL/m4/>" 124f765521fSmrg echo "<$perl_URL>" 125f765521fSmrg ;; 126f765521fSmrg esac 127f765521fSmrg} 128f765521fSmrg 129f765521fSmrggive_advice () 130f765521fSmrg{ 131f765521fSmrg # Normalize program name to check for. 132f765521fSmrg normalized_program=`echo "$1" | sed ' 133f765521fSmrg s/^gnu-//; t 134f765521fSmrg s/^gnu//; t 135f765521fSmrg s/^g//; t'` 136f765521fSmrg 137f765521fSmrg printf '%s\n' "'$1' is $msg." 138f765521fSmrg 139f765521fSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140f765521fSmrg case $normalized_program in 141f765521fSmrg autoconf*) 142f765521fSmrg echo "You should only need it if you modified 'configure.ac'," 143f765521fSmrg echo "or m4 files included by it." 144f765521fSmrg program_details 'autoconf' 145f765521fSmrg ;; 146f765521fSmrg autoheader*) 147f765521fSmrg echo "You should only need it if you modified 'acconfig.h' or" 148f765521fSmrg echo "$configure_deps." 149f765521fSmrg program_details 'autoheader' 150f765521fSmrg ;; 151f765521fSmrg automake*) 152f765521fSmrg echo "You should only need it if you modified 'Makefile.am' or" 153f765521fSmrg echo "$configure_deps." 154f765521fSmrg program_details 'automake' 155f765521fSmrg ;; 156f765521fSmrg aclocal*) 157f765521fSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158f765521fSmrg echo "$configure_deps." 159f765521fSmrg program_details 'aclocal' 160f765521fSmrg ;; 161f765521fSmrg autom4te*) 162f765521fSmrg echo "You might have modified some maintainer files that require" 16396d43ffdSmrg echo "the 'autom4te' program to be rebuilt." 164f765521fSmrg program_details 'autom4te' 165f765521fSmrg ;; 166f765521fSmrg bison*|yacc*) 167f765521fSmrg echo "You should only need it if you modified a '.y' file." 168f765521fSmrg echo "You may want to install the GNU Bison package:" 169f765521fSmrg echo "<$gnu_software_URL/bison/>" 170f765521fSmrg ;; 171f765521fSmrg lex*|flex*) 172f765521fSmrg echo "You should only need it if you modified a '.l' file." 173f765521fSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174f765521fSmrg echo "<$flex_URL>" 175f765521fSmrg ;; 176f765521fSmrg help2man*) 177f765521fSmrg echo "You should only need it if you modified a dependency" \ 178f765521fSmrg "of a man page." 179f765521fSmrg echo "You may want to install the GNU Help2man package:" 180f765521fSmrg echo "<$gnu_software_URL/help2man/>" 181f765521fSmrg ;; 182f765521fSmrg makeinfo*) 183f765521fSmrg echo "You should only need it if you modified a '.texi' file, or" 184f765521fSmrg echo "any other file indirectly affecting the aspect of the manual." 185f765521fSmrg echo "You might want to install the Texinfo package:" 186f765521fSmrg echo "<$gnu_software_URL/texinfo/>" 187f765521fSmrg echo "The spurious makeinfo call might also be the consequence of" 188f765521fSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189f765521fSmrg echo "want to install GNU make:" 190f765521fSmrg echo "<$gnu_software_URL/make/>" 191f765521fSmrg ;; 192f765521fSmrg *) 193f765521fSmrg echo "You might have modified some files without having the proper" 194f765521fSmrg echo "tools for further handling them. Check the 'README' file, it" 195f765521fSmrg echo "often tells you about the needed prerequisites for installing" 196f765521fSmrg echo "this package. You may also peek at any GNU archive site, in" 197f765521fSmrg echo "case some other package contains this missing '$1' program." 198f765521fSmrg ;; 199f765521fSmrg esac 200f765521fSmrg} 201f765521fSmrg 202f765521fSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203f765521fSmrg -e '2,$s/^/ /' >&2 204f765521fSmrg 205f765521fSmrg# Propagate the correct exit status (expected to be 127 for a program 206f765521fSmrg# not found, 63 for a program that failed due to version mismatch). 207f765521fSmrgexit $st 2085dfecf96Smrg 2095dfecf96Smrg# Local variables: 21096d43ffdSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2115dfecf96Smrg# time-stamp-start: "scriptversion=" 2125dfecf96Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 21396d43ffdSmrg# time-stamp-time-zone: "UTC0" 214c05e22d7Smrg# time-stamp-end: "; # UTC" 2155dfecf96Smrg# End: 216