117ca54c3Smrg#! /bin/sh 2ea1d6981Smrg# Common wrapper for a few potentially missing GNU programs. 317ca54c3Smrg 4ea1d6981Smrgscriptversion=2018-03-07.03; # UTC 517ca54c3Smrg 6ffe57424Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7ea1d6981Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 817ca54c3Smrg 917ca54c3Smrg# This program is free software; you can redistribute it and/or modify 1017ca54c3Smrg# it under the terms of the GNU General Public License as published by 1117ca54c3Smrg# the Free Software Foundation; either version 2, or (at your option) 1217ca54c3Smrg# any later version. 1317ca54c3Smrg 1417ca54c3Smrg# This program is distributed in the hope that it will be useful, 1517ca54c3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1617ca54c3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1717ca54c3Smrg# GNU General Public License for more details. 1817ca54c3Smrg 1917ca54c3Smrg# You should have received a copy of the GNU General Public License 20ea1d6981Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2117ca54c3Smrg 2217ca54c3Smrg# As a special exception to the GNU General Public License, if you 2317ca54c3Smrg# distribute this file as part of a program that contains a 2417ca54c3Smrg# configuration script generated by Autoconf, you may include it under 2517ca54c3Smrg# the same distribution terms that you use for the rest of that program. 2617ca54c3Smrg 2717ca54c3Smrgif test $# -eq 0; then 28ea1d6981Smrg echo 1>&2 "Try '$0 --help' for more information" 2917ca54c3Smrg exit 1 3017ca54c3Smrgfi 3117ca54c3Smrg 32ea1d6981Smrgcase $1 in 3317ca54c3Smrg 34ea1d6981Smrg --is-lightweight) 35ea1d6981Smrg # Used by our autoconf macros to check whether the available missing 36ea1d6981Smrg # script is modern enough. 37ea1d6981Smrg exit 0 38ea1d6981Smrg ;; 3917ca54c3Smrg 40ea1d6981Smrg --run) 41ea1d6981Smrg # Back-compat with the calling convention used by older automake. 42ea1d6981Smrg shift 43ea1d6981Smrg ;; 4417ca54c3Smrg 4517ca54c3Smrg -h|--h|--he|--hel|--help) 4617ca54c3Smrg echo "\ 4717ca54c3Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4817ca54c3Smrg 49ea1d6981SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50ea1d6981Smrgto PROGRAM being missing or too old. 5117ca54c3Smrg 5217ca54c3SmrgOptions: 5317ca54c3Smrg -h, --help display this help and exit 5417ca54c3Smrg -v, --version output version information and exit 5517ca54c3Smrg 5617ca54c3SmrgSupported PROGRAM values: 57ea1d6981Smrg aclocal autoconf autoheader autom4te automake makeinfo 58ea1d6981Smrg bison yacc flex lex help2man 59ea1d6981Smrg 60ea1d6981SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61ea1d6981Smrg'g' are ignored when checking the name. 6217ca54c3Smrg 6317ca54c3SmrgSend bug reports to <bug-automake@gnu.org>." 64ea1d6981Smrg exit $? 6517ca54c3Smrg ;; 6617ca54c3Smrg 6717ca54c3Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6817ca54c3Smrg echo "missing $scriptversion (GNU Automake)" 69ea1d6981Smrg exit $? 7017ca54c3Smrg ;; 7117ca54c3Smrg 7217ca54c3Smrg -*) 73ea1d6981Smrg echo 1>&2 "$0: unknown '$1' option" 74ea1d6981Smrg echo 1>&2 "Try '$0 --help' for more information" 7517ca54c3Smrg exit 1 7617ca54c3Smrg ;; 7717ca54c3Smrg 78ea1d6981Smrgesac 7917ca54c3Smrg 80ea1d6981Smrg# Run the given program, remember its exit status. 81ea1d6981Smrg"$@"; st=$? 82ea1d6981Smrg 83ea1d6981Smrg# If it succeeded, we are done. 84ea1d6981Smrgtest $st -eq 0 && exit 0 85ea1d6981Smrg 86ea1d6981Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87ea1d6981Smrg# passed; such an option is passed most likely to detect whether the 88ea1d6981Smrg# program is present and works. 89ea1d6981Smrgcase $2 in --version|--help) exit $st;; esac 90ea1d6981Smrg 91ea1d6981Smrg# Exit code 63 means version mismatch. This often happens when the user 92ea1d6981Smrg# tries to use an ancient version of a tool on a file that requires a 93ea1d6981Smrg# minimum version. 94ea1d6981Smrgif test $st -eq 63; then 95ea1d6981Smrg msg="probably too old" 96ea1d6981Smrgelif test $st -eq 127; then 97ea1d6981Smrg # Program was missing. 98ea1d6981Smrg msg="missing on your system" 99ea1d6981Smrgelse 100ea1d6981Smrg # Program was found and executed, but failed. Give up. 101ea1d6981Smrg exit $st 102ea1d6981Smrgfi 10317ca54c3Smrg 104ea1d6981Smrgperl_URL=https://www.perl.org/ 105ea1d6981Smrgflex_URL=https://github.com/westes/flex 106ea1d6981Smrggnu_software_URL=https://www.gnu.org/software 107ea1d6981Smrg 108ea1d6981Smrgprogram_details () 109ea1d6981Smrg{ 110ea1d6981Smrg case $1 in 111ea1d6981Smrg aclocal|automake) 112ea1d6981Smrg echo "The '$1' program is part of the GNU Automake package:" 113ea1d6981Smrg echo "<$gnu_software_URL/automake>" 114ea1d6981Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115ea1d6981Smrg echo "<$gnu_software_URL/autoconf>" 116ea1d6981Smrg echo "<$gnu_software_URL/m4/>" 117ea1d6981Smrg echo "<$perl_URL>" 118ea1d6981Smrg ;; 119ea1d6981Smrg autoconf|autom4te|autoheader) 120ea1d6981Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121ea1d6981Smrg echo "<$gnu_software_URL/autoconf/>" 122ea1d6981Smrg echo "It also requires GNU m4 and Perl in order to run:" 123ea1d6981Smrg echo "<$gnu_software_URL/m4/>" 124ea1d6981Smrg echo "<$perl_URL>" 125ea1d6981Smrg ;; 126ea1d6981Smrg esac 127ea1d6981Smrg} 128ea1d6981Smrg 129ea1d6981Smrggive_advice () 130ea1d6981Smrg{ 131ea1d6981Smrg # Normalize program name to check for. 132ea1d6981Smrg normalized_program=`echo "$1" | sed ' 133ea1d6981Smrg s/^gnu-//; t 134ea1d6981Smrg s/^gnu//; t 135ea1d6981Smrg s/^g//; t'` 136ea1d6981Smrg 137ea1d6981Smrg printf '%s\n' "'$1' is $msg." 138ea1d6981Smrg 139ea1d6981Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140ea1d6981Smrg case $normalized_program in 141ea1d6981Smrg autoconf*) 142ea1d6981Smrg echo "You should only need it if you modified 'configure.ac'," 143ea1d6981Smrg echo "or m4 files included by it." 144ea1d6981Smrg program_details 'autoconf' 145ea1d6981Smrg ;; 146ea1d6981Smrg autoheader*) 147ea1d6981Smrg echo "You should only need it if you modified 'acconfig.h' or" 148ea1d6981Smrg echo "$configure_deps." 149ea1d6981Smrg program_details 'autoheader' 150ea1d6981Smrg ;; 151ea1d6981Smrg automake*) 152ea1d6981Smrg echo "You should only need it if you modified 'Makefile.am' or" 153ea1d6981Smrg echo "$configure_deps." 154ea1d6981Smrg program_details 'automake' 155ea1d6981Smrg ;; 156ea1d6981Smrg aclocal*) 157ea1d6981Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158ea1d6981Smrg echo "$configure_deps." 159ea1d6981Smrg program_details 'aclocal' 160ea1d6981Smrg ;; 161ea1d6981Smrg autom4te*) 162ea1d6981Smrg echo "You might have modified some maintainer files that require" 163ea1d6981Smrg echo "the 'autom4te' program to be rebuilt." 164ea1d6981Smrg program_details 'autom4te' 165ea1d6981Smrg ;; 166ea1d6981Smrg bison*|yacc*) 167ea1d6981Smrg echo "You should only need it if you modified a '.y' file." 168ea1d6981Smrg echo "You may want to install the GNU Bison package:" 169ea1d6981Smrg echo "<$gnu_software_URL/bison/>" 170ea1d6981Smrg ;; 171ea1d6981Smrg lex*|flex*) 172ea1d6981Smrg echo "You should only need it if you modified a '.l' file." 173ea1d6981Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174ea1d6981Smrg echo "<$flex_URL>" 175ea1d6981Smrg ;; 176ea1d6981Smrg help2man*) 177ea1d6981Smrg echo "You should only need it if you modified a dependency" \ 178ea1d6981Smrg "of a man page." 179ea1d6981Smrg echo "You may want to install the GNU Help2man package:" 180ea1d6981Smrg echo "<$gnu_software_URL/help2man/>" 18117ca54c3Smrg ;; 182ea1d6981Smrg makeinfo*) 183ea1d6981Smrg echo "You should only need it if you modified a '.texi' file, or" 184ea1d6981Smrg echo "any other file indirectly affecting the aspect of the manual." 185ea1d6981Smrg echo "You might want to install the Texinfo package:" 186ea1d6981Smrg echo "<$gnu_software_URL/texinfo/>" 187ea1d6981Smrg echo "The spurious makeinfo call might also be the consequence of" 188ea1d6981Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189ea1d6981Smrg echo "want to install GNU make:" 190ea1d6981Smrg echo "<$gnu_software_URL/make/>" 191ea1d6981Smrg ;; 192ea1d6981Smrg *) 193ea1d6981Smrg echo "You might have modified some files without having the proper" 194ea1d6981Smrg echo "tools for further handling them. Check the 'README' file, it" 195ea1d6981Smrg echo "often tells you about the needed prerequisites for installing" 196ea1d6981Smrg echo "this package. You may also peek at any GNU archive site, in" 197ea1d6981Smrg echo "case some other package contains this missing '$1' program." 198ea1d6981Smrg ;; 199ea1d6981Smrg esac 200ea1d6981Smrg} 201ea1d6981Smrg 202ea1d6981Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203ea1d6981Smrg -e '2,$s/^/ /' >&2 204ea1d6981Smrg 205ea1d6981Smrg# Propagate the correct exit status (expected to be 127 for a program 206ea1d6981Smrg# not found, 63 for a program that failed due to version mismatch). 207ea1d6981Smrgexit $st 20817ca54c3Smrg 20917ca54c3Smrg# Local variables: 210ea1d6981Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 21117ca54c3Smrg# time-stamp-start: "scriptversion=" 21217ca54c3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213ea1d6981Smrg# time-stamp-time-zone: "UTC0" 214ea1d6981Smrg# time-stamp-end: "; # UTC" 21517ca54c3Smrg# End: 216