16c321187Smrg#! /bin/sh 29d0b5e55Smrg# Common wrapper for a few potentially missing GNU programs. 36c321187Smrg 49dedec0cSmrgscriptversion=2018-03-07.03; # UTC 56c321187Smrg 69dedec0cSmrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 79d0b5e55Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 86c321187Smrg 96c321187Smrg# This program is free software; you can redistribute it and/or modify 106c321187Smrg# it under the terms of the GNU General Public License as published by 116c321187Smrg# the Free Software Foundation; either version 2, or (at your option) 126c321187Smrg# any later version. 136c321187Smrg 146c321187Smrg# This program is distributed in the hope that it will be useful, 156c321187Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 166c321187Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 176c321187Smrg# GNU General Public License for more details. 186c321187Smrg 196c321187Smrg# You should have received a copy of the GNU General Public License 209dedec0cSmrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 216c321187Smrg 226c321187Smrg# As a special exception to the GNU General Public License, if you 236c321187Smrg# distribute this file as part of a program that contains a 246c321187Smrg# configuration script generated by Autoconf, you may include it under 256c321187Smrg# the same distribution terms that you use for the rest of that program. 266c321187Smrg 276c321187Smrgif test $# -eq 0; then 289d0b5e55Smrg echo 1>&2 "Try '$0 --help' for more information" 296c321187Smrg exit 1 306c321187Smrgfi 316c321187Smrg 329d0b5e55Smrgcase $1 in 336c321187Smrg 349d0b5e55Smrg --is-lightweight) 359d0b5e55Smrg # Used by our autoconf macros to check whether the available missing 369d0b5e55Smrg # script is modern enough. 379d0b5e55Smrg exit 0 389d0b5e55Smrg ;; 396c321187Smrg 409d0b5e55Smrg --run) 419d0b5e55Smrg # Back-compat with the calling convention used by older automake. 429d0b5e55Smrg shift 439d0b5e55Smrg ;; 446c321187Smrg 456c321187Smrg -h|--h|--he|--hel|--help) 466c321187Smrg echo "\ 476c321187Smrg$0 [OPTION]... PROGRAM [ARGUMENT]... 486c321187Smrg 499d0b5e55SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 509d0b5e55Smrgto PROGRAM being missing or too old. 516c321187Smrg 526c321187SmrgOptions: 536c321187Smrg -h, --help display this help and exit 546c321187Smrg -v, --version output version information and exit 556c321187Smrg 566c321187SmrgSupported PROGRAM values: 579d0b5e55Smrg aclocal autoconf autoheader autom4te automake makeinfo 589d0b5e55Smrg bison yacc flex lex help2man 596c321187Smrg 609d0b5e55SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 619d0b5e55Smrg'g' are ignored when checking the name. 6293493779Smrg 636c321187SmrgSend bug reports to <bug-automake@gnu.org>." 646c321187Smrg exit $? 656c321187Smrg ;; 666c321187Smrg 676c321187Smrg -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 686c321187Smrg echo "missing $scriptversion (GNU Automake)" 696c321187Smrg exit $? 706c321187Smrg ;; 716c321187Smrg 726c321187Smrg -*) 739d0b5e55Smrg echo 1>&2 "$0: unknown '$1' option" 749d0b5e55Smrg echo 1>&2 "Try '$0 --help' for more information" 756c321187Smrg exit 1 766c321187Smrg ;; 776c321187Smrg 786c321187Smrgesac 796c321187Smrg 809d0b5e55Smrg# Run the given program, remember its exit status. 819d0b5e55Smrg"$@"; st=$? 829d0b5e55Smrg 839d0b5e55Smrg# If it succeeded, we are done. 849d0b5e55Smrgtest $st -eq 0 && exit 0 859d0b5e55Smrg 869d0b5e55Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 879d0b5e55Smrg# passed; such an option is passed most likely to detect whether the 889d0b5e55Smrg# program is present and works. 899d0b5e55Smrgcase $2 in --version|--help) exit $st;; esac 909d0b5e55Smrg 919d0b5e55Smrg# Exit code 63 means version mismatch. This often happens when the user 929d0b5e55Smrg# tries to use an ancient version of a tool on a file that requires a 939d0b5e55Smrg# minimum version. 949d0b5e55Smrgif test $st -eq 63; then 959d0b5e55Smrg msg="probably too old" 969d0b5e55Smrgelif test $st -eq 127; then 979d0b5e55Smrg # Program was missing. 989d0b5e55Smrg msg="missing on your system" 999d0b5e55Smrgelse 1009d0b5e55Smrg # Program was found and executed, but failed. Give up. 1019d0b5e55Smrg exit $st 1029d0b5e55Smrgfi 1036c321187Smrg 1049dedec0cSmrgperl_URL=https://www.perl.org/ 1059dedec0cSmrgflex_URL=https://github.com/westes/flex 1069dedec0cSmrggnu_software_URL=https://www.gnu.org/software 1079d0b5e55Smrg 1089d0b5e55Smrgprogram_details () 1099d0b5e55Smrg{ 1109d0b5e55Smrg case $1 in 1119d0b5e55Smrg aclocal|automake) 1129d0b5e55Smrg echo "The '$1' program is part of the GNU Automake package:" 1139d0b5e55Smrg echo "<$gnu_software_URL/automake>" 1149d0b5e55Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 1159d0b5e55Smrg echo "<$gnu_software_URL/autoconf>" 1169d0b5e55Smrg echo "<$gnu_software_URL/m4/>" 1179d0b5e55Smrg echo "<$perl_URL>" 1189d0b5e55Smrg ;; 1199d0b5e55Smrg autoconf|autom4te|autoheader) 1209d0b5e55Smrg echo "The '$1' program is part of the GNU Autoconf package:" 1219d0b5e55Smrg echo "<$gnu_software_URL/autoconf/>" 1229d0b5e55Smrg echo "It also requires GNU m4 and Perl in order to run:" 1239d0b5e55Smrg echo "<$gnu_software_URL/m4/>" 1249d0b5e55Smrg echo "<$perl_URL>" 1259d0b5e55Smrg ;; 1269d0b5e55Smrg esac 1279d0b5e55Smrg} 1289d0b5e55Smrg 1299d0b5e55Smrggive_advice () 1309d0b5e55Smrg{ 1319d0b5e55Smrg # Normalize program name to check for. 1329d0b5e55Smrg normalized_program=`echo "$1" | sed ' 1339d0b5e55Smrg s/^gnu-//; t 1349d0b5e55Smrg s/^gnu//; t 1359d0b5e55Smrg s/^g//; t'` 1369d0b5e55Smrg 1379d0b5e55Smrg printf '%s\n' "'$1' is $msg." 1389d0b5e55Smrg 1399d0b5e55Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 1409d0b5e55Smrg case $normalized_program in 1419d0b5e55Smrg autoconf*) 1429d0b5e55Smrg echo "You should only need it if you modified 'configure.ac'," 1439d0b5e55Smrg echo "or m4 files included by it." 1449d0b5e55Smrg program_details 'autoconf' 1459d0b5e55Smrg ;; 1469d0b5e55Smrg autoheader*) 1479d0b5e55Smrg echo "You should only need it if you modified 'acconfig.h' or" 1489d0b5e55Smrg echo "$configure_deps." 1499d0b5e55Smrg program_details 'autoheader' 1509d0b5e55Smrg ;; 1519d0b5e55Smrg automake*) 1529d0b5e55Smrg echo "You should only need it if you modified 'Makefile.am' or" 1539d0b5e55Smrg echo "$configure_deps." 1549d0b5e55Smrg program_details 'automake' 1559d0b5e55Smrg ;; 1569d0b5e55Smrg aclocal*) 1579d0b5e55Smrg echo "You should only need it if you modified 'acinclude.m4' or" 1589d0b5e55Smrg echo "$configure_deps." 1599d0b5e55Smrg program_details 'aclocal' 1609d0b5e55Smrg ;; 1619d0b5e55Smrg autom4te*) 1629d0b5e55Smrg echo "You might have modified some maintainer files that require" 163198e4c3cSmrg echo "the 'autom4te' program to be rebuilt." 1649d0b5e55Smrg program_details 'autom4te' 1659d0b5e55Smrg ;; 1669d0b5e55Smrg bison*|yacc*) 1679d0b5e55Smrg echo "You should only need it if you modified a '.y' file." 1689d0b5e55Smrg echo "You may want to install the GNU Bison package:" 1699d0b5e55Smrg echo "<$gnu_software_URL/bison/>" 1709d0b5e55Smrg ;; 1719d0b5e55Smrg lex*|flex*) 1729d0b5e55Smrg echo "You should only need it if you modified a '.l' file." 1739d0b5e55Smrg echo "You may want to install the Fast Lexical Analyzer package:" 1749d0b5e55Smrg echo "<$flex_URL>" 1759d0b5e55Smrg ;; 1769d0b5e55Smrg help2man*) 1779d0b5e55Smrg echo "You should only need it if you modified a dependency" \ 1789d0b5e55Smrg "of a man page." 1799d0b5e55Smrg echo "You may want to install the GNU Help2man package:" 1809d0b5e55Smrg echo "<$gnu_software_URL/help2man/>" 1819d0b5e55Smrg ;; 1829d0b5e55Smrg makeinfo*) 1839d0b5e55Smrg echo "You should only need it if you modified a '.texi' file, or" 1849d0b5e55Smrg echo "any other file indirectly affecting the aspect of the manual." 1859d0b5e55Smrg echo "You might want to install the Texinfo package:" 1869d0b5e55Smrg echo "<$gnu_software_URL/texinfo/>" 1879d0b5e55Smrg echo "The spurious makeinfo call might also be the consequence of" 1889d0b5e55Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 1899d0b5e55Smrg echo "want to install GNU make:" 1909d0b5e55Smrg echo "<$gnu_software_URL/make/>" 1919d0b5e55Smrg ;; 1929d0b5e55Smrg *) 1939d0b5e55Smrg echo "You might have modified some files without having the proper" 1949d0b5e55Smrg echo "tools for further handling them. Check the 'README' file, it" 1959d0b5e55Smrg echo "often tells you about the needed prerequisites for installing" 1969d0b5e55Smrg echo "this package. You may also peek at any GNU archive site, in" 1979d0b5e55Smrg echo "case some other package contains this missing '$1' program." 1989d0b5e55Smrg ;; 1999d0b5e55Smrg esac 2009d0b5e55Smrg} 2019d0b5e55Smrg 2029d0b5e55Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 2039d0b5e55Smrg -e '2,$s/^/ /' >&2 2049d0b5e55Smrg 2059d0b5e55Smrg# Propagate the correct exit status (expected to be 127 for a program 2069d0b5e55Smrg# not found, 63 for a program that failed due to version mismatch). 2079d0b5e55Smrgexit $st 2086c321187Smrg 2096c321187Smrg# Local variables: 2109dedec0cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 2116c321187Smrg# time-stamp-start: "scriptversion=" 2126c321187Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 2139dedec0cSmrg# time-stamp-time-zone: "UTC0" 21493493779Smrg# time-stamp-end: "; # UTC" 2156c321187Smrg# End: 216