18b22bf3fSmrg#! /bin/sh 2f126e068Smrg# Common wrapper for a few potentially missing GNU programs. 38b22bf3fSmrg 49e1184feSmrgscriptversion=2018-03-07.03; # UTC 58b22bf3fSmrg 614cde9d3Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7f126e068Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 88b22bf3fSmrg 98b22bf3fSmrg# This program is free software; you can redistribute it and/or modify 108b22bf3fSmrg# it under the terms of the GNU General Public License as published by 118b22bf3fSmrg# the Free Software Foundation; either version 2, or (at your option) 128b22bf3fSmrg# any later version. 138b22bf3fSmrg 148b22bf3fSmrg# This program is distributed in the hope that it will be useful, 158b22bf3fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 168b22bf3fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 178b22bf3fSmrg# GNU General Public License for more details. 188b22bf3fSmrg 198b22bf3fSmrg# You should have received a copy of the GNU General Public License 209e1184feSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 218b22bf3fSmrg 228b22bf3fSmrg# As a special exception to the GNU General Public License, if you 238b22bf3fSmrg# distribute this file as part of a program that contains a 248b22bf3fSmrg# configuration script generated by Autoconf, you may include it under 258b22bf3fSmrg# the same distribution terms that you use for the rest of that program. 268b22bf3fSmrg 278b22bf3fSmrgif test $# -eq 0; then 28f126e068Smrg echo 1>&2 "Try '$0 --help' for more information" 298b22bf3fSmrg exit 1 308b22bf3fSmrgfi 318b22bf3fSmrg 32f126e068Smrgcase $1 in 338b22bf3fSmrg 34f126e068Smrg --is-lightweight) 35f126e068Smrg # Used by our autoconf macros to check whether the available missing 36f126e068Smrg # script is modern enough. 37f126e068Smrg exit 0 38f126e068Smrg ;; 398b22bf3fSmrg 40f126e068Smrg --run) 41f126e068Smrg # Back-compat with the calling convention used by older automake. 42f126e068Smrg shift 43f126e068Smrg ;; 448b22bf3fSmrg 458b22bf3fSmrg -h|--h|--he|--hel|--help) 468b22bf3fSmrg echo "\ 478b22bf3fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 488b22bf3fSmrg 49f126e068SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50f126e068Smrgto PROGRAM being missing or too old. 518b22bf3fSmrg 528b22bf3fSmrgOptions: 538b22bf3fSmrg -h, --help display this help and exit 548b22bf3fSmrg -v, --version output version information and exit 558b22bf3fSmrg 568b22bf3fSmrgSupported PROGRAM values: 57f126e068Smrg aclocal autoconf autoheader autom4te automake makeinfo 58f126e068Smrg bison yacc flex lex help2man 598b22bf3fSmrg 60f126e068SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61f126e068Smrg'g' are ignored when checking the name. 6296a81b41Smrg 638b22bf3fSmrgSend bug reports to <bug-automake@gnu.org>." 648b22bf3fSmrg exit $? 658b22bf3fSmrg ;; 668b22bf3fSmrg 678b22bf3fSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 688b22bf3fSmrg echo "missing $scriptversion (GNU Automake)" 698b22bf3fSmrg exit $? 708b22bf3fSmrg ;; 718b22bf3fSmrg 728b22bf3fSmrg -*) 73f126e068Smrg echo 1>&2 "$0: unknown '$1' option" 74f126e068Smrg echo 1>&2 "Try '$0 --help' for more information" 758b22bf3fSmrg exit 1 768b22bf3fSmrg ;; 778b22bf3fSmrg 788b22bf3fSmrgesac 798b22bf3fSmrg 80f126e068Smrg# Run the given program, remember its exit status. 81f126e068Smrg"$@"; st=$? 82f126e068Smrg 83f126e068Smrg# If it succeeded, we are done. 84f126e068Smrgtest $st -eq 0 && exit 0 85f126e068Smrg 86f126e068Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87f126e068Smrg# passed; such an option is passed most likely to detect whether the 88f126e068Smrg# program is present and works. 89f126e068Smrgcase $2 in --version|--help) exit $st;; esac 90f126e068Smrg 91f126e068Smrg# Exit code 63 means version mismatch. This often happens when the user 92f126e068Smrg# tries to use an ancient version of a tool on a file that requires a 93f126e068Smrg# minimum version. 94f126e068Smrgif test $st -eq 63; then 95f126e068Smrg msg="probably too old" 96f126e068Smrgelif test $st -eq 127; then 97f126e068Smrg # Program was missing. 98f126e068Smrg msg="missing on your system" 99f126e068Smrgelse 100f126e068Smrg # Program was found and executed, but failed. Give up. 101f126e068Smrg exit $st 102f126e068Smrgfi 1038b22bf3fSmrg 1049e1184feSmrgperl_URL=https://www.perl.org/ 1059e1184feSmrgflex_URL=https://github.com/westes/flex 1069e1184feSmrggnu_software_URL=https://www.gnu.org/software 107f126e068Smrg 108f126e068Smrgprogram_details () 109f126e068Smrg{ 110f126e068Smrg case $1 in 111f126e068Smrg aclocal|automake) 112f126e068Smrg echo "The '$1' program is part of the GNU Automake package:" 113f126e068Smrg echo "<$gnu_software_URL/automake>" 114f126e068Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115f126e068Smrg echo "<$gnu_software_URL/autoconf>" 116f126e068Smrg echo "<$gnu_software_URL/m4/>" 117f126e068Smrg echo "<$perl_URL>" 118f126e068Smrg ;; 119f126e068Smrg autoconf|autom4te|autoheader) 120f126e068Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121f126e068Smrg echo "<$gnu_software_URL/autoconf/>" 122f126e068Smrg echo "It also requires GNU m4 and Perl in order to run:" 123f126e068Smrg echo "<$gnu_software_URL/m4/>" 124f126e068Smrg echo "<$perl_URL>" 125f126e068Smrg ;; 126f126e068Smrg esac 127f126e068Smrg} 128f126e068Smrg 129f126e068Smrggive_advice () 130f126e068Smrg{ 131f126e068Smrg # Normalize program name to check for. 132f126e068Smrg normalized_program=`echo "$1" | sed ' 133f126e068Smrg s/^gnu-//; t 134f126e068Smrg s/^gnu//; t 135f126e068Smrg s/^g//; t'` 136f126e068Smrg 137f126e068Smrg printf '%s\n' "'$1' is $msg." 138f126e068Smrg 139f126e068Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140f126e068Smrg case $normalized_program in 141f126e068Smrg autoconf*) 142f126e068Smrg echo "You should only need it if you modified 'configure.ac'," 143f126e068Smrg echo "or m4 files included by it." 144f126e068Smrg program_details 'autoconf' 145f126e068Smrg ;; 146f126e068Smrg autoheader*) 147f126e068Smrg echo "You should only need it if you modified 'acconfig.h' or" 148f126e068Smrg echo "$configure_deps." 149f126e068Smrg program_details 'autoheader' 150f126e068Smrg ;; 151f126e068Smrg automake*) 152f126e068Smrg echo "You should only need it if you modified 'Makefile.am' or" 153f126e068Smrg echo "$configure_deps." 154f126e068Smrg program_details 'automake' 155f126e068Smrg ;; 156f126e068Smrg aclocal*) 157f126e068Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158f126e068Smrg echo "$configure_deps." 159f126e068Smrg program_details 'aclocal' 160f126e068Smrg ;; 161f126e068Smrg autom4te*) 162f126e068Smrg echo "You might have modified some maintainer files that require" 163c74b14bdSmrg echo "the 'autom4te' program to be rebuilt." 164f126e068Smrg program_details 'autom4te' 165f126e068Smrg ;; 166f126e068Smrg bison*|yacc*) 167f126e068Smrg echo "You should only need it if you modified a '.y' file." 168f126e068Smrg echo "You may want to install the GNU Bison package:" 169f126e068Smrg echo "<$gnu_software_URL/bison/>" 170f126e068Smrg ;; 171f126e068Smrg lex*|flex*) 172f126e068Smrg echo "You should only need it if you modified a '.l' file." 173f126e068Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174f126e068Smrg echo "<$flex_URL>" 175f126e068Smrg ;; 176f126e068Smrg help2man*) 177f126e068Smrg echo "You should only need it if you modified a dependency" \ 178f126e068Smrg "of a man page." 179f126e068Smrg echo "You may want to install the GNU Help2man package:" 180f126e068Smrg echo "<$gnu_software_URL/help2man/>" 181f126e068Smrg ;; 182f126e068Smrg makeinfo*) 183f126e068Smrg echo "You should only need it if you modified a '.texi' file, or" 184f126e068Smrg echo "any other file indirectly affecting the aspect of the manual." 185f126e068Smrg echo "You might want to install the Texinfo package:" 186f126e068Smrg echo "<$gnu_software_URL/texinfo/>" 187f126e068Smrg echo "The spurious makeinfo call might also be the consequence of" 188f126e068Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189f126e068Smrg echo "want to install GNU make:" 190f126e068Smrg echo "<$gnu_software_URL/make/>" 191f126e068Smrg ;; 192f126e068Smrg *) 193f126e068Smrg echo "You might have modified some files without having the proper" 194f126e068Smrg echo "tools for further handling them. Check the 'README' file, it" 195f126e068Smrg echo "often tells you about the needed prerequisites for installing" 196f126e068Smrg echo "this package. You may also peek at any GNU archive site, in" 197f126e068Smrg echo "case some other package contains this missing '$1' program." 198f126e068Smrg ;; 199f126e068Smrg esac 200f126e068Smrg} 201f126e068Smrg 202f126e068Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203f126e068Smrg -e '2,$s/^/ /' >&2 204f126e068Smrg 205f126e068Smrg# Propagate the correct exit status (expected to be 127 for a program 206f126e068Smrg# not found, 63 for a program that failed due to version mismatch). 207f126e068Smrgexit $st 2088b22bf3fSmrg 2098b22bf3fSmrg# Local variables: 2109e1184feSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2118b22bf3fSmrg# time-stamp-start: "scriptversion=" 2128b22bf3fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2139e1184feSmrg# time-stamp-time-zone: "UTC0" 21496a81b41Smrg# time-stamp-end: "; # UTC" 2158b22bf3fSmrg# End: 216