121c2f794Smrg#! /bin/sh 21b2353dbSmrg# Common wrapper for a few potentially missing GNU programs. 321c2f794Smrg 4889a2364Smrgscriptversion=2018-03-07.03; # UTC 521c2f794Smrg 6889a2364Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 71b2353dbSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 821c2f794Smrg 921c2f794Smrg# This program is free software; you can redistribute it and/or modify 1021c2f794Smrg# it under the terms of the GNU General Public License as published by 1121c2f794Smrg# the Free Software Foundation; either version 2, or (at your option) 1221c2f794Smrg# any later version. 1321c2f794Smrg 1421c2f794Smrg# This program is distributed in the hope that it will be useful, 1521c2f794Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1621c2f794Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1721c2f794Smrg# GNU General Public License for more details. 1821c2f794Smrg 1921c2f794Smrg# You should have received a copy of the GNU General Public License 20889a2364Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 2121c2f794Smrg 2221c2f794Smrg# As a special exception to the GNU General Public License, if you 2321c2f794Smrg# distribute this file as part of a program that contains a 2421c2f794Smrg# configuration script generated by Autoconf, you may include it under 2521c2f794Smrg# the same distribution terms that you use for the rest of that program. 2621c2f794Smrg 2721c2f794Smrgif test $# -eq 0; then 281b2353dbSmrg echo 1>&2 "Try '$0 --help' for more information" 2921c2f794Smrg exit 1 3021c2f794Smrgfi 3121c2f794Smrg 321b2353dbSmrgcase $1 in 3321c2f794Smrg 341b2353dbSmrg --is-lightweight) 351b2353dbSmrg # Used by our autoconf macros to check whether the available missing 361b2353dbSmrg # script is modern enough. 371b2353dbSmrg exit 0 381b2353dbSmrg ;; 3921c2f794Smrg 401b2353dbSmrg --run) 411b2353dbSmrg # Back-compat with the calling convention used by older automake. 421b2353dbSmrg shift 431b2353dbSmrg ;; 4421c2f794Smrg 4521c2f794Smrg -h|--h|--he|--hel|--help) 4621c2f794Smrg echo "\ 4721c2f794Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 4821c2f794Smrg 491b2353dbSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 501b2353dbSmrgto PROGRAM being missing or too old. 5121c2f794Smrg 5221c2f794SmrgOptions: 5321c2f794Smrg -h, --help display this help and exit 5421c2f794Smrg -v, --version output version information and exit 5521c2f794Smrg 5621c2f794SmrgSupported PROGRAM values: 571b2353dbSmrg aclocal autoconf autoheader autom4te automake makeinfo 581b2353dbSmrg bison yacc flex lex help2man 5921c2f794Smrg 601b2353dbSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 611b2353dbSmrg'g' are ignored when checking the name. 6212391620Smrg 6321c2f794SmrgSend bug reports to <bug-automake@gnu.org>." 6421c2f794Smrg exit $? 6521c2f794Smrg ;; 6621c2f794Smrg 6721c2f794Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 6821c2f794Smrg echo "missing $scriptversion (GNU Automake)" 6921c2f794Smrg exit $? 7021c2f794Smrg ;; 7121c2f794Smrg 7221c2f794Smrg -*) 731b2353dbSmrg echo 1>&2 "$0: unknown '$1' option" 741b2353dbSmrg echo 1>&2 "Try '$0 --help' for more information" 7521c2f794Smrg exit 1 7621c2f794Smrg ;; 7721c2f794Smrg 7821c2f794Smrgesac 7921c2f794Smrg 801b2353dbSmrg# Run the given program, remember its exit status. 811b2353dbSmrg"$@"; st=$? 821b2353dbSmrg 831b2353dbSmrg# If it succeeded, we are done. 841b2353dbSmrgtest $st -eq 0 && exit 0 851b2353dbSmrg 861b2353dbSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 871b2353dbSmrg# passed; such an option is passed most likely to detect whether the 881b2353dbSmrg# program is present and works. 891b2353dbSmrgcase $2 in --version|--help) exit $st;; esac 901b2353dbSmrg 911b2353dbSmrg# Exit code 63 means version mismatch. This often happens when the user 921b2353dbSmrg# tries to use an ancient version of a tool on a file that requires a 931b2353dbSmrg# minimum version. 941b2353dbSmrgif test $st -eq 63; then 951b2353dbSmrg msg="probably too old" 961b2353dbSmrgelif test $st -eq 127; then 971b2353dbSmrg # Program was missing. 981b2353dbSmrg msg="missing on your system" 991b2353dbSmrgelse 1001b2353dbSmrg # Program was found and executed, but failed. Give up. 1011b2353dbSmrg exit $st 1021b2353dbSmrgfi 10321c2f794Smrg 104889a2364Smrgperl_URL=https://www.perl.org/ 105889a2364Smrgflex_URL=https://github.com/westes/flex 106889a2364Smrggnu_software_URL=https://www.gnu.org/software 1071b2353dbSmrg 1081b2353dbSmrgprogram_details () 1091b2353dbSmrg{ 1101b2353dbSmrg case $1 in 1111b2353dbSmrg aclocal|automake) 1121b2353dbSmrg echo "The '$1' program is part of the GNU Automake package:" 1131b2353dbSmrg echo "<$gnu_software_URL/automake>" 1141b2353dbSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1151b2353dbSmrg echo "<$gnu_software_URL/autoconf>" 1161b2353dbSmrg echo "<$gnu_software_URL/m4/>" 1171b2353dbSmrg echo "<$perl_URL>" 1181b2353dbSmrg ;; 1191b2353dbSmrg autoconf|autom4te|autoheader) 1201b2353dbSmrg echo "The '$1' program is part of the GNU Autoconf package:" 1211b2353dbSmrg echo "<$gnu_software_URL/autoconf/>" 1221b2353dbSmrg echo "It also requires GNU m4 and Perl in order to run:" 1231b2353dbSmrg echo "<$gnu_software_URL/m4/>" 1241b2353dbSmrg echo "<$perl_URL>" 1251b2353dbSmrg ;; 1261b2353dbSmrg esac 1271b2353dbSmrg} 1281b2353dbSmrg 1291b2353dbSmrggive_advice () 1301b2353dbSmrg{ 1311b2353dbSmrg # Normalize program name to check for. 1321b2353dbSmrg normalized_program=`echo "$1" | sed ' 1331b2353dbSmrg s/^gnu-//; t 1341b2353dbSmrg s/^gnu//; t 1351b2353dbSmrg s/^g//; t'` 1361b2353dbSmrg 1371b2353dbSmrg printf '%s\n' "'$1' is $msg." 1381b2353dbSmrg 1391b2353dbSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1401b2353dbSmrg case $normalized_program in 1411b2353dbSmrg autoconf*) 1421b2353dbSmrg echo "You should only need it if you modified 'configure.ac'," 1431b2353dbSmrg echo "or m4 files included by it." 1441b2353dbSmrg program_details 'autoconf' 1451b2353dbSmrg ;; 1461b2353dbSmrg autoheader*) 1471b2353dbSmrg echo "You should only need it if you modified 'acconfig.h' or" 1481b2353dbSmrg echo "$configure_deps." 1491b2353dbSmrg program_details 'autoheader' 1501b2353dbSmrg ;; 1511b2353dbSmrg automake*) 1521b2353dbSmrg echo "You should only need it if you modified 'Makefile.am' or" 1531b2353dbSmrg echo "$configure_deps." 1541b2353dbSmrg program_details 'automake' 1551b2353dbSmrg ;; 1561b2353dbSmrg aclocal*) 1571b2353dbSmrg echo "You should only need it if you modified 'acinclude.m4' or" 1581b2353dbSmrg echo "$configure_deps." 1591b2353dbSmrg program_details 'aclocal' 1601b2353dbSmrg ;; 1611b2353dbSmrg autom4te*) 1621b2353dbSmrg echo "You might have modified some maintainer files that require" 1631b2353dbSmrg echo "the 'autom4te' program to be rebuilt." 1641b2353dbSmrg program_details 'autom4te' 1651b2353dbSmrg ;; 1661b2353dbSmrg bison*|yacc*) 1671b2353dbSmrg echo "You should only need it if you modified a '.y' file." 1681b2353dbSmrg echo "You may want to install the GNU Bison package:" 1691b2353dbSmrg echo "<$gnu_software_URL/bison/>" 1701b2353dbSmrg ;; 1711b2353dbSmrg lex*|flex*) 1721b2353dbSmrg echo "You should only need it if you modified a '.l' file." 1731b2353dbSmrg echo "You may want to install the Fast Lexical Analyzer package:" 1741b2353dbSmrg echo "<$flex_URL>" 1751b2353dbSmrg ;; 1761b2353dbSmrg help2man*) 1771b2353dbSmrg echo "You should only need it if you modified a dependency" \ 1781b2353dbSmrg "of a man page." 1791b2353dbSmrg echo "You may want to install the GNU Help2man package:" 1801b2353dbSmrg echo "<$gnu_software_URL/help2man/>" 1811b2353dbSmrg ;; 1821b2353dbSmrg makeinfo*) 1831b2353dbSmrg echo "You should only need it if you modified a '.texi' file, or" 1841b2353dbSmrg echo "any other file indirectly affecting the aspect of the manual." 1851b2353dbSmrg echo "You might want to install the Texinfo package:" 1861b2353dbSmrg echo "<$gnu_software_URL/texinfo/>" 1871b2353dbSmrg echo "The spurious makeinfo call might also be the consequence of" 1881b2353dbSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 1891b2353dbSmrg echo "want to install GNU make:" 1901b2353dbSmrg echo "<$gnu_software_URL/make/>" 1911b2353dbSmrg ;; 1921b2353dbSmrg *) 1931b2353dbSmrg echo "You might have modified some files without having the proper" 1941b2353dbSmrg echo "tools for further handling them. Check the 'README' file, it" 1951b2353dbSmrg echo "often tells you about the needed prerequisites for installing" 1961b2353dbSmrg echo "this package. You may also peek at any GNU archive site, in" 1971b2353dbSmrg echo "case some other package contains this missing '$1' program." 1981b2353dbSmrg ;; 1991b2353dbSmrg esac 2001b2353dbSmrg} 2011b2353dbSmrg 2021b2353dbSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2031b2353dbSmrg -e '2,$s/^/ /' >&2 2041b2353dbSmrg 2051b2353dbSmrg# Propagate the correct exit status (expected to be 127 for a program 2061b2353dbSmrg# not found, 63 for a program that failed due to version mismatch). 2071b2353dbSmrgexit $st 20821c2f794Smrg 20921c2f794Smrg# Local variables: 210889a2364Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 21121c2f794Smrg# time-stamp-start: "scriptversion=" 21221c2f794Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 213889a2364Smrg# time-stamp-time-zone: "UTC0" 21412391620Smrg# time-stamp-end: "; # UTC" 21521c2f794Smrg# End: 216