11cc8c64fSmrg#! /bin/sh 218eba588Smrg# Common wrapper for a few potentially missing GNU programs. 3b9bb67cbSmrg 418eba588Smrgscriptversion=2018-03-07.03; # UTC 5b9bb67cbSmrg 618eba588Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 718eba588Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 81cc8c64fSmrg 91cc8c64fSmrg# This program is free software; you can redistribute it and/or modify 101cc8c64fSmrg# it under the terms of the GNU General Public License as published by 111cc8c64fSmrg# the Free Software Foundation; either version 2, or (at your option) 121cc8c64fSmrg# any later version. 131cc8c64fSmrg 141cc8c64fSmrg# This program is distributed in the hope that it will be useful, 151cc8c64fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 161cc8c64fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171cc8c64fSmrg# GNU General Public License for more details. 181cc8c64fSmrg 191cc8c64fSmrg# You should have received a copy of the GNU General Public License 2018eba588Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 211cc8c64fSmrg 221cc8c64fSmrg# As a special exception to the GNU General Public License, if you 231cc8c64fSmrg# distribute this file as part of a program that contains a 241cc8c64fSmrg# configuration script generated by Autoconf, you may include it under 251cc8c64fSmrg# the same distribution terms that you use for the rest of that program. 261cc8c64fSmrg 271cc8c64fSmrgif test $# -eq 0; then 2818eba588Smrg echo 1>&2 "Try '$0 --help' for more information" 291cc8c64fSmrg exit 1 301cc8c64fSmrgfi 311cc8c64fSmrg 3218eba588Smrgcase $1 in 331cc8c64fSmrg 3418eba588Smrg --is-lightweight) 3518eba588Smrg # Used by our autoconf macros to check whether the available missing 3618eba588Smrg # script is modern enough. 3718eba588Smrg exit 0 3818eba588Smrg ;; 39b9bb67cbSmrg 4018eba588Smrg --run) 4118eba588Smrg # Back-compat with the calling convention used by older automake. 4218eba588Smrg shift 4318eba588Smrg ;; 441cc8c64fSmrg 451cc8c64fSmrg -h|--h|--he|--hel|--help) 461cc8c64fSmrg echo "\ 471cc8c64fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 481cc8c64fSmrg 4918eba588SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5018eba588Smrgto PROGRAM being missing or too old. 511cc8c64fSmrg 521cc8c64fSmrgOptions: 531cc8c64fSmrg -h, --help display this help and exit 541cc8c64fSmrg -v, --version output version information and exit 551cc8c64fSmrg 561cc8c64fSmrgSupported PROGRAM values: 5718eba588Smrg aclocal autoconf autoheader autom4te automake makeinfo 5818eba588Smrg bison yacc flex lex help2man 59b9bb67cbSmrg 6018eba588SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6118eba588Smrg'g' are ignored when checking the name. 62b9bb67cbSmrg 63b9bb67cbSmrgSend bug reports to <bug-automake@gnu.org>." 64b9bb67cbSmrg exit $? 651cc8c64fSmrg ;; 661cc8c64fSmrg 671cc8c64fSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68b9bb67cbSmrg echo "missing $scriptversion (GNU Automake)" 69b9bb67cbSmrg exit $? 701cc8c64fSmrg ;; 711cc8c64fSmrg 721cc8c64fSmrg -*) 7318eba588Smrg echo 1>&2 "$0: unknown '$1' option" 7418eba588Smrg echo 1>&2 "Try '$0 --help' for more information" 751cc8c64fSmrg exit 1 761cc8c64fSmrg ;; 771cc8c64fSmrg 78b9bb67cbSmrgesac 79b9bb67cbSmrg 8018eba588Smrg# Run the given program, remember its exit status. 8118eba588Smrg"$@"; st=$? 8218eba588Smrg 8318eba588Smrg# If it succeeded, we are done. 8418eba588Smrgtest $st -eq 0 && exit 0 8518eba588Smrg 8618eba588Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 8718eba588Smrg# passed; such an option is passed most likely to detect whether the 8818eba588Smrg# program is present and works. 8918eba588Smrgcase $2 in --version|--help) exit $st;; esac 9018eba588Smrg 9118eba588Smrg# Exit code 63 means version mismatch. This often happens when the user 9218eba588Smrg# tries to use an ancient version of a tool on a file that requires a 9318eba588Smrg# minimum version. 9418eba588Smrgif test $st -eq 63; then 9518eba588Smrg msg="probably too old" 9618eba588Smrgelif test $st -eq 127; then 9718eba588Smrg # Program was missing. 9818eba588Smrg msg="missing on your system" 9918eba588Smrgelse 10018eba588Smrg # Program was found and executed, but failed. Give up. 10118eba588Smrg exit $st 10218eba588Smrgfi 1031cc8c64fSmrg 10418eba588Smrgperl_URL=https://www.perl.org/ 10518eba588Smrgflex_URL=https://github.com/westes/flex 10618eba588Smrggnu_software_URL=https://www.gnu.org/software 10718eba588Smrg 10818eba588Smrgprogram_details () 10918eba588Smrg{ 11018eba588Smrg case $1 in 11118eba588Smrg aclocal|automake) 11218eba588Smrg echo "The '$1' program is part of the GNU Automake package:" 11318eba588Smrg echo "<$gnu_software_URL/automake>" 11418eba588Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11518eba588Smrg echo "<$gnu_software_URL/autoconf>" 11618eba588Smrg echo "<$gnu_software_URL/m4/>" 11718eba588Smrg echo "<$perl_URL>" 11818eba588Smrg ;; 11918eba588Smrg autoconf|autom4te|autoheader) 12018eba588Smrg echo "The '$1' program is part of the GNU Autoconf package:" 12118eba588Smrg echo "<$gnu_software_URL/autoconf/>" 12218eba588Smrg echo "It also requires GNU m4 and Perl in order to run:" 12318eba588Smrg echo "<$gnu_software_URL/m4/>" 12418eba588Smrg echo "<$perl_URL>" 12518eba588Smrg ;; 12618eba588Smrg esac 12718eba588Smrg} 12818eba588Smrg 12918eba588Smrggive_advice () 13018eba588Smrg{ 13118eba588Smrg # Normalize program name to check for. 13218eba588Smrg normalized_program=`echo "$1" | sed ' 13318eba588Smrg s/^gnu-//; t 13418eba588Smrg s/^gnu//; t 13518eba588Smrg s/^g//; t'` 13618eba588Smrg 13718eba588Smrg printf '%s\n' "'$1' is $msg." 13818eba588Smrg 13918eba588Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14018eba588Smrg case $normalized_program in 14118eba588Smrg autoconf*) 14218eba588Smrg echo "You should only need it if you modified 'configure.ac'," 14318eba588Smrg echo "or m4 files included by it." 14418eba588Smrg program_details 'autoconf' 14518eba588Smrg ;; 14618eba588Smrg autoheader*) 14718eba588Smrg echo "You should only need it if you modified 'acconfig.h' or" 14818eba588Smrg echo "$configure_deps." 14918eba588Smrg program_details 'autoheader' 15018eba588Smrg ;; 15118eba588Smrg automake*) 15218eba588Smrg echo "You should only need it if you modified 'Makefile.am' or" 15318eba588Smrg echo "$configure_deps." 15418eba588Smrg program_details 'automake' 15518eba588Smrg ;; 15618eba588Smrg aclocal*) 15718eba588Smrg echo "You should only need it if you modified 'acinclude.m4' or" 15818eba588Smrg echo "$configure_deps." 15918eba588Smrg program_details 'aclocal' 16018eba588Smrg ;; 16118eba588Smrg autom4te*) 16218eba588Smrg echo "You might have modified some maintainer files that require" 16318eba588Smrg echo "the 'autom4te' program to be rebuilt." 16418eba588Smrg program_details 'autom4te' 16518eba588Smrg ;; 16618eba588Smrg bison*|yacc*) 16718eba588Smrg echo "You should only need it if you modified a '.y' file." 16818eba588Smrg echo "You may want to install the GNU Bison package:" 16918eba588Smrg echo "<$gnu_software_URL/bison/>" 17018eba588Smrg ;; 17118eba588Smrg lex*|flex*) 17218eba588Smrg echo "You should only need it if you modified a '.l' file." 17318eba588Smrg echo "You may want to install the Fast Lexical Analyzer package:" 17418eba588Smrg echo "<$flex_URL>" 17518eba588Smrg ;; 17618eba588Smrg help2man*) 17718eba588Smrg echo "You should only need it if you modified a dependency" \ 17818eba588Smrg "of a man page." 17918eba588Smrg echo "You may want to install the GNU Help2man package:" 18018eba588Smrg echo "<$gnu_software_URL/help2man/>" 18118eba588Smrg ;; 18218eba588Smrg makeinfo*) 18318eba588Smrg echo "You should only need it if you modified a '.texi' file, or" 18418eba588Smrg echo "any other file indirectly affecting the aspect of the manual." 18518eba588Smrg echo "You might want to install the Texinfo package:" 18618eba588Smrg echo "<$gnu_software_URL/texinfo/>" 18718eba588Smrg echo "The spurious makeinfo call might also be the consequence of" 18818eba588Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18918eba588Smrg echo "want to install GNU make:" 19018eba588Smrg echo "<$gnu_software_URL/make/>" 19118eba588Smrg ;; 19218eba588Smrg *) 19318eba588Smrg echo "You might have modified some files without having the proper" 19418eba588Smrg echo "tools for further handling them. Check the 'README' file, it" 19518eba588Smrg echo "often tells you about the needed prerequisites for installing" 19618eba588Smrg echo "this package. You may also peek at any GNU archive site, in" 19718eba588Smrg echo "case some other package contains this missing '$1' program." 19818eba588Smrg ;; 19918eba588Smrg esac 20018eba588Smrg} 20118eba588Smrg 20218eba588Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20318eba588Smrg -e '2,$s/^/ /' >&2 20418eba588Smrg 20518eba588Smrg# Propagate the correct exit status (expected to be 127 for a program 20618eba588Smrg# not found, 63 for a program that failed due to version mismatch). 20718eba588Smrgexit $st 208b9bb67cbSmrg 209b9bb67cbSmrg# Local variables: 21018eba588Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211b9bb67cbSmrg# time-stamp-start: "scriptversion=" 212b9bb67cbSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 21318eba588Smrg# time-stamp-time-zone: "UTC0" 214b9bb67cbSmrg# time-stamp-end: "; # UTC" 215b9bb67cbSmrg# End: 216