109885543Smrg#! /bin/sh 2df9ffc95Smrg# Common wrapper for a few potentially missing GNU programs. 309885543Smrg 4beef1b22Smrgscriptversion=2018-03-07.03; # UTC 509885543Smrg 6beef1b22Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 7df9ffc95Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 809885543Smrg 909885543Smrg# This program is free software; you can redistribute it and/or modify 1009885543Smrg# it under the terms of the GNU General Public License as published by 1109885543Smrg# the Free Software Foundation; either version 2, or (at your option) 1209885543Smrg# any later version. 1309885543Smrg 1409885543Smrg# This program is distributed in the hope that it will be useful, 1509885543Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1609885543Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1709885543Smrg# GNU General Public License for more details. 1809885543Smrg 1909885543Smrg# You should have received a copy of the GNU General Public License 20beef1b22Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2109885543Smrg 2209885543Smrg# As a special exception to the GNU General Public License, if you 2309885543Smrg# distribute this file as part of a program that contains a 2409885543Smrg# configuration script generated by Autoconf, you may include it under 2509885543Smrg# the same distribution terms that you use for the rest of that program. 2609885543Smrg 2709885543Smrgif test $# -eq 0; then 28df9ffc95Smrg echo 1>&2 "Try '$0 --help' for more information" 2909885543Smrg exit 1 3009885543Smrgfi 3109885543Smrg 32df9ffc95Smrgcase $1 in 3309885543Smrg 34df9ffc95Smrg --is-lightweight) 35df9ffc95Smrg # Used by our autoconf macros to check whether the available missing 36df9ffc95Smrg # script is modern enough. 37df9ffc95Smrg exit 0 38df9ffc95Smrg ;; 3909885543Smrg 40df9ffc95Smrg --run) 41df9ffc95Smrg # Back-compat with the calling convention used by older automake. 42df9ffc95Smrg shift 43df9ffc95Smrg ;; 4409885543Smrg 4509885543Smrg -h|--h|--he|--hel|--help) 4609885543Smrg echo "\ 4709885543Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4809885543Smrg 49df9ffc95SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50df9ffc95Smrgto PROGRAM being missing or too old. 5109885543Smrg 5209885543SmrgOptions: 5309885543Smrg -h, --help display this help and exit 5409885543Smrg -v, --version output version information and exit 5509885543Smrg 5609885543SmrgSupported PROGRAM values: 57df9ffc95Smrg aclocal autoconf autoheader autom4te automake makeinfo 58df9ffc95Smrg bison yacc flex lex help2man 5909885543Smrg 60df9ffc95SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61df9ffc95Smrg'g' are ignored when checking the name. 62b698ba48Smrg 6309885543SmrgSend bug reports to <bug-automake@gnu.org>." 6409885543Smrg exit $? 6509885543Smrg ;; 6609885543Smrg 6709885543Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6809885543Smrg echo "missing $scriptversion (GNU Automake)" 6909885543Smrg exit $? 7009885543Smrg ;; 7109885543Smrg 7209885543Smrg -*) 73df9ffc95Smrg echo 1>&2 "$0: unknown '$1' option" 74df9ffc95Smrg echo 1>&2 "Try '$0 --help' for more information" 7509885543Smrg exit 1 7609885543Smrg ;; 7709885543Smrg 7809885543Smrgesac 7909885543Smrg 80df9ffc95Smrg# Run the given program, remember its exit status. 81df9ffc95Smrg"$@"; st=$? 82df9ffc95Smrg 83df9ffc95Smrg# If it succeeded, we are done. 84df9ffc95Smrgtest $st -eq 0 && exit 0 85df9ffc95Smrg 86df9ffc95Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 87df9ffc95Smrg# passed; such an option is passed most likely to detect whether the 88df9ffc95Smrg# program is present and works. 89df9ffc95Smrgcase $2 in --version|--help) exit $st;; esac 90df9ffc95Smrg 91df9ffc95Smrg# Exit code 63 means version mismatch. This often happens when the user 92df9ffc95Smrg# tries to use an ancient version of a tool on a file that requires a 93df9ffc95Smrg# minimum version. 94df9ffc95Smrgif test $st -eq 63; then 95df9ffc95Smrg msg="probably too old" 96df9ffc95Smrgelif test $st -eq 127; then 97df9ffc95Smrg # Program was missing. 98df9ffc95Smrg msg="missing on your system" 99df9ffc95Smrgelse 100df9ffc95Smrg # Program was found and executed, but failed. Give up. 101df9ffc95Smrg exit $st 102df9ffc95Smrgfi 10309885543Smrg 104beef1b22Smrgperl_URL=https://www.perl.org/ 105beef1b22Smrgflex_URL=https://github.com/westes/flex 106beef1b22Smrggnu_software_URL=https://www.gnu.org/software 107df9ffc95Smrg 108df9ffc95Smrgprogram_details () 109df9ffc95Smrg{ 110df9ffc95Smrg case $1 in 111df9ffc95Smrg aclocal|automake) 112df9ffc95Smrg echo "The '$1' program is part of the GNU Automake package:" 113df9ffc95Smrg echo "<$gnu_software_URL/automake>" 114df9ffc95Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115df9ffc95Smrg echo "<$gnu_software_URL/autoconf>" 116df9ffc95Smrg echo "<$gnu_software_URL/m4/>" 117df9ffc95Smrg echo "<$perl_URL>" 118df9ffc95Smrg ;; 119df9ffc95Smrg autoconf|autom4te|autoheader) 120df9ffc95Smrg echo "The '$1' program is part of the GNU Autoconf package:" 121df9ffc95Smrg echo "<$gnu_software_URL/autoconf/>" 122df9ffc95Smrg echo "It also requires GNU m4 and Perl in order to run:" 123df9ffc95Smrg echo "<$gnu_software_URL/m4/>" 124df9ffc95Smrg echo "<$perl_URL>" 125df9ffc95Smrg ;; 126df9ffc95Smrg esac 127df9ffc95Smrg} 128df9ffc95Smrg 129df9ffc95Smrggive_advice () 130df9ffc95Smrg{ 131df9ffc95Smrg # Normalize program name to check for. 132df9ffc95Smrg normalized_program=`echo "$1" | sed ' 133df9ffc95Smrg s/^gnu-//; t 134df9ffc95Smrg s/^gnu//; t 135df9ffc95Smrg s/^g//; t'` 136df9ffc95Smrg 137df9ffc95Smrg printf '%s\n' "'$1' is $msg." 138df9ffc95Smrg 139df9ffc95Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140df9ffc95Smrg case $normalized_program in 141df9ffc95Smrg autoconf*) 142df9ffc95Smrg echo "You should only need it if you modified 'configure.ac'," 143df9ffc95Smrg echo "or m4 files included by it." 144df9ffc95Smrg program_details 'autoconf' 145df9ffc95Smrg ;; 146df9ffc95Smrg autoheader*) 147df9ffc95Smrg echo "You should only need it if you modified 'acconfig.h' or" 148df9ffc95Smrg echo "$configure_deps." 149df9ffc95Smrg program_details 'autoheader' 150df9ffc95Smrg ;; 151df9ffc95Smrg automake*) 152df9ffc95Smrg echo "You should only need it if you modified 'Makefile.am' or" 153df9ffc95Smrg echo "$configure_deps." 154df9ffc95Smrg program_details 'automake' 155df9ffc95Smrg ;; 156df9ffc95Smrg aclocal*) 157df9ffc95Smrg echo "You should only need it if you modified 'acinclude.m4' or" 158df9ffc95Smrg echo "$configure_deps." 159df9ffc95Smrg program_details 'aclocal' 160df9ffc95Smrg ;; 161df9ffc95Smrg autom4te*) 162df9ffc95Smrg echo "You might have modified some maintainer files that require" 163df9ffc95Smrg echo "the 'autom4te' program to be rebuilt." 164df9ffc95Smrg program_details 'autom4te' 165df9ffc95Smrg ;; 166df9ffc95Smrg bison*|yacc*) 167df9ffc95Smrg echo "You should only need it if you modified a '.y' file." 168df9ffc95Smrg echo "You may want to install the GNU Bison package:" 169df9ffc95Smrg echo "<$gnu_software_URL/bison/>" 170df9ffc95Smrg ;; 171df9ffc95Smrg lex*|flex*) 172df9ffc95Smrg echo "You should only need it if you modified a '.l' file." 173df9ffc95Smrg echo "You may want to install the Fast Lexical Analyzer package:" 174df9ffc95Smrg echo "<$flex_URL>" 175df9ffc95Smrg ;; 176df9ffc95Smrg help2man*) 177df9ffc95Smrg echo "You should only need it if you modified a dependency" \ 178df9ffc95Smrg "of a man page." 179df9ffc95Smrg echo "You may want to install the GNU Help2man package:" 180df9ffc95Smrg echo "<$gnu_software_URL/help2man/>" 18109885543Smrg ;; 182df9ffc95Smrg makeinfo*) 183df9ffc95Smrg echo "You should only need it if you modified a '.texi' file, or" 184df9ffc95Smrg echo "any other file indirectly affecting the aspect of the manual." 185df9ffc95Smrg echo "You might want to install the Texinfo package:" 186df9ffc95Smrg echo "<$gnu_software_URL/texinfo/>" 187df9ffc95Smrg echo "The spurious makeinfo call might also be the consequence of" 188df9ffc95Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189df9ffc95Smrg echo "want to install GNU make:" 190df9ffc95Smrg echo "<$gnu_software_URL/make/>" 191df9ffc95Smrg ;; 192df9ffc95Smrg *) 193df9ffc95Smrg echo "You might have modified some files without having the proper" 194df9ffc95Smrg echo "tools for further handling them. Check the 'README' file, it" 195df9ffc95Smrg echo "often tells you about the needed prerequisites for installing" 196df9ffc95Smrg echo "this package. You may also peek at any GNU archive site, in" 197df9ffc95Smrg echo "case some other package contains this missing '$1' program." 198df9ffc95Smrg ;; 199df9ffc95Smrg esac 200df9ffc95Smrg} 201df9ffc95Smrg 202df9ffc95Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 203df9ffc95Smrg -e '2,$s/^/ /' >&2 204df9ffc95Smrg 205df9ffc95Smrg# Propagate the correct exit status (expected to be 127 for a program 206df9ffc95Smrg# not found, 63 for a program that failed due to version mismatch). 207df9ffc95Smrgexit $st 20809885543Smrg 20909885543Smrg# Local variables: 210beef1b22Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 21109885543Smrg# time-stamp-start: "scriptversion=" 21209885543Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213beef1b22Smrg# time-stamp-time-zone: "UTC0" 214b698ba48Smrg# time-stamp-end: "; # UTC" 21509885543Smrg# End: 216