missing revision 2becc446
12c7c4e3dSmrg#! /bin/sh
22becc446Smrg# Common wrapper for a few potentially missing GNU programs.
38650bb69Smrg
42becc446Smrgscriptversion=2013-10-28.13; # UTC
58650bb69Smrg
62becc446Smrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
72becc446Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
82c7c4e3dSmrg
92c7c4e3dSmrg# This program is free software; you can redistribute it and/or modify
102c7c4e3dSmrg# it under the terms of the GNU General Public License as published by
112c7c4e3dSmrg# the Free Software Foundation; either version 2, or (at your option)
122c7c4e3dSmrg# any later version.
132c7c4e3dSmrg
142c7c4e3dSmrg# This program is distributed in the hope that it will be useful,
152c7c4e3dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
162c7c4e3dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
172c7c4e3dSmrg# GNU General Public License for more details.
182c7c4e3dSmrg
192c7c4e3dSmrg# You should have received a copy of the GNU General Public License
208650bb69Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
212c7c4e3dSmrg
222c7c4e3dSmrg# As a special exception to the GNU General Public License, if you
232c7c4e3dSmrg# distribute this file as part of a program that contains a
242c7c4e3dSmrg# configuration script generated by Autoconf, you may include it under
252c7c4e3dSmrg# the same distribution terms that you use for the rest of that program.
262c7c4e3dSmrg
272c7c4e3dSmrgif test $# -eq 0; then
282becc446Smrg  echo 1>&2 "Try '$0 --help' for more information"
292c7c4e3dSmrg  exit 1
302c7c4e3dSmrgfi
312c7c4e3dSmrg
322becc446Smrgcase $1 in
332c7c4e3dSmrg
342becc446Smrg  --is-lightweight)
352becc446Smrg    # Used by our autoconf macros to check whether the available missing
362becc446Smrg    # script is modern enough.
372becc446Smrg    exit 0
382becc446Smrg    ;;
398650bb69Smrg
402becc446Smrg  --run)
412becc446Smrg    # Back-compat with the calling convention used by older automake.
422becc446Smrg    shift
432becc446Smrg    ;;
442c7c4e3dSmrg
452c7c4e3dSmrg  -h|--h|--he|--hel|--help)
462c7c4e3dSmrg    echo "\
472c7c4e3dSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
482c7c4e3dSmrg
492becc446SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
502becc446Smrgto PROGRAM being missing or too old.
512c7c4e3dSmrg
522c7c4e3dSmrgOptions:
532c7c4e3dSmrg  -h, --help      display this help and exit
542c7c4e3dSmrg  -v, --version   output version information and exit
552c7c4e3dSmrg
562c7c4e3dSmrgSupported PROGRAM values:
572becc446Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
582becc446Smrg  bison     yacc      flex         lex       help2man
598650bb69Smrg
602becc446SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
612becc446Smrg'g' are ignored when checking the name.
628650bb69Smrg
638650bb69SmrgSend bug reports to <bug-automake@gnu.org>."
648650bb69Smrg    exit $?
652c7c4e3dSmrg    ;;
662c7c4e3dSmrg
672c7c4e3dSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
688650bb69Smrg    echo "missing $scriptversion (GNU Automake)"
698650bb69Smrg    exit $?
702c7c4e3dSmrg    ;;
712c7c4e3dSmrg
722c7c4e3dSmrg  -*)
732becc446Smrg    echo 1>&2 "$0: unknown '$1' option"
742becc446Smrg    echo 1>&2 "Try '$0 --help' for more information"
752c7c4e3dSmrg    exit 1
762c7c4e3dSmrg    ;;
772c7c4e3dSmrg
788650bb69Smrgesac
798650bb69Smrg
802becc446Smrg# Run the given program, remember its exit status.
812becc446Smrg"$@"; st=$?
822becc446Smrg
832becc446Smrg# If it succeeded, we are done.
842becc446Smrgtest $st -eq 0 && exit 0
852becc446Smrg
862becc446Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
872becc446Smrg# passed; such an option is passed most likely to detect whether the
882becc446Smrg# program is present and works.
892becc446Smrgcase $2 in --version|--help) exit $st;; esac
902becc446Smrg
912becc446Smrg# Exit code 63 means version mismatch.  This often happens when the user
922becc446Smrg# tries to use an ancient version of a tool on a file that requires a
932becc446Smrg# minimum version.
942becc446Smrgif test $st -eq 63; then
952becc446Smrg  msg="probably too old"
962becc446Smrgelif test $st -eq 127; then
972becc446Smrg  # Program was missing.
982becc446Smrg  msg="missing on your system"
992becc446Smrgelse
1002becc446Smrg  # Program was found and executed, but failed.  Give up.
1012becc446Smrg  exit $st
1022becc446Smrgfi
1032c7c4e3dSmrg
1042becc446Smrgperl_URL=http://www.perl.org/
1052becc446Smrgflex_URL=http://flex.sourceforge.net/
1062becc446Smrggnu_software_URL=http://www.gnu.org/software
1072becc446Smrg
1082becc446Smrgprogram_details ()
1092becc446Smrg{
1102becc446Smrg  case $1 in
1112becc446Smrg    aclocal|automake)
1122becc446Smrg      echo "The '$1' program is part of the GNU Automake package:"
1132becc446Smrg      echo "<$gnu_software_URL/automake>"
1142becc446Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1152becc446Smrg      echo "<$gnu_software_URL/autoconf>"
1162becc446Smrg      echo "<$gnu_software_URL/m4/>"
1172becc446Smrg      echo "<$perl_URL>"
1182becc446Smrg      ;;
1192becc446Smrg    autoconf|autom4te|autoheader)
1202becc446Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
1212becc446Smrg      echo "<$gnu_software_URL/autoconf/>"
1222becc446Smrg      echo "It also requires GNU m4 and Perl in order to run:"
1232becc446Smrg      echo "<$gnu_software_URL/m4/>"
1242becc446Smrg      echo "<$perl_URL>"
1252becc446Smrg      ;;
1262becc446Smrg  esac
1272becc446Smrg}
1282becc446Smrg
1292becc446Smrggive_advice ()
1302becc446Smrg{
1312becc446Smrg  # Normalize program name to check for.
1322becc446Smrg  normalized_program=`echo "$1" | sed '
1332becc446Smrg    s/^gnu-//; t
1342becc446Smrg    s/^gnu//; t
1352becc446Smrg    s/^g//; t'`
1362becc446Smrg
1372becc446Smrg  printf '%s\n' "'$1' is $msg."
1382becc446Smrg
1392becc446Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1402becc446Smrg  case $normalized_program in
1412becc446Smrg    autoconf*)
1422becc446Smrg      echo "You should only need it if you modified 'configure.ac',"
1432becc446Smrg      echo "or m4 files included by it."
1442becc446Smrg      program_details 'autoconf'
1452becc446Smrg      ;;
1462becc446Smrg    autoheader*)
1472becc446Smrg      echo "You should only need it if you modified 'acconfig.h' or"
1482becc446Smrg      echo "$configure_deps."
1492becc446Smrg      program_details 'autoheader'
1502becc446Smrg      ;;
1512becc446Smrg    automake*)
1522becc446Smrg      echo "You should only need it if you modified 'Makefile.am' or"
1532becc446Smrg      echo "$configure_deps."
1542becc446Smrg      program_details 'automake'
1552becc446Smrg      ;;
1562becc446Smrg    aclocal*)
1572becc446Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
1582becc446Smrg      echo "$configure_deps."
1592becc446Smrg      program_details 'aclocal'
1602becc446Smrg      ;;
1612becc446Smrg   autom4te*)
1622becc446Smrg      echo "You might have modified some maintainer files that require"
1632becc446Smrg      echo "the 'autom4te' program to be rebuilt."
1642becc446Smrg      program_details 'autom4te'
1652becc446Smrg      ;;
1662becc446Smrg    bison*|yacc*)
1672becc446Smrg      echo "You should only need it if you modified a '.y' file."
1682becc446Smrg      echo "You may want to install the GNU Bison package:"
1692becc446Smrg      echo "<$gnu_software_URL/bison/>"
1702becc446Smrg      ;;
1712becc446Smrg    lex*|flex*)
1722becc446Smrg      echo "You should only need it if you modified a '.l' file."
1732becc446Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
1742becc446Smrg      echo "<$flex_URL>"
1752becc446Smrg      ;;
1762becc446Smrg    help2man*)
1772becc446Smrg      echo "You should only need it if you modified a dependency" \
1782becc446Smrg           "of a man page."
1792becc446Smrg      echo "You may want to install the GNU Help2man package:"
1802becc446Smrg      echo "<$gnu_software_URL/help2man/>"
1812becc446Smrg    ;;
1822becc446Smrg    makeinfo*)
1832becc446Smrg      echo "You should only need it if you modified a '.texi' file, or"
1842becc446Smrg      echo "any other file indirectly affecting the aspect of the manual."
1852becc446Smrg      echo "You might want to install the Texinfo package:"
1862becc446Smrg      echo "<$gnu_software_URL/texinfo/>"
1872becc446Smrg      echo "The spurious makeinfo call might also be the consequence of"
1882becc446Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1892becc446Smrg      echo "want to install GNU make:"
1902becc446Smrg      echo "<$gnu_software_URL/make/>"
1912becc446Smrg      ;;
1922becc446Smrg    *)
1932becc446Smrg      echo "You might have modified some files without having the proper"
1942becc446Smrg      echo "tools for further handling them.  Check the 'README' file, it"
1952becc446Smrg      echo "often tells you about the needed prerequisites for installing"
1962becc446Smrg      echo "this package.  You may also peek at any GNU archive site, in"
1972becc446Smrg      echo "case some other package contains this missing '$1' program."
1982becc446Smrg      ;;
1992becc446Smrg  esac
2002becc446Smrg}
2012becc446Smrg
2022becc446Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2032becc446Smrg                       -e '2,$s/^/         /' >&2
2042becc446Smrg
2052becc446Smrg# Propagate the correct exit status (expected to be 127 for a program
2062becc446Smrg# not found, 63 for a program that failed due to version mismatch).
2072becc446Smrgexit $st
2088650bb69Smrg
2098650bb69Smrg# Local variables:
2108650bb69Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
2118650bb69Smrg# time-stamp-start: "scriptversion="
2128650bb69Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
2138650bb69Smrg# time-stamp-time-zone: "UTC"
2148650bb69Smrg# time-stamp-end: "; # UTC"
2158650bb69Smrg# End:
216