1f7ec340bSmacallan#! /bin/sh 266ab3337Smrg# Common wrapper for a few potentially missing GNU programs. 3f7ec340bSmacallan 466ab3337Smrgscriptversion=2018-03-07.03; # UTC 5f7ec340bSmacallan 666ab3337Smrg# Copyright (C) 1996-2021 Free Software Foundation, Inc. 766ab3337Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. 8f7ec340bSmacallan 9f7ec340bSmacallan# This program is free software; you can redistribute it and/or modify 10f7ec340bSmacallan# it under the terms of the GNU General Public License as published by 11f7ec340bSmacallan# the Free Software Foundation; either version 2, or (at your option) 12f7ec340bSmacallan# any later version. 13f7ec340bSmacallan 14f7ec340bSmacallan# This program is distributed in the hope that it will be useful, 15f7ec340bSmacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of 16f7ec340bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17f7ec340bSmacallan# GNU General Public License for more details. 18f7ec340bSmacallan 19f7ec340bSmacallan# You should have received a copy of the GNU General Public License 2066ab3337Smrg# along with this program. If not, see <https://www.gnu.org/licenses/>. 21f7ec340bSmacallan 22f7ec340bSmacallan# As a special exception to the GNU General Public License, if you 23f7ec340bSmacallan# distribute this file as part of a program that contains a 24f7ec340bSmacallan# configuration script generated by Autoconf, you may include it under 25f7ec340bSmacallan# the same distribution terms that you use for the rest of that program. 26f7ec340bSmacallan 27f7ec340bSmacallanif test $# -eq 0; then 282a75d1c4Smrg echo 1>&2 "Try '$0 --help' for more information" 29f7ec340bSmacallan exit 1 30f7ec340bSmacallanfi 31f7ec340bSmacallan 3266ab3337Smrgcase $1 in 33f7ec340bSmacallan 3466ab3337Smrg --is-lightweight) 3566ab3337Smrg # Used by our autoconf macros to check whether the available missing 3666ab3337Smrg # script is modern enough. 3766ab3337Smrg exit 0 3866ab3337Smrg ;; 39f7ec340bSmacallan 4066ab3337Smrg --run) 4166ab3337Smrg # Back-compat with the calling convention used by older automake. 4266ab3337Smrg shift 4366ab3337Smrg ;; 44f7ec340bSmacallan 45f7ec340bSmacallan -h|--h|--he|--hel|--help) 46f7ec340bSmacallan echo "\ 47f7ec340bSmacallan$0 [OPTION]... PROGRAM [ARGUMENT]... 48f7ec340bSmacallan 4966ab3337SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 5066ab3337Smrgto PROGRAM being missing or too old. 51f7ec340bSmacallan 52f7ec340bSmacallanOptions: 53f7ec340bSmacallan -h, --help display this help and exit 54f7ec340bSmacallan -v, --version output version information and exit 55f7ec340bSmacallan 56f7ec340bSmacallanSupported PROGRAM values: 5766ab3337Smrg aclocal autoconf autoheader autom4te automake makeinfo 5866ab3337Smrg bison yacc flex lex help2man 592a75d1c4Smrg 602a75d1c4SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 612a75d1c4Smrg'g' are ignored when checking the name. 62f7ec340bSmacallan 63f7ec340bSmacallanSend bug reports to <bug-automake@gnu.org>." 64f7ec340bSmacallan exit $? 65f7ec340bSmacallan ;; 66f7ec340bSmacallan 67f7ec340bSmacallan -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68f7ec340bSmacallan echo "missing $scriptversion (GNU Automake)" 69f7ec340bSmacallan exit $? 70f7ec340bSmacallan ;; 71f7ec340bSmacallan 72f7ec340bSmacallan -*) 7366ab3337Smrg echo 1>&2 "$0: unknown '$1' option" 742a75d1c4Smrg echo 1>&2 "Try '$0 --help' for more information" 75f7ec340bSmacallan exit 1 76f7ec340bSmacallan ;; 77f7ec340bSmacallan 78f7ec340bSmacallanesac 79f7ec340bSmacallan 8066ab3337Smrg# Run the given program, remember its exit status. 8166ab3337Smrg"$@"; st=$? 8266ab3337Smrg 8366ab3337Smrg# If it succeeded, we are done. 8466ab3337Smrgtest $st -eq 0 && exit 0 8566ab3337Smrg 8666ab3337Smrg# Also exit now if we it failed (or wasn't found), and '--version' was 8766ab3337Smrg# passed; such an option is passed most likely to detect whether the 8866ab3337Smrg# program is present and works. 8966ab3337Smrgcase $2 in --version|--help) exit $st;; esac 9066ab3337Smrg 9166ab3337Smrg# Exit code 63 means version mismatch. This often happens when the user 9266ab3337Smrg# tries to use an ancient version of a tool on a file that requires a 9366ab3337Smrg# minimum version. 9466ab3337Smrgif test $st -eq 63; then 9566ab3337Smrg msg="probably too old" 9666ab3337Smrgelif test $st -eq 127; then 9766ab3337Smrg # Program was missing. 9866ab3337Smrg msg="missing on your system" 9966ab3337Smrgelse 10066ab3337Smrg # Program was found and executed, but failed. Give up. 10166ab3337Smrg exit $st 10266ab3337Smrgfi 103f7ec340bSmacallan 10466ab3337Smrgperl_URL=https://www.perl.org/ 10566ab3337Smrgflex_URL=https://github.com/westes/flex 10666ab3337Smrggnu_software_URL=https://www.gnu.org/software 10766ab3337Smrg 10866ab3337Smrgprogram_details () 10966ab3337Smrg{ 11066ab3337Smrg case $1 in 11166ab3337Smrg aclocal|automake) 11266ab3337Smrg echo "The '$1' program is part of the GNU Automake package:" 11366ab3337Smrg echo "<$gnu_software_URL/automake>" 11466ab3337Smrg echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 11566ab3337Smrg echo "<$gnu_software_URL/autoconf>" 11666ab3337Smrg echo "<$gnu_software_URL/m4/>" 11766ab3337Smrg echo "<$perl_URL>" 11866ab3337Smrg ;; 11966ab3337Smrg autoconf|autom4te|autoheader) 12066ab3337Smrg echo "The '$1' program is part of the GNU Autoconf package:" 12166ab3337Smrg echo "<$gnu_software_URL/autoconf/>" 12266ab3337Smrg echo "It also requires GNU m4 and Perl in order to run:" 12366ab3337Smrg echo "<$gnu_software_URL/m4/>" 12466ab3337Smrg echo "<$perl_URL>" 12566ab3337Smrg ;; 12666ab3337Smrg esac 12766ab3337Smrg} 12866ab3337Smrg 12966ab3337Smrggive_advice () 13066ab3337Smrg{ 13166ab3337Smrg # Normalize program name to check for. 13266ab3337Smrg normalized_program=`echo "$1" | sed ' 13366ab3337Smrg s/^gnu-//; t 13466ab3337Smrg s/^gnu//; t 13566ab3337Smrg s/^g//; t'` 13666ab3337Smrg 13766ab3337Smrg printf '%s\n' "'$1' is $msg." 13866ab3337Smrg 13966ab3337Smrg configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 14066ab3337Smrg case $normalized_program in 14166ab3337Smrg autoconf*) 14266ab3337Smrg echo "You should only need it if you modified 'configure.ac'," 14366ab3337Smrg echo "or m4 files included by it." 14466ab3337Smrg program_details 'autoconf' 14566ab3337Smrg ;; 14666ab3337Smrg autoheader*) 14766ab3337Smrg echo "You should only need it if you modified 'acconfig.h' or" 14866ab3337Smrg echo "$configure_deps." 14966ab3337Smrg program_details 'autoheader' 15066ab3337Smrg ;; 15166ab3337Smrg automake*) 15266ab3337Smrg echo "You should only need it if you modified 'Makefile.am' or" 15366ab3337Smrg echo "$configure_deps." 15466ab3337Smrg program_details 'automake' 15566ab3337Smrg ;; 15666ab3337Smrg aclocal*) 15766ab3337Smrg echo "You should only need it if you modified 'acinclude.m4' or" 15866ab3337Smrg echo "$configure_deps." 15966ab3337Smrg program_details 'aclocal' 16066ab3337Smrg ;; 16166ab3337Smrg autom4te*) 16266ab3337Smrg echo "You might have modified some maintainer files that require" 16366ab3337Smrg echo "the 'autom4te' program to be rebuilt." 16466ab3337Smrg program_details 'autom4te' 16566ab3337Smrg ;; 16666ab3337Smrg bison*|yacc*) 16766ab3337Smrg echo "You should only need it if you modified a '.y' file." 16866ab3337Smrg echo "You may want to install the GNU Bison package:" 16966ab3337Smrg echo "<$gnu_software_URL/bison/>" 17066ab3337Smrg ;; 17166ab3337Smrg lex*|flex*) 17266ab3337Smrg echo "You should only need it if you modified a '.l' file." 17366ab3337Smrg echo "You may want to install the Fast Lexical Analyzer package:" 17466ab3337Smrg echo "<$flex_URL>" 17566ab3337Smrg ;; 17666ab3337Smrg help2man*) 17766ab3337Smrg echo "You should only need it if you modified a dependency" \ 17866ab3337Smrg "of a man page." 17966ab3337Smrg echo "You may want to install the GNU Help2man package:" 18066ab3337Smrg echo "<$gnu_software_URL/help2man/>" 181f7ec340bSmacallan ;; 18266ab3337Smrg makeinfo*) 18366ab3337Smrg echo "You should only need it if you modified a '.texi' file, or" 18466ab3337Smrg echo "any other file indirectly affecting the aspect of the manual." 18566ab3337Smrg echo "You might want to install the Texinfo package:" 18666ab3337Smrg echo "<$gnu_software_URL/texinfo/>" 18766ab3337Smrg echo "The spurious makeinfo call might also be the consequence of" 18866ab3337Smrg echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 18966ab3337Smrg echo "want to install GNU make:" 19066ab3337Smrg echo "<$gnu_software_URL/make/>" 19166ab3337Smrg ;; 19266ab3337Smrg *) 19366ab3337Smrg echo "You might have modified some files without having the proper" 19466ab3337Smrg echo "tools for further handling them. Check the 'README' file, it" 19566ab3337Smrg echo "often tells you about the needed prerequisites for installing" 19666ab3337Smrg echo "this package. You may also peek at any GNU archive site, in" 19766ab3337Smrg echo "case some other package contains this missing '$1' program." 19866ab3337Smrg ;; 19966ab3337Smrg esac 20066ab3337Smrg} 20166ab3337Smrg 20266ab3337Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \ 20366ab3337Smrg -e '2,$s/^/ /' >&2 20466ab3337Smrg 20566ab3337Smrg# Propagate the correct exit status (expected to be 127 for a program 20666ab3337Smrg# not found, 63 for a program that failed due to version mismatch). 20766ab3337Smrgexit $st 208f7ec340bSmacallan 209f7ec340bSmacallan# Local variables: 21066ab3337Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 211f7ec340bSmacallan# time-stamp-start: "scriptversion=" 212f7ec340bSmacallan# time-stamp-format: "%:y-%02m-%02d.%02H" 21366ab3337Smrg# time-stamp-time-zone: "UTC0" 2142a75d1c4Smrg# time-stamp-end: "; # UTC" 215f7ec340bSmacallan# End: 216