1b042e37fSmrg#! /bin/sh 28bd17e5fSmrg# Common wrapper for a few potentially missing GNU programs. 3b042e37fSmrg 48d0bc965Smrgscriptversion=2018-03-07.03; # UTC 5b042e37fSmrg 68d0bc965Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 78bd17e5fSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8b042e37fSmrg 9b042e37fSmrg# This program is free software; you can redistribute it and/or modify 10b042e37fSmrg# it under the terms of the GNU General Public License as published by 11b042e37fSmrg# the Free Software Foundation; either version 2, or (at your option) 12b042e37fSmrg# any later version. 13b042e37fSmrg 14b042e37fSmrg# This program is distributed in the hope that it will be useful, 15b042e37fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 16b042e37fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17b042e37fSmrg# GNU General Public License for more details. 18b042e37fSmrg 19b042e37fSmrg# You should have received a copy of the GNU General Public License 208d0bc965Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21b042e37fSmrg 22b042e37fSmrg# As a special exception to the GNU General Public License, if you 23b042e37fSmrg# distribute this file as part of a program that contains a 24b042e37fSmrg# configuration script generated by Autoconf, you may include it under 25b042e37fSmrg# the same distribution terms that you use for the rest of that program. 26b042e37fSmrg 27b042e37fSmrgif test $# -eq 0; then 288bd17e5fSmrg echo 1>&2 "Try '$0 --help' for more information" 29b042e37fSmrg exit 1 30b042e37fSmrgfi 31b042e37fSmrg 328bd17e5fSmrgcase $1 in 33b042e37fSmrg 348bd17e5fSmrg --is-lightweight) 358bd17e5fSmrg # Used by our autoconf macros to check whether the available missing 368bd17e5fSmrg # script is modern enough. 378bd17e5fSmrg exit 0 388bd17e5fSmrg ;; 39b042e37fSmrg 408bd17e5fSmrg --run) 418bd17e5fSmrg # Back-compat with the calling convention used by older automake. 428bd17e5fSmrg shift 438bd17e5fSmrg ;; 44b042e37fSmrg 45b042e37fSmrg -h|--h|--he|--hel|--help) 46b042e37fSmrg echo "\ 47b042e37fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]... 48b042e37fSmrg 498bd17e5fSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 508bd17e5fSmrgto PROGRAM being missing or too old. 51b042e37fSmrg 52b042e37fSmrgOptions: 53b042e37fSmrg -h, --help display this help and exit 54b042e37fSmrg -v, --version output version information and exit 55b042e37fSmrg 56b042e37fSmrgSupported PROGRAM values: 578bd17e5fSmrg aclocal autoconf autoheader autom4te automake makeinfo 588bd17e5fSmrg bison yacc flex lex help2man 59b042e37fSmrg 608bd17e5fSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 618bd17e5fSmrg'g' are ignored when checking the name. 62706b6b52Smrg 63b042e37fSmrgSend bug reports to <bug-automake@gnu.org>." 64b042e37fSmrg exit $? 65b042e37fSmrg ;; 66b042e37fSmrg 67b042e37fSmrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68b042e37fSmrg echo "missing $scriptversion (GNU Automake)" 69b042e37fSmrg exit $? 70b042e37fSmrg ;; 71b042e37fSmrg 72b042e37fSmrg -*) 738bd17e5fSmrg echo 1>&2 "$0: unknown '$1' option" 748bd17e5fSmrg echo 1>&2 "Try '$0 --help' for more information" 75b042e37fSmrg exit 1 76b042e37fSmrg ;; 77b042e37fSmrg 78b042e37fSmrgesac 79b042e37fSmrg 808bd17e5fSmrg# Run the given program, remember its exit status. 818bd17e5fSmrg"$@"; st=$? 828bd17e5fSmrg 838bd17e5fSmrg# If it succeeded, we are done. 848bd17e5fSmrgtest $st -eq 0 && exit 0 858bd17e5fSmrg 868bd17e5fSmrg# Also exit now if we it failed (or wasn't found), and '--version' was 878bd17e5fSmrg# passed; such an option is passed most likely to detect whether the 888bd17e5fSmrg# program is present and works. 898bd17e5fSmrgcase $2 in --version|--help) exit $st;; esac 908bd17e5fSmrg 918bd17e5fSmrg# Exit code 63 means version mismatch. This often happens when the user 928bd17e5fSmrg# tries to use an ancient version of a tool on a file that requires a 938bd17e5fSmrg# minimum version. 948bd17e5fSmrgif test $st -eq 63; then 958bd17e5fSmrg msg="probably too old" 968bd17e5fSmrgelif test $st -eq 127; then 978bd17e5fSmrg # Program was missing. 988bd17e5fSmrg msg="missing on your system" 998bd17e5fSmrgelse 1008bd17e5fSmrg # Program was found and executed, but failed. Give up. 1018bd17e5fSmrg exit $st 1028bd17e5fSmrgfi 103b042e37fSmrg 1048d0bc965Smrgperl_URL=https://www.perl.org/ 1058d0bc965Smrgflex_URL=https://github.com/westes/flex 1068d0bc965Smrggnu_software_URL=https://www.gnu.org/software 1078bd17e5fSmrg 1088bd17e5fSmrgprogram_details () 1098bd17e5fSmrg{ 1108bd17e5fSmrg case $1 in 1118bd17e5fSmrg aclocal|automake) 1128bd17e5fSmrg echo "The '$1' program is part of the GNU Automake package:" 1138bd17e5fSmrg echo "<$gnu_software_URL/automake>" 1148bd17e5fSmrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1158bd17e5fSmrg echo "<$gnu_software_URL/autoconf>" 1168bd17e5fSmrg echo "<$gnu_software_URL/m4/>" 1178bd17e5fSmrg echo "<$perl_URL>" 1188bd17e5fSmrg ;; 1198bd17e5fSmrg autoconf|autom4te|autoheader) 1208bd17e5fSmrg echo "The '$1' program is part of the GNU Autoconf package:" 1218bd17e5fSmrg echo "<$gnu_software_URL/autoconf/>" 1228bd17e5fSmrg echo "It also requires GNU m4 and Perl in order to run:" 1238bd17e5fSmrg echo "<$gnu_software_URL/m4/>" 1248bd17e5fSmrg echo "<$perl_URL>" 1258bd17e5fSmrg ;; 1268bd17e5fSmrg esac 1278bd17e5fSmrg} 1288bd17e5fSmrg 1298bd17e5fSmrggive_advice () 1308bd17e5fSmrg{ 1318bd17e5fSmrg # Normalize program name to check for. 1328bd17e5fSmrg normalized_program=`echo "$1" | sed ' 1338bd17e5fSmrg s/^gnu-//; t 1348bd17e5fSmrg s/^gnu//; t 1358bd17e5fSmrg s/^g//; t'` 1368bd17e5fSmrg 1378bd17e5fSmrg printf '%s\n' "'$1' is $msg." 1388bd17e5fSmrg 1398bd17e5fSmrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1408bd17e5fSmrg case $normalized_program in 1418bd17e5fSmrg autoconf*) 1428bd17e5fSmrg echo "You should only need it if you modified 'configure.ac'," 1438bd17e5fSmrg echo "or m4 files included by it." 1448bd17e5fSmrg program_details 'autoconf' 1458bd17e5fSmrg ;; 1468bd17e5fSmrg autoheader*) 1478bd17e5fSmrg echo "You should only need it if you modified 'acconfig.h' or" 1488bd17e5fSmrg echo "$configure_deps." 1498bd17e5fSmrg program_details 'autoheader' 1508bd17e5fSmrg ;; 1518bd17e5fSmrg automake*) 1528bd17e5fSmrg echo "You should only need it if you modified 'Makefile.am' or" 1538bd17e5fSmrg echo "$configure_deps." 1548bd17e5fSmrg program_details 'automake' 1558bd17e5fSmrg ;; 1568bd17e5fSmrg aclocal*) 1578bd17e5fSmrg echo "You should only need it if you modified 'acinclude.m4' or" 1588bd17e5fSmrg echo "$configure_deps." 1598bd17e5fSmrg program_details 'aclocal' 1608bd17e5fSmrg ;; 1618bd17e5fSmrg autom4te*) 1628bd17e5fSmrg echo "You might have modified some maintainer files that require" 163b242714cSmrg echo "the 'autom4te' program to be rebuilt." 1648bd17e5fSmrg program_details 'autom4te' 1658bd17e5fSmrg ;; 1668bd17e5fSmrg bison*|yacc*) 1678bd17e5fSmrg echo "You should only need it if you modified a '.y' file." 1688bd17e5fSmrg echo "You may want to install the GNU Bison package:" 1698bd17e5fSmrg echo "<$gnu_software_URL/bison/>" 1708bd17e5fSmrg ;; 1718bd17e5fSmrg lex*|flex*) 1728bd17e5fSmrg echo "You should only need it if you modified a '.l' file." 1738bd17e5fSmrg echo "You may want to install the Fast Lexical Analyzer package:" 1748bd17e5fSmrg echo "<$flex_URL>" 1758bd17e5fSmrg ;; 1768bd17e5fSmrg help2man*) 1778bd17e5fSmrg echo "You should only need it if you modified a dependency" \ 1788bd17e5fSmrg "of a man page." 1798bd17e5fSmrg echo "You may want to install the GNU Help2man package:" 1808bd17e5fSmrg echo "<$gnu_software_URL/help2man/>" 181b042e37fSmrg ;; 1828bd17e5fSmrg makeinfo*) 1838bd17e5fSmrg echo "You should only need it if you modified a '.texi' file, or" 1848bd17e5fSmrg echo "any other file indirectly affecting the aspect of the manual." 1858bd17e5fSmrg echo "You might want to install the Texinfo package:" 1868bd17e5fSmrg echo "<$gnu_software_URL/texinfo/>" 1878bd17e5fSmrg echo "The spurious makeinfo call might also be the consequence of" 1888bd17e5fSmrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 1898bd17e5fSmrg echo "want to install GNU make:" 1908bd17e5fSmrg echo "<$gnu_software_URL/make/>" 1918bd17e5fSmrg ;; 1928bd17e5fSmrg *) 1938bd17e5fSmrg echo "You might have modified some files without having the proper" 1948bd17e5fSmrg echo "tools for further handling them. Check the 'README' file, it" 1958bd17e5fSmrg echo "often tells you about the needed prerequisites for installing" 1968bd17e5fSmrg echo "this package. You may also peek at any GNU archive site, in" 1978bd17e5fSmrg echo "case some other package contains this missing '$1' program." 1988bd17e5fSmrg ;; 1998bd17e5fSmrg esac 2008bd17e5fSmrg} 2018bd17e5fSmrg 2028bd17e5fSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2038bd17e5fSmrg -e '2,$s/^/ /' >&2 2048bd17e5fSmrg 2058bd17e5fSmrg# Propagate the correct exit status (expected to be 127 for a program 2068bd17e5fSmrg# not found, 63 for a program that failed due to version mismatch). 2078bd17e5fSmrgexit $st 208b042e37fSmrg 209b042e37fSmrg# Local variables: 2108d0bc965Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211b042e37fSmrg# time-stamp-start: "scriptversion=" 212b042e37fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2138d0bc965Smrg# time-stamp-time-zone: "UTC0" 214706b6b52Smrg# time-stamp-end: "; # UTC" 215b042e37fSmrg# End: 216