missing revision fc34a306
10e20ee16Smrg#! /bin/sh
22f167a42Smrg# Common wrapper for a few potentially missing GNU programs.
33e6697d4Smrg
4fc34a306Smrgscriptversion=2018-03-07.03; # UTC
53e6697d4Smrg
6fc34a306Smrg# Copyright (C) 1996-2018 Free Software Foundation, Inc.
72f167a42Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
80e20ee16Smrg
90e20ee16Smrg# This program is free software; you can redistribute it and/or modify
100e20ee16Smrg# it under the terms of the GNU General Public License as published by
110e20ee16Smrg# the Free Software Foundation; either version 2, or (at your option)
120e20ee16Smrg# any later version.
130e20ee16Smrg
140e20ee16Smrg# This program is distributed in the hope that it will be useful,
150e20ee16Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
160e20ee16Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
170e20ee16Smrg# GNU General Public License for more details.
180e20ee16Smrg
190e20ee16Smrg# You should have received a copy of the GNU General Public License
20fc34a306Smrg# along with this program.  If not, see <https://www.gnu.org/licenses/>.
210e20ee16Smrg
220e20ee16Smrg# As a special exception to the GNU General Public License, if you
230e20ee16Smrg# distribute this file as part of a program that contains a
240e20ee16Smrg# configuration script generated by Autoconf, you may include it under
250e20ee16Smrg# the same distribution terms that you use for the rest of that program.
260e20ee16Smrg
270e20ee16Smrgif test $# -eq 0; then
282f167a42Smrg  echo 1>&2 "Try '$0 --help' for more information"
290e20ee16Smrg  exit 1
300e20ee16Smrgfi
310e20ee16Smrg
322f167a42Smrgcase $1 in
330e20ee16Smrg
342f167a42Smrg  --is-lightweight)
352f167a42Smrg    # Used by our autoconf macros to check whether the available missing
362f167a42Smrg    # script is modern enough.
372f167a42Smrg    exit 0
382f167a42Smrg    ;;
393e6697d4Smrg
402f167a42Smrg  --run)
412f167a42Smrg    # Back-compat with the calling convention used by older automake.
422f167a42Smrg    shift
432f167a42Smrg    ;;
440e20ee16Smrg
450e20ee16Smrg  -h|--h|--he|--hel|--help)
460e20ee16Smrg    echo "\
470e20ee16Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
480e20ee16Smrg
492f167a42SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
502f167a42Smrgto PROGRAM being missing or too old.
510e20ee16Smrg
520e20ee16SmrgOptions:
530e20ee16Smrg  -h, --help      display this help and exit
540e20ee16Smrg  -v, --version   output version information and exit
550e20ee16Smrg
560e20ee16SmrgSupported PROGRAM values:
572f167a42Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
582f167a42Smrg  bison     yacc      flex         lex       help2man
593e6697d4Smrg
602f167a42SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
612f167a42Smrg'g' are ignored when checking the name.
623e6697d4Smrg
633e6697d4SmrgSend bug reports to <bug-automake@gnu.org>."
643e6697d4Smrg    exit $?
650e20ee16Smrg    ;;
660e20ee16Smrg
670e20ee16Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
683e6697d4Smrg    echo "missing $scriptversion (GNU Automake)"
693e6697d4Smrg    exit $?
700e20ee16Smrg    ;;
710e20ee16Smrg
720e20ee16Smrg  -*)
732f167a42Smrg    echo 1>&2 "$0: unknown '$1' option"
742f167a42Smrg    echo 1>&2 "Try '$0 --help' for more information"
750e20ee16Smrg    exit 1
760e20ee16Smrg    ;;
770e20ee16Smrg
783e6697d4Smrgesac
793e6697d4Smrg
802f167a42Smrg# Run the given program, remember its exit status.
812f167a42Smrg"$@"; st=$?
822f167a42Smrg
832f167a42Smrg# If it succeeded, we are done.
842f167a42Smrgtest $st -eq 0 && exit 0
852f167a42Smrg
862f167a42Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
872f167a42Smrg# passed; such an option is passed most likely to detect whether the
882f167a42Smrg# program is present and works.
892f167a42Smrgcase $2 in --version|--help) exit $st;; esac
902f167a42Smrg
912f167a42Smrg# Exit code 63 means version mismatch.  This often happens when the user
922f167a42Smrg# tries to use an ancient version of a tool on a file that requires a
932f167a42Smrg# minimum version.
942f167a42Smrgif test $st -eq 63; then
952f167a42Smrg  msg="probably too old"
962f167a42Smrgelif test $st -eq 127; then
972f167a42Smrg  # Program was missing.
982f167a42Smrg  msg="missing on your system"
992f167a42Smrgelse
1002f167a42Smrg  # Program was found and executed, but failed.  Give up.
1012f167a42Smrg  exit $st
1022f167a42Smrgfi
1030e20ee16Smrg
104fc34a306Smrgperl_URL=https://www.perl.org/
105fc34a306Smrgflex_URL=https://github.com/westes/flex
106fc34a306Smrggnu_software_URL=https://www.gnu.org/software
1072f167a42Smrg
1082f167a42Smrgprogram_details ()
1092f167a42Smrg{
1102f167a42Smrg  case $1 in
1112f167a42Smrg    aclocal|automake)
1122f167a42Smrg      echo "The '$1' program is part of the GNU Automake package:"
1132f167a42Smrg      echo "<$gnu_software_URL/automake>"
1142f167a42Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1152f167a42Smrg      echo "<$gnu_software_URL/autoconf>"
1162f167a42Smrg      echo "<$gnu_software_URL/m4/>"
1172f167a42Smrg      echo "<$perl_URL>"
1182f167a42Smrg      ;;
1192f167a42Smrg    autoconf|autom4te|autoheader)
1202f167a42Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
1212f167a42Smrg      echo "<$gnu_software_URL/autoconf/>"
1222f167a42Smrg      echo "It also requires GNU m4 and Perl in order to run:"
1232f167a42Smrg      echo "<$gnu_software_URL/m4/>"
1242f167a42Smrg      echo "<$perl_URL>"
1252f167a42Smrg      ;;
1262f167a42Smrg  esac
1272f167a42Smrg}
1282f167a42Smrg
1292f167a42Smrggive_advice ()
1302f167a42Smrg{
1312f167a42Smrg  # Normalize program name to check for.
1322f167a42Smrg  normalized_program=`echo "$1" | sed '
1332f167a42Smrg    s/^gnu-//; t
1342f167a42Smrg    s/^gnu//; t
1352f167a42Smrg    s/^g//; t'`
1362f167a42Smrg
1372f167a42Smrg  printf '%s\n' "'$1' is $msg."
1382f167a42Smrg
1392f167a42Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1402f167a42Smrg  case $normalized_program in
1412f167a42Smrg    autoconf*)
1422f167a42Smrg      echo "You should only need it if you modified 'configure.ac',"
1432f167a42Smrg      echo "or m4 files included by it."
1442f167a42Smrg      program_details 'autoconf'
1452f167a42Smrg      ;;
1462f167a42Smrg    autoheader*)
1472f167a42Smrg      echo "You should only need it if you modified 'acconfig.h' or"
1482f167a42Smrg      echo "$configure_deps."
1492f167a42Smrg      program_details 'autoheader'
1502f167a42Smrg      ;;
1512f167a42Smrg    automake*)
1522f167a42Smrg      echo "You should only need it if you modified 'Makefile.am' or"
1532f167a42Smrg      echo "$configure_deps."
1542f167a42Smrg      program_details 'automake'
1552f167a42Smrg      ;;
1562f167a42Smrg    aclocal*)
1572f167a42Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
1582f167a42Smrg      echo "$configure_deps."
1592f167a42Smrg      program_details 'aclocal'
1602f167a42Smrg      ;;
1612f167a42Smrg   autom4te*)
1622f167a42Smrg      echo "You might have modified some maintainer files that require"
1632f167a42Smrg      echo "the 'autom4te' program to be rebuilt."
1642f167a42Smrg      program_details 'autom4te'
1652f167a42Smrg      ;;
1662f167a42Smrg    bison*|yacc*)
1672f167a42Smrg      echo "You should only need it if you modified a '.y' file."
1682f167a42Smrg      echo "You may want to install the GNU Bison package:"
1692f167a42Smrg      echo "<$gnu_software_URL/bison/>"
1702f167a42Smrg      ;;
1712f167a42Smrg    lex*|flex*)
1722f167a42Smrg      echo "You should only need it if you modified a '.l' file."
1732f167a42Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
1742f167a42Smrg      echo "<$flex_URL>"
1752f167a42Smrg      ;;
1762f167a42Smrg    help2man*)
1772f167a42Smrg      echo "You should only need it if you modified a dependency" \
1782f167a42Smrg           "of a man page."
1792f167a42Smrg      echo "You may want to install the GNU Help2man package:"
1802f167a42Smrg      echo "<$gnu_software_URL/help2man/>"
1812f167a42Smrg    ;;
1822f167a42Smrg    makeinfo*)
1832f167a42Smrg      echo "You should only need it if you modified a '.texi' file, or"
1842f167a42Smrg      echo "any other file indirectly affecting the aspect of the manual."
1852f167a42Smrg      echo "You might want to install the Texinfo package:"
1862f167a42Smrg      echo "<$gnu_software_URL/texinfo/>"
1872f167a42Smrg      echo "The spurious makeinfo call might also be the consequence of"
1882f167a42Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1892f167a42Smrg      echo "want to install GNU make:"
1902f167a42Smrg      echo "<$gnu_software_URL/make/>"
1912f167a42Smrg      ;;
1922f167a42Smrg    *)
1932f167a42Smrg      echo "You might have modified some files without having the proper"
1942f167a42Smrg      echo "tools for further handling them.  Check the 'README' file, it"
1952f167a42Smrg      echo "often tells you about the needed prerequisites for installing"
1962f167a42Smrg      echo "this package.  You may also peek at any GNU archive site, in"
1972f167a42Smrg      echo "case some other package contains this missing '$1' program."
1982f167a42Smrg      ;;
1992f167a42Smrg  esac
2002f167a42Smrg}
2012f167a42Smrg
2022f167a42Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2032f167a42Smrg                       -e '2,$s/^/         /' >&2
2042f167a42Smrg
2052f167a42Smrg# Propagate the correct exit status (expected to be 127 for a program
2062f167a42Smrg# not found, 63 for a program that failed due to version mismatch).
2072f167a42Smrgexit $st
2083e6697d4Smrg
2093e6697d4Smrg# Local variables:
210fc34a306Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
2113e6697d4Smrg# time-stamp-start: "scriptversion="
2123e6697d4Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213fc34a306Smrg# time-stamp-time-zone: "UTC0"
2143e6697d4Smrg# time-stamp-end: "; # UTC"
2153e6697d4Smrg# End:
216