File indexing completed on 2024-12-22 04:04:20

0001 #! /bin/sh
0002 # Common wrapper for a few potentially missing GNU programs.
0003 
0004 scriptversion=2018-03-07.03; # UTC
0005 
0006 # Copyright (C) 1996-2018 Free Software Foundation, Inc.
0007 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
0008 
0009 # This program is free software; you can redistribute it and/or modify
0010 # it under the terms of the GNU General Public License as published by
0011 # the Free Software Foundation; either version 2, or (at your option)
0012 # any later version.
0013 
0014 # This program is distributed in the hope that it will be useful,
0015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017 # GNU General Public License for more details.
0018 
0019 # You should have received a copy of the GNU General Public License
0020 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
0021 
0022 # As a special exception to the GNU General Public License, if you
0023 # distribute this file as part of a program that contains a
0024 # configuration script generated by Autoconf, you may include it under
0025 # the same distribution terms that you use for the rest of that program.
0026 
0027 if test $# -eq 0; then
0028   echo 1>&2 "Try '$0 --help' for more information"
0029   exit 1
0030 fi
0031 
0032 case $1 in
0033 
0034   --is-lightweight)
0035     # Used by our autoconf macros to check whether the available missing
0036     # script is modern enough.
0037     exit 0
0038     ;;
0039 
0040   --run)
0041     # Back-compat with the calling convention used by older automake.
0042     shift
0043     ;;
0044 
0045   -h|--h|--he|--hel|--help)
0046     echo "\
0047 $0 [OPTION]... PROGRAM [ARGUMENT]...
0048 
0049 Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
0050 to PROGRAM being missing or too old.
0051 
0052 Options:
0053   -h, --help      display this help and exit
0054   -v, --version   output version information and exit
0055 
0056 Supported PROGRAM values:
0057   aclocal   autoconf  autoheader   autom4te  automake  makeinfo
0058   bison     yacc      flex         lex       help2man
0059 
0060 Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
0061 'g' are ignored when checking the name.
0062 
0063 Send bug reports to <bug-automake@gnu.org>."
0064     exit $?
0065     ;;
0066 
0067   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
0068     echo "missing $scriptversion (GNU Automake)"
0069     exit $?
0070     ;;
0071 
0072   -*)
0073     echo 1>&2 "$0: unknown '$1' option"
0074     echo 1>&2 "Try '$0 --help' for more information"
0075     exit 1
0076     ;;
0077 
0078 esac
0079 
0080 # Run the given program, remember its exit status.
0081 "$@"; st=$?
0082 
0083 # If it succeeded, we are done.
0084 test $st -eq 0 && exit 0
0085 
0086 # Also exit now if we it failed (or wasn't found), and '--version' was
0087 # passed; such an option is passed most likely to detect whether the
0088 # program is present and works.
0089 case $2 in --version|--help) exit $st;; esac
0090 
0091 # Exit code 63 means version mismatch.  This often happens when the user
0092 # tries to use an ancient version of a tool on a file that requires a
0093 # minimum version.
0094 if test $st -eq 63; then
0095   msg="probably too old"
0096 elif test $st -eq 127; then
0097   # Program was missing.
0098   msg="missing on your system"
0099 else
0100   # Program was found and executed, but failed.  Give up.
0101   exit $st
0102 fi
0103 
0104 perl_URL=https://www.perl.org/
0105 flex_URL=https://github.com/westes/flex
0106 gnu_software_URL=https://www.gnu.org/software
0107 
0108 program_details ()
0109 {
0110   case $1 in
0111     aclocal|automake)
0112       echo "The '$1' program is part of the GNU Automake package:"
0113       echo "<$gnu_software_URL/automake>"
0114       echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
0115       echo "<$gnu_software_URL/autoconf>"
0116       echo "<$gnu_software_URL/m4/>"
0117       echo "<$perl_URL>"
0118       ;;
0119     autoconf|autom4te|autoheader)
0120       echo "The '$1' program is part of the GNU Autoconf package:"
0121       echo "<$gnu_software_URL/autoconf/>"
0122       echo "It also requires GNU m4 and Perl in order to run:"
0123       echo "<$gnu_software_URL/m4/>"
0124       echo "<$perl_URL>"
0125       ;;
0126   esac
0127 }
0128 
0129 give_advice ()
0130 {
0131   # Normalize program name to check for.
0132   normalized_program=`echo "$1" | sed '
0133     s/^gnu-//; t
0134     s/^gnu//; t
0135     s/^g//; t'`
0136 
0137   printf '%s\n' "'$1' is $msg."
0138 
0139   configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
0140   case $normalized_program in
0141     autoconf*)
0142       echo "You should only need it if you modified 'configure.ac',"
0143       echo "or m4 files included by it."
0144       program_details 'autoconf'
0145       ;;
0146     autoheader*)
0147       echo "You should only need it if you modified 'acconfig.h' or"
0148       echo "$configure_deps."
0149       program_details 'autoheader'
0150       ;;
0151     automake*)
0152       echo "You should only need it if you modified 'Makefile.am' or"
0153       echo "$configure_deps."
0154       program_details 'automake'
0155       ;;
0156     aclocal*)
0157       echo "You should only need it if you modified 'acinclude.m4' or"
0158       echo "$configure_deps."
0159       program_details 'aclocal'
0160       ;;
0161    autom4te*)
0162       echo "You might have modified some maintainer files that require"
0163       echo "the 'autom4te' program to be rebuilt."
0164       program_details 'autom4te'
0165       ;;
0166     bison*|yacc*)
0167       echo "You should only need it if you modified a '.y' file."
0168       echo "You may want to install the GNU Bison package:"
0169       echo "<$gnu_software_URL/bison/>"
0170       ;;
0171     lex*|flex*)
0172       echo "You should only need it if you modified a '.l' file."
0173       echo "You may want to install the Fast Lexical Analyzer package:"
0174       echo "<$flex_URL>"
0175       ;;
0176     help2man*)
0177       echo "You should only need it if you modified a dependency" \
0178            "of a man page."
0179       echo "You may want to install the GNU Help2man package:"
0180       echo "<$gnu_software_URL/help2man/>"
0181     ;;
0182     makeinfo*)
0183       echo "You should only need it if you modified a '.texi' file, or"
0184       echo "any other file indirectly affecting the aspect of the manual."
0185       echo "You might want to install the Texinfo package:"
0186       echo "<$gnu_software_URL/texinfo/>"
0187       echo "The spurious makeinfo call might also be the consequence of"
0188       echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
0189       echo "want to install GNU make:"
0190       echo "<$gnu_software_URL/make/>"
0191       ;;
0192     *)
0193       echo "You might have modified some files without having the proper"
0194       echo "tools for further handling them.  Check the 'README' file, it"
0195       echo "often tells you about the needed prerequisites for installing"
0196       echo "this package.  You may also peek at any GNU archive site, in"
0197       echo "case some other package contains this missing '$1' program."
0198       ;;
0199   esac
0200 }
0201 
0202 give_advice "$1" | sed -e '1s/^/WARNING: /' \
0203                        -e '2,$s/^/         /' >&2
0204 
0205 # Propagate the correct exit status (expected to be 127 for a program
0206 # not found, 63 for a program that failed due to version mismatch).
0207 exit $st
0208 
0209 # Local variables:
0210 # eval: (add-hook 'before-save-hook 'time-stamp)
0211 # time-stamp-start: "scriptversion="
0212 # time-stamp-format: "%:y-%02m-%02d.%02H"
0213 # time-stamp-time-zone: "UTC0"
0214 # time-stamp-end: "; # UTC"
0215 # End: