11d54945dSmrg#! /bin/sh 27322289dSmrg# Common wrapper for a few potentially missing GNU programs. 31d54945dSmrg 422663e35Smrgscriptversion=2018-03-07.03; # UTC 51d54945dSmrg 622663e35Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 77322289dSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 81d54945dSmrg 91d54945dSmrg# This program is free software; you can redistribute it and/or modify 101d54945dSmrg# it under the terms of the GNU General Public License as published by 111d54945dSmrg# the Free Software Foundation; either version 2, or (at your option) 121d54945dSmrg# any later version. 131d54945dSmrg 141d54945dSmrg# This program is distributed in the hope that it will be useful, 151d54945dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 161d54945dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171d54945dSmrg# GNU General Public License for more details. 181d54945dSmrg 191d54945dSmrg# You should have received a copy of the GNU General Public License 2022663e35Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 211d54945dSmrg 221d54945dSmrg# As a special exception to the GNU General Public License, if you 231d54945dSmrg# distribute this file as part of a program that contains a 241d54945dSmrg# configuration script generated by Autoconf, you may include it under 251d54945dSmrg# the same distribution terms that you use for the rest of that program. 261d54945dSmrg 271d54945dSmrgif test $# -eq 0; then 287322289dSmrg echo 1>&2 "Try '$0 --help' for more information" 291d54945dSmrg exit 1 301d54945dSmrgfi 311d54945dSmrg 327322289dSmrgcase $1 in 331d54945dSmrg 347322289dSmrg --is-lightweight) 357322289dSmrg # Used by our autoconf macros to check whether the available missing 367322289dSmrg # script is modern enough. 377322289dSmrg exit 0 387322289dSmrg ;; 391d54945dSmrg 407322289dSmrg --run) 417322289dSmrg # Back-compat with the calling convention used by older automake. 427322289dSmrg shift 437322289dSmrg ;; 441d54945dSmrg 451d54945dSmrg -h|--h|--he|--hel|--help) 461d54945dSmrg echo "\ 471d54945dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 481d54945dSmrg 497322289dSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 507322289dSmrgto PROGRAM being missing or too old. 511d54945dSmrg 521d54945dSmrgOptions: 531d54945dSmrg -h, --help display this help and exit 541d54945dSmrg -v, --version output version information and exit 551d54945dSmrg 561d54945dSmrgSupported PROGRAM values: 577322289dSmrg aclocal autoconf autoheader autom4te automake makeinfo 587322289dSmrg bison yacc flex lex help2man 591d54945dSmrg 607322289dSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 617322289dSmrg'g' are ignored when checking the name. 62ec713c28Smrg 631d54945dSmrgSend bug reports to <bug-automake@gnu.org>." 641d54945dSmrg exit $? 651d54945dSmrg ;; 661d54945dSmrg 671d54945dSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 681d54945dSmrg echo "missing $scriptversion (GNU Automake)" 691d54945dSmrg exit $? 701d54945dSmrg ;; 711d54945dSmrg 721d54945dSmrg -*) 737322289dSmrg echo 1>&2 "$0: unknown '$1' option" 747322289dSmrg echo 1>&2 "Try '$0 --help' for more information" 751d54945dSmrg exit 1 761d54945dSmrg ;; 771d54945dSmrg 781d54945dSmrgesac 791d54945dSmrg 807322289dSmrg# Run the given program, remember its exit status. 817322289dSmrg"$@"; st=$? 827322289dSmrg 837322289dSmrg# If it succeeded, we are done. 847322289dSmrgtest $st -eq 0 && exit 0 857322289dSmrg 867322289dSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 877322289dSmrg# passed; such an option is passed most likely to detect whether the 887322289dSmrg# program is present and works. 897322289dSmrgcase $2 in --version|--help) exit $st;; esac 907322289dSmrg 917322289dSmrg# Exit code 63 means version mismatch. This often happens when the user 927322289dSmrg# tries to use an ancient version of a tool on a file that requires a 937322289dSmrg# minimum version. 947322289dSmrgif test $st -eq 63; then 957322289dSmrg msg="probably too old" 967322289dSmrgelif test $st -eq 127; then 977322289dSmrg # Program was missing. 987322289dSmrg msg="missing on your system" 997322289dSmrgelse 1007322289dSmrg # Program was found and executed, but failed. Give up. 1017322289dSmrg exit $st 1027322289dSmrgfi 1031d54945dSmrg 10422663e35Smrgperl_URL=https://www.perl.org/ 10522663e35Smrgflex_URL=https://github.com/westes/flex 10622663e35Smrggnu_software_URL=https://www.gnu.org/software 1077322289dSmrg 1087322289dSmrgprogram_details () 1097322289dSmrg{ 1107322289dSmrg case $1 in 1117322289dSmrg aclocal|automake) 1127322289dSmrg echo "The '$1' program is part of the GNU Automake package:" 1137322289dSmrg echo "<$gnu_software_URL/automake>" 1147322289dSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1157322289dSmrg echo "<$gnu_software_URL/autoconf>" 1167322289dSmrg echo "<$gnu_software_URL/m4/>" 1177322289dSmrg echo "<$perl_URL>" 1187322289dSmrg ;; 1197322289dSmrg autoconf|autom4te|autoheader) 1207322289dSmrg echo "The '$1' program is part of the GNU Autoconf package:" 1217322289dSmrg echo "<$gnu_software_URL/autoconf/>" 1227322289dSmrg echo "It also requires GNU m4 and Perl in order to run:" 1237322289dSmrg echo "<$gnu_software_URL/m4/>" 1247322289dSmrg echo "<$perl_URL>" 1257322289dSmrg ;; 1267322289dSmrg esac 1277322289dSmrg} 1287322289dSmrg 1297322289dSmrggive_advice () 1307322289dSmrg{ 1317322289dSmrg # Normalize program name to check for. 1327322289dSmrg normalized_program=`echo "$1" | sed ' 1337322289dSmrg s/^gnu-//; t 1347322289dSmrg s/^gnu//; t 1357322289dSmrg s/^g//; t'` 1367322289dSmrg 1377322289dSmrg printf '%s\n' "'$1' is $msg." 1387322289dSmrg 1397322289dSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1407322289dSmrg case $normalized_program in 1417322289dSmrg autoconf*) 1427322289dSmrg echo "You should only need it if you modified 'configure.ac'," 1437322289dSmrg echo "or m4 files included by it." 1447322289dSmrg program_details 'autoconf' 1457322289dSmrg ;; 1467322289dSmrg autoheader*) 1477322289dSmrg echo "You should only need it if you modified 'acconfig.h' or" 1487322289dSmrg echo "$configure_deps." 1497322289dSmrg program_details 'autoheader' 1507322289dSmrg ;; 1517322289dSmrg automake*) 1527322289dSmrg echo "You should only need it if you modified 'Makefile.am' or" 1537322289dSmrg echo "$configure_deps." 1547322289dSmrg program_details 'automake' 1557322289dSmrg ;; 1567322289dSmrg aclocal*) 1577322289dSmrg echo "You should only need it if you modified 'acinclude.m4' or" 1587322289dSmrg echo "$configure_deps." 1597322289dSmrg program_details 'aclocal' 1607322289dSmrg ;; 1617322289dSmrg autom4te*) 1627322289dSmrg echo "You might have modified some maintainer files that require" 1637322289dSmrg echo "the 'autom4te' program to be rebuilt." 1647322289dSmrg program_details 'autom4te' 1657322289dSmrg ;; 1667322289dSmrg bison*|yacc*) 1677322289dSmrg echo "You should only need it if you modified a '.y' file." 1687322289dSmrg echo "You may want to install the GNU Bison package:" 1697322289dSmrg echo "<$gnu_software_URL/bison/>" 1707322289dSmrg ;; 1717322289dSmrg lex*|flex*) 1727322289dSmrg echo "You should only need it if you modified a '.l' file." 1737322289dSmrg echo "You may want to install the Fast Lexical Analyzer package:" 1747322289dSmrg echo "<$flex_URL>" 1757322289dSmrg ;; 1767322289dSmrg help2man*) 1777322289dSmrg echo "You should only need it if you modified a dependency" \ 1787322289dSmrg "of a man page." 1797322289dSmrg echo "You may want to install the GNU Help2man package:" 1807322289dSmrg echo "<$gnu_software_URL/help2man/>" 1811d54945dSmrg ;; 1827322289dSmrg makeinfo*) 1837322289dSmrg echo "You should only need it if you modified a '.texi' file, or" 1847322289dSmrg echo "any other file indirectly affecting the aspect of the manual." 1857322289dSmrg echo "You might want to install the Texinfo package:" 1867322289dSmrg echo "<$gnu_software_URL/texinfo/>" 1877322289dSmrg echo "The spurious makeinfo call might also be the consequence of" 1887322289dSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 1897322289dSmrg echo "want to install GNU make:" 1907322289dSmrg echo "<$gnu_software_URL/make/>" 1917322289dSmrg ;; 1927322289dSmrg *) 1937322289dSmrg echo "You might have modified some files without having the proper" 1947322289dSmrg echo "tools for further handling them. Check the 'README' file, it" 1957322289dSmrg echo "often tells you about the needed prerequisites for installing" 1967322289dSmrg echo "this package. You may also peek at any GNU archive site, in" 1977322289dSmrg echo "case some other package contains this missing '$1' program." 1987322289dSmrg ;; 1997322289dSmrg esac 2007322289dSmrg} 2017322289dSmrg 2027322289dSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2037322289dSmrg -e '2,$s/^/ /' >&2 2047322289dSmrg 2057322289dSmrg# Propagate the correct exit status (expected to be 127 for a program 2067322289dSmrg# not found, 63 for a program that failed due to version mismatch). 2077322289dSmrgexit $st 2081d54945dSmrg 2091d54945dSmrg# Local variables: 21022663e35Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 2111d54945dSmrg# time-stamp-start: "scriptversion=" 2121d54945dSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 21322663e35Smrg# time-stamp-time-zone: "UTC0" 214ec713c28Smrg# time-stamp-end: "; # UTC" 2151d54945dSmrg# End: 216