19bd41f2cSmrg#! /bin/sh 2084f91ccSmrg# Common wrapper for a few potentially missing GNU programs. 39bd41f2cSmrg 4084f91ccSmrgscriptversion=2018-03-07.03; # UTC 59bd41f2cSmrg 6084f91ccSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7084f91ccSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 89bd41f2cSmrg 99bd41f2cSmrg# This program is free software; you can redistribute it and/or modify 109bd41f2cSmrg# it under the terms of the GNU General Public License as published by 119bd41f2cSmrg# the Free Software Foundation; either version 2, or (at your option) 129bd41f2cSmrg# any later version. 139bd41f2cSmrg 149bd41f2cSmrg# This program is distributed in the hope that it will be useful, 159bd41f2cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 169bd41f2cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 179bd41f2cSmrg# GNU General Public License for more details. 189bd41f2cSmrg 199bd41f2cSmrg# You should have received a copy of the GNU General Public License 20084f91ccSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 219bd41f2cSmrg 229bd41f2cSmrg# As a special exception to the GNU General Public License, if you 239bd41f2cSmrg# distribute this file as part of a program that contains a 249bd41f2cSmrg# configuration script generated by Autoconf, you may include it under 259bd41f2cSmrg# the same distribution terms that you use for the rest of that program. 269bd41f2cSmrg 279bd41f2cSmrgif test $# -eq 0; then 28084f91ccSmrg echo 1>&2 "Try '$0 --help' for more information" 299bd41f2cSmrg exit 1 309bd41f2cSmrgfi 319bd41f2cSmrg 32084f91ccSmrgcase $1 in 339bd41f2cSmrg 34084f91ccSmrg --is-lightweight) 35084f91ccSmrg # Used by our autoconf macros to check whether the available missing 36084f91ccSmrg # script is modern enough. 37084f91ccSmrg exit 0 38084f91ccSmrg ;; 399bd41f2cSmrg 40084f91ccSmrg --run) 41084f91ccSmrg # Back-compat with the calling convention used by older automake. 42084f91ccSmrg shift 43084f91ccSmrg ;; 449bd41f2cSmrg 459bd41f2cSmrg -h|--h|--he|--hel|--help) 469bd41f2cSmrg echo "\ 479bd41f2cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 489bd41f2cSmrg 49084f91ccSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50084f91ccSmrgto PROGRAM being missing or too old. 519bd41f2cSmrg 529bd41f2cSmrgOptions: 539bd41f2cSmrg -h, --help display this help and exit 549bd41f2cSmrg -v, --version output version information and exit 559bd41f2cSmrg 569bd41f2cSmrgSupported PROGRAM values: 57084f91ccSmrg aclocal autoconf autoheader autom4te automake makeinfo 58084f91ccSmrg bison yacc flex lex help2man 599bd41f2cSmrg 60084f91ccSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61084f91ccSmrg'g' are ignored when checking the name. 620da4cdccSmrg 639bd41f2cSmrgSend bug reports to <bug-automake@gnu.org>." 649bd41f2cSmrg exit $? 659bd41f2cSmrg ;; 669bd41f2cSmrg 679bd41f2cSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 689bd41f2cSmrg echo "missing $scriptversion (GNU Automake)" 699bd41f2cSmrg exit $? 709bd41f2cSmrg ;; 719bd41f2cSmrg 729bd41f2cSmrg -*) 73084f91ccSmrg echo 1>&2 "$0: unknown '$1' option" 74084f91ccSmrg echo 1>&2 "Try '$0 --help' for more information" 759bd41f2cSmrg exit 1 769bd41f2cSmrg ;; 779bd41f2cSmrg 789bd41f2cSmrgesac 799bd41f2cSmrg 80084f91ccSmrg# Run the given program, remember its exit status. 81084f91ccSmrg"$@"; st=$? 82084f91ccSmrg 83084f91ccSmrg# If it succeeded, we are done. 84084f91ccSmrgtest $st -eq 0 && exit 0 85084f91ccSmrg 86084f91ccSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 87084f91ccSmrg# passed; such an option is passed most likely to detect whether the 88084f91ccSmrg# program is present and works. 89084f91ccSmrgcase $2 in --version|--help) exit $st;; esac 90084f91ccSmrg 91084f91ccSmrg# Exit code 63 means version mismatch. This often happens when the user 92084f91ccSmrg# tries to use an ancient version of a tool on a file that requires a 93084f91ccSmrg# minimum version. 94084f91ccSmrgif test $st -eq 63; then 95084f91ccSmrg msg="probably too old" 96084f91ccSmrgelif test $st -eq 127; then 97084f91ccSmrg # Program was missing. 98084f91ccSmrg msg="missing on your system" 99084f91ccSmrgelse 100084f91ccSmrg # Program was found and executed, but failed. Give up. 101084f91ccSmrg exit $st 102084f91ccSmrgfi 1039bd41f2cSmrg 104084f91ccSmrgperl_URL=https://www.perl.org/ 105084f91ccSmrgflex_URL=https://github.com/westes/flex 106084f91ccSmrggnu_software_URL=https://www.gnu.org/software 107084f91ccSmrg 108084f91ccSmrgprogram_details () 109084f91ccSmrg{ 110084f91ccSmrg case $1 in 111084f91ccSmrg aclocal|automake) 112084f91ccSmrg echo "The '$1' program is part of the GNU Automake package:" 113084f91ccSmrg echo "<$gnu_software_URL/automake>" 114084f91ccSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115084f91ccSmrg echo "<$gnu_software_URL/autoconf>" 116084f91ccSmrg echo "<$gnu_software_URL/m4/>" 117084f91ccSmrg echo "<$perl_URL>" 118084f91ccSmrg ;; 119084f91ccSmrg autoconf|autom4te|autoheader) 120084f91ccSmrg echo "The '$1' program is part of the GNU Autoconf package:" 121084f91ccSmrg echo "<$gnu_software_URL/autoconf/>" 122084f91ccSmrg echo "It also requires GNU m4 and Perl in order to run:" 123084f91ccSmrg echo "<$gnu_software_URL/m4/>" 124084f91ccSmrg echo "<$perl_URL>" 125084f91ccSmrg ;; 126084f91ccSmrg esac 127084f91ccSmrg} 128084f91ccSmrg 129084f91ccSmrggive_advice () 130084f91ccSmrg{ 131084f91ccSmrg # Normalize program name to check for. 132084f91ccSmrg normalized_program=`echo "$1" | sed ' 133084f91ccSmrg s/^gnu-//; t 134084f91ccSmrg s/^gnu//; t 135084f91ccSmrg s/^g//; t'` 136084f91ccSmrg 137084f91ccSmrg printf '%s\n' "'$1' is $msg." 138084f91ccSmrg 139084f91ccSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140084f91ccSmrg case $normalized_program in 141084f91ccSmrg autoconf*) 142084f91ccSmrg echo "You should only need it if you modified 'configure.ac'," 143084f91ccSmrg echo "or m4 files included by it." 144084f91ccSmrg program_details 'autoconf' 145084f91ccSmrg ;; 146084f91ccSmrg autoheader*) 147084f91ccSmrg echo "You should only need it if you modified 'acconfig.h' or" 148084f91ccSmrg echo "$configure_deps." 149084f91ccSmrg program_details 'autoheader' 150084f91ccSmrg ;; 151084f91ccSmrg automake*) 152084f91ccSmrg echo "You should only need it if you modified 'Makefile.am' or" 153084f91ccSmrg echo "$configure_deps." 154084f91ccSmrg program_details 'automake' 155084f91ccSmrg ;; 156084f91ccSmrg aclocal*) 157084f91ccSmrg echo "You should only need it if you modified 'acinclude.m4' or" 158084f91ccSmrg echo "$configure_deps." 159084f91ccSmrg program_details 'aclocal' 160084f91ccSmrg ;; 161084f91ccSmrg autom4te*) 162084f91ccSmrg echo "You might have modified some maintainer files that require" 163084f91ccSmrg echo "the 'autom4te' program to be rebuilt." 164084f91ccSmrg program_details 'autom4te' 165084f91ccSmrg ;; 166084f91ccSmrg bison*|yacc*) 167084f91ccSmrg echo "You should only need it if you modified a '.y' file." 168084f91ccSmrg echo "You may want to install the GNU Bison package:" 169084f91ccSmrg echo "<$gnu_software_URL/bison/>" 170084f91ccSmrg ;; 171084f91ccSmrg lex*|flex*) 172084f91ccSmrg echo "You should only need it if you modified a '.l' file." 173084f91ccSmrg echo "You may want to install the Fast Lexical Analyzer package:" 174084f91ccSmrg echo "<$flex_URL>" 175084f91ccSmrg ;; 176084f91ccSmrg help2man*) 177084f91ccSmrg echo "You should only need it if you modified a dependency" \ 178084f91ccSmrg "of a man page." 179084f91ccSmrg echo "You may want to install the GNU Help2man package:" 180084f91ccSmrg echo "<$gnu_software_URL/help2man/>" 1819bd41f2cSmrg ;; 182084f91ccSmrg makeinfo*) 183084f91ccSmrg echo "You should only need it if you modified a '.texi' file, or" 184084f91ccSmrg echo "any other file indirectly affecting the aspect of the manual." 185084f91ccSmrg echo "You might want to install the Texinfo package:" 186084f91ccSmrg echo "<$gnu_software_URL/texinfo/>" 187084f91ccSmrg echo "The spurious makeinfo call might also be the consequence of" 188084f91ccSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189084f91ccSmrg echo "want to install GNU make:" 190084f91ccSmrg echo "<$gnu_software_URL/make/>" 191084f91ccSmrg ;; 192084f91ccSmrg *) 193084f91ccSmrg echo "You might have modified some files without having the proper" 194084f91ccSmrg echo "tools for further handling them. Check the 'README' file, it" 195084f91ccSmrg echo "often tells you about the needed prerequisites for installing" 196084f91ccSmrg echo "this package. You may also peek at any GNU archive site, in" 197084f91ccSmrg echo "case some other package contains this missing '$1' program." 198084f91ccSmrg ;; 199084f91ccSmrg esac 200084f91ccSmrg} 201084f91ccSmrg 202084f91ccSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203084f91ccSmrg -e '2,$s/^/ /' >&2 204084f91ccSmrg 205084f91ccSmrg# Propagate the correct exit status (expected to be 127 for a program 206084f91ccSmrg# not found, 63 for a program that failed due to version mismatch). 207084f91ccSmrgexit $st 2089bd41f2cSmrg 2099bd41f2cSmrg# Local variables: 210084f91ccSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2119bd41f2cSmrg# time-stamp-start: "scriptversion=" 2129bd41f2cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213084f91ccSmrg# time-stamp-time-zone: "UTC0" 2140da4cdccSmrg# time-stamp-end: "; # UTC" 2159bd41f2cSmrg# End: 216