188cd5fc2Smrg#! /bin/sh 288cd5fc2Smrg# Common wrapper for a few potentially missing GNU programs. 388cd5fc2Smrg 4a33c354dSmrgscriptversion=2018-03-07.03; # UTC 588cd5fc2Smrg 6a33c354dSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 788cd5fc2Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 888cd5fc2Smrg 988cd5fc2Smrg# This program is free software; you can redistribute it and/or modify 1088cd5fc2Smrg# it under the terms of the GNU General Public License as published by 1188cd5fc2Smrg# the Free Software Foundation; either version 2, or (at your option) 1288cd5fc2Smrg# any later version. 1388cd5fc2Smrg 1488cd5fc2Smrg# This program is distributed in the hope that it will be useful, 1588cd5fc2Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1688cd5fc2Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1788cd5fc2Smrg# GNU General Public License for more details. 1888cd5fc2Smrg 1988cd5fc2Smrg# You should have received a copy of the GNU General Public License 20a33c354dSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2188cd5fc2Smrg 2288cd5fc2Smrg# As a special exception to the GNU General Public License, if you 2388cd5fc2Smrg# distribute this file as part of a program that contains a 2488cd5fc2Smrg# configuration script generated by Autoconf, you may include it under 2588cd5fc2Smrg# the same distribution terms that you use for the rest of that program. 2688cd5fc2Smrg 2788cd5fc2Smrgif test $# -eq 0; then 2888cd5fc2Smrg echo 1>&2 "Try '$0 --help' for more information" 2988cd5fc2Smrg exit 1 3088cd5fc2Smrgfi 3188cd5fc2Smrg 3288cd5fc2Smrgcase $1 in 3388cd5fc2Smrg 3488cd5fc2Smrg --is-lightweight) 3588cd5fc2Smrg # Used by our autoconf macros to check whether the available missing 3688cd5fc2Smrg # script is modern enough. 3788cd5fc2Smrg exit 0 3888cd5fc2Smrg ;; 3988cd5fc2Smrg 4088cd5fc2Smrg --run) 4188cd5fc2Smrg # Back-compat with the calling convention used by older automake. 4288cd5fc2Smrg shift 4388cd5fc2Smrg ;; 4488cd5fc2Smrg 4588cd5fc2Smrg -h|--h|--he|--hel|--help) 4688cd5fc2Smrg echo "\ 4788cd5fc2Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4888cd5fc2Smrg 4988cd5fc2SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5088cd5fc2Smrgto PROGRAM being missing or too old. 5188cd5fc2Smrg 5288cd5fc2SmrgOptions: 5388cd5fc2Smrg -h, --help display this help and exit 5488cd5fc2Smrg -v, --version output version information and exit 5588cd5fc2Smrg 5688cd5fc2SmrgSupported PROGRAM values: 5788cd5fc2Smrg aclocal autoconf autoheader autom4te automake makeinfo 5888cd5fc2Smrg bison yacc flex lex help2man 5988cd5fc2Smrg 6088cd5fc2SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 6188cd5fc2Smrg'g' are ignored when checking the name. 6288cd5fc2Smrg 6388cd5fc2SmrgSend bug reports to <bug-automake@gnu.org>." 6488cd5fc2Smrg exit $? 6588cd5fc2Smrg ;; 6688cd5fc2Smrg 6788cd5fc2Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6888cd5fc2Smrg echo "missing $scriptversion (GNU Automake)" 6988cd5fc2Smrg exit $? 7088cd5fc2Smrg ;; 7188cd5fc2Smrg 7288cd5fc2Smrg -*) 7388cd5fc2Smrg echo 1>&2 "$0: unknown '$1' option" 7488cd5fc2Smrg echo 1>&2 "Try '$0 --help' for more information" 7588cd5fc2Smrg exit 1 7688cd5fc2Smrg ;; 7788cd5fc2Smrg 7888cd5fc2Smrgesac 7988cd5fc2Smrg 8088cd5fc2Smrg# Run the given program, remember its exit status. 8188cd5fc2Smrg"$@"; st=$? 8288cd5fc2Smrg 8388cd5fc2Smrg# If it succeeded, we are done. 8488cd5fc2Smrgtest $st -eq 0 && exit 0 8588cd5fc2Smrg 8688cd5fc2Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 8788cd5fc2Smrg# passed; such an option is passed most likely to detect whether the 8888cd5fc2Smrg# program is present and works. 8988cd5fc2Smrgcase $2 in --version|--help) exit $st;; esac 9088cd5fc2Smrg 9188cd5fc2Smrg# Exit code 63 means version mismatch. This often happens when the user 9288cd5fc2Smrg# tries to use an ancient version of a tool on a file that requires a 9388cd5fc2Smrg# minimum version. 9488cd5fc2Smrgif test $st -eq 63; then 9588cd5fc2Smrg msg="probably too old" 9688cd5fc2Smrgelif test $st -eq 127; then 9788cd5fc2Smrg # Program was missing. 9888cd5fc2Smrg msg="missing on your system" 9988cd5fc2Smrgelse 10088cd5fc2Smrg # Program was found and executed, but failed. Give up. 10188cd5fc2Smrg exit $st 10288cd5fc2Smrgfi 10388cd5fc2Smrg 104a33c354dSmrgperl_URL=https://www.perl.org/ 105a33c354dSmrgflex_URL=https://github.com/westes/flex 106a33c354dSmrggnu_software_URL=https://www.gnu.org/software 10788cd5fc2Smrg 10888cd5fc2Smrgprogram_details () 10988cd5fc2Smrg{ 11088cd5fc2Smrg case $1 in 11188cd5fc2Smrg aclocal|automake) 11288cd5fc2Smrg echo "The '$1' program is part of the GNU Automake package:" 11388cd5fc2Smrg echo "<$gnu_software_URL/automake>" 11488cd5fc2Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11588cd5fc2Smrg echo "<$gnu_software_URL/autoconf>" 11688cd5fc2Smrg echo "<$gnu_software_URL/m4/>" 11788cd5fc2Smrg echo "<$perl_URL>" 11888cd5fc2Smrg ;; 11988cd5fc2Smrg autoconf|autom4te|autoheader) 12088cd5fc2Smrg echo "The '$1' program is part of the GNU Autoconf package:" 12188cd5fc2Smrg echo "<$gnu_software_URL/autoconf/>" 12288cd5fc2Smrg echo "It also requires GNU m4 and Perl in order to run:" 12388cd5fc2Smrg echo "<$gnu_software_URL/m4/>" 12488cd5fc2Smrg echo "<$perl_URL>" 12588cd5fc2Smrg ;; 12688cd5fc2Smrg esac 12788cd5fc2Smrg} 12888cd5fc2Smrg 12988cd5fc2Smrggive_advice () 13088cd5fc2Smrg{ 13188cd5fc2Smrg # Normalize program name to check for. 13288cd5fc2Smrg normalized_program=`echo "$1" | sed ' 13388cd5fc2Smrg s/^gnu-//; t 13488cd5fc2Smrg s/^gnu//; t 13588cd5fc2Smrg s/^g//; t'` 13688cd5fc2Smrg 13788cd5fc2Smrg printf '%s\n' "'$1' is $msg." 13888cd5fc2Smrg 13988cd5fc2Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14088cd5fc2Smrg case $normalized_program in 14188cd5fc2Smrg autoconf*) 14288cd5fc2Smrg echo "You should only need it if you modified 'configure.ac'," 14388cd5fc2Smrg echo "or m4 files included by it." 14488cd5fc2Smrg program_details 'autoconf' 14588cd5fc2Smrg ;; 14688cd5fc2Smrg autoheader*) 14788cd5fc2Smrg echo "You should only need it if you modified 'acconfig.h' or" 14888cd5fc2Smrg echo "$configure_deps." 14988cd5fc2Smrg program_details 'autoheader' 15088cd5fc2Smrg ;; 15188cd5fc2Smrg automake*) 15288cd5fc2Smrg echo "You should only need it if you modified 'Makefile.am' or" 15388cd5fc2Smrg echo "$configure_deps." 15488cd5fc2Smrg program_details 'automake' 15588cd5fc2Smrg ;; 15688cd5fc2Smrg aclocal*) 15788cd5fc2Smrg echo "You should only need it if you modified 'acinclude.m4' or" 15888cd5fc2Smrg echo "$configure_deps." 15988cd5fc2Smrg program_details 'aclocal' 16088cd5fc2Smrg ;; 16188cd5fc2Smrg autom4te*) 16288cd5fc2Smrg echo "You might have modified some maintainer files that require" 16388cd5fc2Smrg echo "the 'autom4te' program to be rebuilt." 16488cd5fc2Smrg program_details 'autom4te' 16588cd5fc2Smrg ;; 16688cd5fc2Smrg bison*|yacc*) 16788cd5fc2Smrg echo "You should only need it if you modified a '.y' file." 16888cd5fc2Smrg echo "You may want to install the GNU Bison package:" 16988cd5fc2Smrg echo "<$gnu_software_URL/bison/>" 17088cd5fc2Smrg ;; 17188cd5fc2Smrg lex*|flex*) 17288cd5fc2Smrg echo "You should only need it if you modified a '.l' file." 17388cd5fc2Smrg echo "You may want to install the Fast Lexical Analyzer package:" 17488cd5fc2Smrg echo "<$flex_URL>" 17588cd5fc2Smrg ;; 17688cd5fc2Smrg help2man*) 17788cd5fc2Smrg echo "You should only need it if you modified a dependency" \ 17888cd5fc2Smrg "of a man page." 17988cd5fc2Smrg echo "You may want to install the GNU Help2man package:" 18088cd5fc2Smrg echo "<$gnu_software_URL/help2man/>" 18188cd5fc2Smrg ;; 18288cd5fc2Smrg makeinfo*) 18388cd5fc2Smrg echo "You should only need it if you modified a '.texi' file, or" 18488cd5fc2Smrg echo "any other file indirectly affecting the aspect of the manual." 18588cd5fc2Smrg echo "You might want to install the Texinfo package:" 18688cd5fc2Smrg echo "<$gnu_software_URL/texinfo/>" 18788cd5fc2Smrg echo "The spurious makeinfo call might also be the consequence of" 18888cd5fc2Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18988cd5fc2Smrg echo "want to install GNU make:" 19088cd5fc2Smrg echo "<$gnu_software_URL/make/>" 19188cd5fc2Smrg ;; 19288cd5fc2Smrg *) 19388cd5fc2Smrg echo "You might have modified some files without having the proper" 19488cd5fc2Smrg echo "tools for further handling them. Check the 'README' file, it" 19588cd5fc2Smrg echo "often tells you about the needed prerequisites for installing" 19688cd5fc2Smrg echo "this package. You may also peek at any GNU archive site, in" 19788cd5fc2Smrg echo "case some other package contains this missing '$1' program." 19888cd5fc2Smrg ;; 19988cd5fc2Smrg esac 20088cd5fc2Smrg} 20188cd5fc2Smrg 20288cd5fc2Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20388cd5fc2Smrg -e '2,$s/^/ /' >&2 20488cd5fc2Smrg 20588cd5fc2Smrg# Propagate the correct exit status (expected to be 127 for a program 20688cd5fc2Smrg# not found, 63 for a program that failed due to version mismatch). 20788cd5fc2Smrgexit $st 20888cd5fc2Smrg 20988cd5fc2Smrg# Local variables: 210a33c354dSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 21188cd5fc2Smrg# time-stamp-start: "scriptversion=" 21288cd5fc2Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213a33c354dSmrg# time-stamp-time-zone: "UTC0" 21488cd5fc2Smrg# time-stamp-end: "; # UTC" 21588cd5fc2Smrg# End: 216