1c43cc173Smrg#! /bin/sh 206c34b88Smrg# Common wrapper for a few potentially missing GNU programs. 3c43cc173Smrg 44940c694Smrgscriptversion=2018-03-07.03; # UTC 5c43cc173Smrg 64e8f48c7Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 706c34b88Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8c43cc173Smrg 9c43cc173Smrg# This program is free software; you can redistribute it and/or modify 10c43cc173Smrg# it under the terms of the GNU General Public License as published by 11c43cc173Smrg# the Free Software Foundation; either version 2, or (at your option) 12c43cc173Smrg# any later version. 13c43cc173Smrg 14c43cc173Smrg# This program is distributed in the hope that it will be useful, 15c43cc173Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16c43cc173Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17c43cc173Smrg# GNU General Public License for more details. 18c43cc173Smrg 19c43cc173Smrg# You should have received a copy of the GNU General Public License 204940c694Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21c43cc173Smrg 22c43cc173Smrg# As a special exception to the GNU General Public License, if you 23c43cc173Smrg# distribute this file as part of a program that contains a 24c43cc173Smrg# configuration script generated by Autoconf, you may include it under 25c43cc173Smrg# the same distribution terms that you use for the rest of that program. 26c43cc173Smrg 27c43cc173Smrgif test $# -eq 0; then 28f1ee322dSmrg echo 1>&2 "Try '$0 --help' for more information" 29c43cc173Smrg exit 1 30c43cc173Smrgfi 31c43cc173Smrg 3206c34b88Smrgcase $1 in 33c43cc173Smrg 3406c34b88Smrg --is-lightweight) 3506c34b88Smrg # Used by our autoconf macros to check whether the available missing 3606c34b88Smrg # script is modern enough. 3706c34b88Smrg exit 0 3806c34b88Smrg ;; 39c43cc173Smrg 4006c34b88Smrg --run) 4106c34b88Smrg # Back-compat with the calling convention used by older automake. 4206c34b88Smrg shift 4306c34b88Smrg ;; 44c43cc173Smrg 45c43cc173Smrg -h|--h|--he|--hel|--help) 46c43cc173Smrg echo "\ 47c43cc173Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48c43cc173Smrg 4906c34b88SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5006c34b88Smrgto PROGRAM being missing or too old. 51c43cc173Smrg 52c43cc173SmrgOptions: 53c43cc173Smrg -h, --help display this help and exit 54c43cc173Smrg -v, --version output version information and exit 55c43cc173Smrg 56c43cc173SmrgSupported PROGRAM values: 5706c34b88Smrg aclocal autoconf autoheader autom4te automake makeinfo 5806c34b88Smrg bison yacc flex lex help2man 59c43cc173Smrg 60f1ee322dSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61f1ee322dSmrg'g' are ignored when checking the name. 62c27c18e8Smrg 63c43cc173SmrgSend bug reports to <bug-automake@gnu.org>." 64c43cc173Smrg exit $? 65c43cc173Smrg ;; 66c43cc173Smrg 67c43cc173Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68c43cc173Smrg echo "missing $scriptversion (GNU Automake)" 69c43cc173Smrg exit $? 70c43cc173Smrg ;; 71c43cc173Smrg 72c43cc173Smrg -*) 7306c34b88Smrg echo 1>&2 "$0: unknown '$1' option" 74f1ee322dSmrg echo 1>&2 "Try '$0 --help' for more information" 75c43cc173Smrg exit 1 76c43cc173Smrg ;; 77c43cc173Smrg 78c43cc173Smrgesac 79c43cc173Smrg 8006c34b88Smrg# Run the given program, remember its exit status. 8106c34b88Smrg"$@"; st=$? 8206c34b88Smrg 8306c34b88Smrg# If it succeeded, we are done. 8406c34b88Smrgtest $st -eq 0 && exit 0 8506c34b88Smrg 8606c34b88Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 8706c34b88Smrg# passed; such an option is passed most likely to detect whether the 8806c34b88Smrg# program is present and works. 8906c34b88Smrgcase $2 in --version|--help) exit $st;; esac 9006c34b88Smrg 9106c34b88Smrg# Exit code 63 means version mismatch. This often happens when the user 9206c34b88Smrg# tries to use an ancient version of a tool on a file that requires a 9306c34b88Smrg# minimum version. 9406c34b88Smrgif test $st -eq 63; then 9506c34b88Smrg msg="probably too old" 9606c34b88Smrgelif test $st -eq 127; then 9706c34b88Smrg # Program was missing. 9806c34b88Smrg msg="missing on your system" 9906c34b88Smrgelse 10006c34b88Smrg # Program was found and executed, but failed. Give up. 10106c34b88Smrg exit $st 10206c34b88Smrgfi 103c43cc173Smrg 1044940c694Smrgperl_URL=https://www.perl.org/ 1054940c694Smrgflex_URL=https://github.com/westes/flex 1064940c694Smrggnu_software_URL=https://www.gnu.org/software 10706c34b88Smrg 10806c34b88Smrgprogram_details () 10906c34b88Smrg{ 11006c34b88Smrg case $1 in 11106c34b88Smrg aclocal|automake) 11206c34b88Smrg echo "The '$1' program is part of the GNU Automake package:" 11306c34b88Smrg echo "<$gnu_software_URL/automake>" 11406c34b88Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11506c34b88Smrg echo "<$gnu_software_URL/autoconf>" 11606c34b88Smrg echo "<$gnu_software_URL/m4/>" 11706c34b88Smrg echo "<$perl_URL>" 11806c34b88Smrg ;; 11906c34b88Smrg autoconf|autom4te|autoheader) 12006c34b88Smrg echo "The '$1' program is part of the GNU Autoconf package:" 12106c34b88Smrg echo "<$gnu_software_URL/autoconf/>" 12206c34b88Smrg echo "It also requires GNU m4 and Perl in order to run:" 12306c34b88Smrg echo "<$gnu_software_URL/m4/>" 12406c34b88Smrg echo "<$perl_URL>" 12506c34b88Smrg ;; 12606c34b88Smrg esac 12706c34b88Smrg} 12806c34b88Smrg 12906c34b88Smrggive_advice () 13006c34b88Smrg{ 13106c34b88Smrg # Normalize program name to check for. 13206c34b88Smrg normalized_program=`echo "$1" | sed ' 13306c34b88Smrg s/^gnu-//; t 13406c34b88Smrg s/^gnu//; t 13506c34b88Smrg s/^g//; t'` 13606c34b88Smrg 13706c34b88Smrg printf '%s\n' "'$1' is $msg." 13806c34b88Smrg 13906c34b88Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14006c34b88Smrg case $normalized_program in 14106c34b88Smrg autoconf*) 14206c34b88Smrg echo "You should only need it if you modified 'configure.ac'," 14306c34b88Smrg echo "or m4 files included by it." 14406c34b88Smrg program_details 'autoconf' 14506c34b88Smrg ;; 14606c34b88Smrg autoheader*) 14706c34b88Smrg echo "You should only need it if you modified 'acconfig.h' or" 14806c34b88Smrg echo "$configure_deps." 14906c34b88Smrg program_details 'autoheader' 15006c34b88Smrg ;; 15106c34b88Smrg automake*) 15206c34b88Smrg echo "You should only need it if you modified 'Makefile.am' or" 15306c34b88Smrg echo "$configure_deps." 15406c34b88Smrg program_details 'automake' 15506c34b88Smrg ;; 15606c34b88Smrg aclocal*) 15706c34b88Smrg echo "You should only need it if you modified 'acinclude.m4' or" 15806c34b88Smrg echo "$configure_deps." 15906c34b88Smrg program_details 'aclocal' 16006c34b88Smrg ;; 16106c34b88Smrg autom4te*) 16206c34b88Smrg echo "You might have modified some maintainer files that require" 16344584a44Smrg echo "the 'autom4te' program to be rebuilt." 16406c34b88Smrg program_details 'autom4te' 16506c34b88Smrg ;; 16606c34b88Smrg bison*|yacc*) 16706c34b88Smrg echo "You should only need it if you modified a '.y' file." 16806c34b88Smrg echo "You may want to install the GNU Bison package:" 16906c34b88Smrg echo "<$gnu_software_URL/bison/>" 17006c34b88Smrg ;; 17106c34b88Smrg lex*|flex*) 17206c34b88Smrg echo "You should only need it if you modified a '.l' file." 17306c34b88Smrg echo "You may want to install the Fast Lexical Analyzer package:" 17406c34b88Smrg echo "<$flex_URL>" 17506c34b88Smrg ;; 17606c34b88Smrg help2man*) 17706c34b88Smrg echo "You should only need it if you modified a dependency" \ 17806c34b88Smrg "of a man page." 17906c34b88Smrg echo "You may want to install the GNU Help2man package:" 18006c34b88Smrg echo "<$gnu_software_URL/help2man/>" 181c43cc173Smrg ;; 18206c34b88Smrg makeinfo*) 18306c34b88Smrg echo "You should only need it if you modified a '.texi' file, or" 18406c34b88Smrg echo "any other file indirectly affecting the aspect of the manual." 18506c34b88Smrg echo "You might want to install the Texinfo package:" 18606c34b88Smrg echo "<$gnu_software_URL/texinfo/>" 18706c34b88Smrg echo "The spurious makeinfo call might also be the consequence of" 18806c34b88Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18906c34b88Smrg echo "want to install GNU make:" 19006c34b88Smrg echo "<$gnu_software_URL/make/>" 19106c34b88Smrg ;; 19206c34b88Smrg *) 19306c34b88Smrg echo "You might have modified some files without having the proper" 19406c34b88Smrg echo "tools for further handling them. Check the 'README' file, it" 19506c34b88Smrg echo "often tells you about the needed prerequisites for installing" 19606c34b88Smrg echo "this package. You may also peek at any GNU archive site, in" 19706c34b88Smrg echo "case some other package contains this missing '$1' program." 19806c34b88Smrg ;; 19906c34b88Smrg esac 20006c34b88Smrg} 20106c34b88Smrg 20206c34b88Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20306c34b88Smrg -e '2,$s/^/ /' >&2 20406c34b88Smrg 20506c34b88Smrg# Propagate the correct exit status (expected to be 127 for a program 20606c34b88Smrg# not found, 63 for a program that failed due to version mismatch). 20706c34b88Smrgexit $st 208c43cc173Smrg 209c43cc173Smrg# Local variables: 2104940c694Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211c43cc173Smrg# time-stamp-start: "scriptversion=" 212c43cc173Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2134940c694Smrg# time-stamp-time-zone: "UTC0" 214c27c18e8Smrg# time-stamp-end: "; # UTC" 215c43cc173Smrg# End: 216