1b1297603Smrg#! /bin/sh 233734831Smrg# Common wrapper for a few potentially missing GNU programs. 3b1297603Smrg 4a570218aSmrgscriptversion=2018-03-07.03; # UTC 5b1297603Smrg 620f5670eSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 733734831Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8b1297603Smrg 9b1297603Smrg# This program is free software; you can redistribute it and/or modify 10b1297603Smrg# it under the terms of the GNU General Public License as published by 11b1297603Smrg# the Free Software Foundation; either version 2, or (at your option) 12b1297603Smrg# any later version. 13b1297603Smrg 14b1297603Smrg# This program is distributed in the hope that it will be useful, 15b1297603Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16b1297603Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17b1297603Smrg# GNU General Public License for more details. 18b1297603Smrg 19b1297603Smrg# You should have received a copy of the GNU General Public License 20a570218aSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21b1297603Smrg 22b1297603Smrg# As a special exception to the GNU General Public License, if you 23b1297603Smrg# distribute this file as part of a program that contains a 24b1297603Smrg# configuration script generated by Autoconf, you may include it under 25b1297603Smrg# the same distribution terms that you use for the rest of that program. 26b1297603Smrg 27b1297603Smrgif test $# -eq 0; then 2833734831Smrg echo 1>&2 "Try '$0 --help' for more information" 29b1297603Smrg exit 1 30b1297603Smrgfi 31b1297603Smrg 3233734831Smrgcase $1 in 33b1297603Smrg 3433734831Smrg --is-lightweight) 3533734831Smrg # Used by our autoconf macros to check whether the available missing 3633734831Smrg # script is modern enough. 3733734831Smrg exit 0 3833734831Smrg ;; 39b1297603Smrg 4033734831Smrg --run) 4133734831Smrg # Back-compat with the calling convention used by older automake. 4233734831Smrg shift 4333734831Smrg ;; 44b1297603Smrg 45b1297603Smrg -h|--h|--he|--hel|--help) 46b1297603Smrg echo "\ 47b1297603Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48b1297603Smrg 4933734831SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5033734831Smrgto PROGRAM being missing or too old. 51b1297603Smrg 52b1297603SmrgOptions: 53b1297603Smrg -h, --help display this help and exit 54b1297603Smrg -v, --version output version information and exit 55b1297603Smrg 56b1297603SmrgSupported PROGRAM values: 5733734831Smrg aclocal autoconf autoheader autom4te automake makeinfo 5833734831Smrg bison yacc flex lex help2man 5933734831Smrg 6033734831SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6133734831Smrg'g' are ignored when checking the name. 62b1297603Smrg 63b1297603SmrgSend bug reports to <bug-automake@gnu.org>." 64b1297603Smrg exit $? 65b1297603Smrg ;; 66b1297603Smrg 67b1297603Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68b1297603Smrg echo "missing $scriptversion (GNU Automake)" 69b1297603Smrg exit $? 70b1297603Smrg ;; 71b1297603Smrg 72b1297603Smrg -*) 7333734831Smrg echo 1>&2 "$0: unknown '$1' option" 7433734831Smrg echo 1>&2 "Try '$0 --help' for more information" 75b1297603Smrg exit 1 76b1297603Smrg ;; 77b1297603Smrg 78b1297603Smrgesac 79b1297603Smrg 8033734831Smrg# Run the given program, remember its exit status. 8133734831Smrg"$@"; st=$? 8233734831Smrg 8333734831Smrg# If it succeeded, we are done. 8433734831Smrgtest $st -eq 0 && exit 0 8533734831Smrg 8633734831Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 8733734831Smrg# passed; such an option is passed most likely to detect whether the 8833734831Smrg# program is present and works. 8933734831Smrgcase $2 in --version|--help) exit $st;; esac 9033734831Smrg 9133734831Smrg# Exit code 63 means version mismatch. This often happens when the user 9233734831Smrg# tries to use an ancient version of a tool on a file that requires a 9333734831Smrg# minimum version. 9433734831Smrgif test $st -eq 63; then 9533734831Smrg msg="probably too old" 9633734831Smrgelif test $st -eq 127; then 9733734831Smrg # Program was missing. 9833734831Smrg msg="missing on your system" 9933734831Smrgelse 10033734831Smrg # Program was found and executed, but failed. Give up. 10133734831Smrg exit $st 10233734831Smrgfi 103b1297603Smrg 104a570218aSmrgperl_URL=https://www.perl.org/ 105a570218aSmrgflex_URL=https://github.com/westes/flex 106a570218aSmrggnu_software_URL=https://www.gnu.org/software 10733734831Smrg 10833734831Smrgprogram_details () 10933734831Smrg{ 11033734831Smrg case $1 in 11133734831Smrg aclocal|automake) 11233734831Smrg echo "The '$1' program is part of the GNU Automake package:" 11333734831Smrg echo "<$gnu_software_URL/automake>" 11433734831Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11533734831Smrg echo "<$gnu_software_URL/autoconf>" 11633734831Smrg echo "<$gnu_software_URL/m4/>" 11733734831Smrg echo "<$perl_URL>" 11833734831Smrg ;; 11933734831Smrg autoconf|autom4te|autoheader) 12033734831Smrg echo "The '$1' program is part of the GNU Autoconf package:" 12133734831Smrg echo "<$gnu_software_URL/autoconf/>" 12233734831Smrg echo "It also requires GNU m4 and Perl in order to run:" 12333734831Smrg echo "<$gnu_software_URL/m4/>" 12433734831Smrg echo "<$perl_URL>" 12533734831Smrg ;; 12633734831Smrg esac 12733734831Smrg} 12833734831Smrg 12933734831Smrggive_advice () 13033734831Smrg{ 13133734831Smrg # Normalize program name to check for. 13233734831Smrg normalized_program=`echo "$1" | sed ' 13333734831Smrg s/^gnu-//; t 13433734831Smrg s/^gnu//; t 13533734831Smrg s/^g//; t'` 13633734831Smrg 13733734831Smrg printf '%s\n' "'$1' is $msg." 13833734831Smrg 13933734831Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14033734831Smrg case $normalized_program in 14133734831Smrg autoconf*) 14233734831Smrg echo "You should only need it if you modified 'configure.ac'," 14333734831Smrg echo "or m4 files included by it." 14433734831Smrg program_details 'autoconf' 14533734831Smrg ;; 14633734831Smrg autoheader*) 14733734831Smrg echo "You should only need it if you modified 'acconfig.h' or" 14833734831Smrg echo "$configure_deps." 14933734831Smrg program_details 'autoheader' 15033734831Smrg ;; 15133734831Smrg automake*) 15233734831Smrg echo "You should only need it if you modified 'Makefile.am' or" 15333734831Smrg echo "$configure_deps." 15433734831Smrg program_details 'automake' 15533734831Smrg ;; 15633734831Smrg aclocal*) 15733734831Smrg echo "You should only need it if you modified 'acinclude.m4' or" 15833734831Smrg echo "$configure_deps." 15933734831Smrg program_details 'aclocal' 16033734831Smrg ;; 16133734831Smrg autom4te*) 16233734831Smrg echo "You might have modified some maintainer files that require" 163a570218aSmrg echo "the 'autom4te' program to be rebuilt." 16433734831Smrg program_details 'autom4te' 16533734831Smrg ;; 16633734831Smrg bison*|yacc*) 16733734831Smrg echo "You should only need it if you modified a '.y' file." 16833734831Smrg echo "You may want to install the GNU Bison package:" 16933734831Smrg echo "<$gnu_software_URL/bison/>" 17033734831Smrg ;; 17133734831Smrg lex*|flex*) 17233734831Smrg echo "You should only need it if you modified a '.l' file." 17333734831Smrg echo "You may want to install the Fast Lexical Analyzer package:" 17433734831Smrg echo "<$flex_URL>" 17533734831Smrg ;; 17633734831Smrg help2man*) 17733734831Smrg echo "You should only need it if you modified a dependency" \ 17833734831Smrg "of a man page." 17933734831Smrg echo "You may want to install the GNU Help2man package:" 18033734831Smrg echo "<$gnu_software_URL/help2man/>" 18133734831Smrg ;; 18233734831Smrg makeinfo*) 18333734831Smrg echo "You should only need it if you modified a '.texi' file, or" 18433734831Smrg echo "any other file indirectly affecting the aspect of the manual." 18533734831Smrg echo "You might want to install the Texinfo package:" 18633734831Smrg echo "<$gnu_software_URL/texinfo/>" 18733734831Smrg echo "The spurious makeinfo call might also be the consequence of" 18833734831Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18933734831Smrg echo "want to install GNU make:" 19033734831Smrg echo "<$gnu_software_URL/make/>" 19133734831Smrg ;; 19233734831Smrg *) 19333734831Smrg echo "You might have modified some files without having the proper" 19433734831Smrg echo "tools for further handling them. Check the 'README' file, it" 19533734831Smrg echo "often tells you about the needed prerequisites for installing" 19633734831Smrg echo "this package. You may also peek at any GNU archive site, in" 19733734831Smrg echo "case some other package contains this missing '$1' program." 19833734831Smrg ;; 19933734831Smrg esac 20033734831Smrg} 20133734831Smrg 20233734831Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20333734831Smrg -e '2,$s/^/ /' >&2 20433734831Smrg 20533734831Smrg# Propagate the correct exit status (expected to be 127 for a program 20633734831Smrg# not found, 63 for a program that failed due to version mismatch). 20733734831Smrgexit $st 208b1297603Smrg 209b1297603Smrg# Local variables: 210a570218aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 211b1297603Smrg# time-stamp-start: "scriptversion=" 212b1297603Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213a570218aSmrg# time-stamp-time-zone: "UTC0" 21433734831Smrg# time-stamp-end: "; # UTC" 215b1297603Smrg# End: 216