missing revision 0a6b08f8
1126a8a12Smrg#! /bin/sh
20a6b08f8Smrg# Common wrapper for a few potentially missing GNU programs.
3126a8a12Smrg
40a6b08f8Smrgscriptversion=2012-06-26.16; # UTC
5126a8a12Smrg
60a6b08f8Smrg# Copyright (C) 1996-2013 Free Software Foundation, Inc.
70a6b08f8Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8126a8a12Smrg
9126a8a12Smrg# This program is free software; you can redistribute it and/or modify
10126a8a12Smrg# it under the terms of the GNU General Public License as published by
11126a8a12Smrg# the Free Software Foundation; either version 2, or (at your option)
12126a8a12Smrg# any later version.
13126a8a12Smrg
14126a8a12Smrg# This program is distributed in the hope that it will be useful,
15126a8a12Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16126a8a12Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17126a8a12Smrg# GNU General Public License for more details.
18126a8a12Smrg
19126a8a12Smrg# You should have received a copy of the GNU General Public License
20d656433aSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21126a8a12Smrg
22126a8a12Smrg# As a special exception to the GNU General Public License, if you
23126a8a12Smrg# distribute this file as part of a program that contains a
24126a8a12Smrg# configuration script generated by Autoconf, you may include it under
25126a8a12Smrg# the same distribution terms that you use for the rest of that program.
26126a8a12Smrg
27126a8a12Smrgif test $# -eq 0; then
280a6b08f8Smrg  echo 1>&2 "Try '$0 --help' for more information"
29126a8a12Smrg  exit 1
30126a8a12Smrgfi
31126a8a12Smrg
320a6b08f8Smrgcase $1 in
33126a8a12Smrg
340a6b08f8Smrg  --is-lightweight)
350a6b08f8Smrg    # Used by our autoconf macros to check whether the available missing
360a6b08f8Smrg    # script is modern enough.
370a6b08f8Smrg    exit 0
380a6b08f8Smrg    ;;
39126a8a12Smrg
400a6b08f8Smrg  --run)
410a6b08f8Smrg    # Back-compat with the calling convention used by older automake.
420a6b08f8Smrg    shift
430a6b08f8Smrg    ;;
44126a8a12Smrg
45126a8a12Smrg  -h|--h|--he|--hel|--help)
46126a8a12Smrg    echo "\
47126a8a12Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48126a8a12Smrg
490a6b08f8SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
500a6b08f8Smrgto PROGRAM being missing or too old.
51126a8a12Smrg
52126a8a12SmrgOptions:
53126a8a12Smrg  -h, --help      display this help and exit
54126a8a12Smrg  -v, --version   output version information and exit
55126a8a12Smrg
56126a8a12SmrgSupported PROGRAM values:
570a6b08f8Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
580a6b08f8Smrg  bison     yacc      flex         lex       help2man
59126a8a12Smrg
600a6b08f8SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
610a6b08f8Smrg'g' are ignored when checking the name.
62d656433aSmrg
63126a8a12SmrgSend bug reports to <bug-automake@gnu.org>."
64126a8a12Smrg    exit $?
65126a8a12Smrg    ;;
66126a8a12Smrg
67126a8a12Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68126a8a12Smrg    echo "missing $scriptversion (GNU Automake)"
69126a8a12Smrg    exit $?
70126a8a12Smrg    ;;
71126a8a12Smrg
72126a8a12Smrg  -*)
730a6b08f8Smrg    echo 1>&2 "$0: unknown '$1' option"
740a6b08f8Smrg    echo 1>&2 "Try '$0 --help' for more information"
75126a8a12Smrg    exit 1
76126a8a12Smrg    ;;
77126a8a12Smrg
78126a8a12Smrgesac
79126a8a12Smrg
800a6b08f8Smrg# Run the given program, remember its exit status.
810a6b08f8Smrg"$@"; st=$?
820a6b08f8Smrg
830a6b08f8Smrg# If it succeeded, we are done.
840a6b08f8Smrgtest $st -eq 0 && exit 0
850a6b08f8Smrg
860a6b08f8Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
870a6b08f8Smrg# passed; such an option is passed most likely to detect whether the
880a6b08f8Smrg# program is present and works.
890a6b08f8Smrgcase $2 in --version|--help) exit $st;; esac
900a6b08f8Smrg
910a6b08f8Smrg# Exit code 63 means version mismatch.  This often happens when the user
920a6b08f8Smrg# tries to use an ancient version of a tool on a file that requires a
930a6b08f8Smrg# minimum version.
940a6b08f8Smrgif test $st -eq 63; then
950a6b08f8Smrg  msg="probably too old"
960a6b08f8Smrgelif test $st -eq 127; then
970a6b08f8Smrg  # Program was missing.
980a6b08f8Smrg  msg="missing on your system"
990a6b08f8Smrgelse
1000a6b08f8Smrg  # Program was found and executed, but failed.  Give up.
1010a6b08f8Smrg  exit $st
1020a6b08f8Smrgfi
103126a8a12Smrg
1040a6b08f8Smrgperl_URL=http://www.perl.org/
1050a6b08f8Smrgflex_URL=http://flex.sourceforge.net/
1060a6b08f8Smrggnu_software_URL=http://www.gnu.org/software
1070a6b08f8Smrg
1080a6b08f8Smrgprogram_details ()
1090a6b08f8Smrg{
1100a6b08f8Smrg  case $1 in
1110a6b08f8Smrg    aclocal|automake)
1120a6b08f8Smrg      echo "The '$1' program is part of the GNU Automake package:"
1130a6b08f8Smrg      echo "<$gnu_software_URL/automake>"
1140a6b08f8Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1150a6b08f8Smrg      echo "<$gnu_software_URL/autoconf>"
1160a6b08f8Smrg      echo "<$gnu_software_URL/m4/>"
1170a6b08f8Smrg      echo "<$perl_URL>"
1180a6b08f8Smrg      ;;
1190a6b08f8Smrg    autoconf|autom4te|autoheader)
1200a6b08f8Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
1210a6b08f8Smrg      echo "<$gnu_software_URL/autoconf/>"
1220a6b08f8Smrg      echo "It also requires GNU m4 and Perl in order to run:"
1230a6b08f8Smrg      echo "<$gnu_software_URL/m4/>"
1240a6b08f8Smrg      echo "<$perl_URL>"
1250a6b08f8Smrg      ;;
1260a6b08f8Smrg  esac
1270a6b08f8Smrg}
1280a6b08f8Smrg
1290a6b08f8Smrggive_advice ()
1300a6b08f8Smrg{
1310a6b08f8Smrg  # Normalize program name to check for.
1320a6b08f8Smrg  normalized_program=`echo "$1" | sed '
1330a6b08f8Smrg    s/^gnu-//; t
1340a6b08f8Smrg    s/^gnu//; t
1350a6b08f8Smrg    s/^g//; t'`
1360a6b08f8Smrg
1370a6b08f8Smrg  printf '%s\n' "'$1' is $msg."
1380a6b08f8Smrg
1390a6b08f8Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1400a6b08f8Smrg  case $normalized_program in
1410a6b08f8Smrg    autoconf*)
1420a6b08f8Smrg      echo "You should only need it if you modified 'configure.ac',"
1430a6b08f8Smrg      echo "or m4 files included by it."
1440a6b08f8Smrg      program_details 'autoconf'
1450a6b08f8Smrg      ;;
1460a6b08f8Smrg    autoheader*)
1470a6b08f8Smrg      echo "You should only need it if you modified 'acconfig.h' or"
1480a6b08f8Smrg      echo "$configure_deps."
1490a6b08f8Smrg      program_details 'autoheader'
1500a6b08f8Smrg      ;;
1510a6b08f8Smrg    automake*)
1520a6b08f8Smrg      echo "You should only need it if you modified 'Makefile.am' or"
1530a6b08f8Smrg      echo "$configure_deps."
1540a6b08f8Smrg      program_details 'automake'
1550a6b08f8Smrg      ;;
1560a6b08f8Smrg    aclocal*)
1570a6b08f8Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
1580a6b08f8Smrg      echo "$configure_deps."
1590a6b08f8Smrg      program_details 'aclocal'
1600a6b08f8Smrg      ;;
1610a6b08f8Smrg   autom4te*)
1620a6b08f8Smrg      echo "You might have modified some maintainer files that require"
1630a6b08f8Smrg      echo "the 'automa4te' program to be rebuilt."
1640a6b08f8Smrg      program_details 'autom4te'
1650a6b08f8Smrg      ;;
1660a6b08f8Smrg    bison*|yacc*)
1670a6b08f8Smrg      echo "You should only need it if you modified a '.y' file."
1680a6b08f8Smrg      echo "You may want to install the GNU Bison package:"
1690a6b08f8Smrg      echo "<$gnu_software_URL/bison/>"
1700a6b08f8Smrg      ;;
1710a6b08f8Smrg    lex*|flex*)
1720a6b08f8Smrg      echo "You should only need it if you modified a '.l' file."
1730a6b08f8Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
1740a6b08f8Smrg      echo "<$flex_URL>"
1750a6b08f8Smrg      ;;
1760a6b08f8Smrg    help2man*)
1770a6b08f8Smrg      echo "You should only need it if you modified a dependency" \
1780a6b08f8Smrg           "of a man page."
1790a6b08f8Smrg      echo "You may want to install the GNU Help2man package:"
1800a6b08f8Smrg      echo "<$gnu_software_URL/help2man/>"
1810a6b08f8Smrg    ;;
1820a6b08f8Smrg    makeinfo*)
1830a6b08f8Smrg      echo "You should only need it if you modified a '.texi' file, or"
1840a6b08f8Smrg      echo "any other file indirectly affecting the aspect of the manual."
1850a6b08f8Smrg      echo "You might want to install the Texinfo package:"
1860a6b08f8Smrg      echo "<$gnu_software_URL/texinfo/>"
1870a6b08f8Smrg      echo "The spurious makeinfo call might also be the consequence of"
1880a6b08f8Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1890a6b08f8Smrg      echo "want to install GNU make:"
1900a6b08f8Smrg      echo "<$gnu_software_URL/make/>"
1910a6b08f8Smrg      ;;
1920a6b08f8Smrg    *)
1930a6b08f8Smrg      echo "You might have modified some files without having the proper"
1940a6b08f8Smrg      echo "tools for further handling them.  Check the 'README' file, it"
1950a6b08f8Smrg      echo "often tells you about the needed prerequisites for installing"
1960a6b08f8Smrg      echo "this package.  You may also peek at any GNU archive site, in"
1970a6b08f8Smrg      echo "case some other package contains this missing '$1' program."
1980a6b08f8Smrg      ;;
1990a6b08f8Smrg  esac
2000a6b08f8Smrg}
2010a6b08f8Smrg
2020a6b08f8Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2030a6b08f8Smrg                       -e '2,$s/^/         /' >&2
2040a6b08f8Smrg
2050a6b08f8Smrg# Propagate the correct exit status (expected to be 127 for a program
2060a6b08f8Smrg# not found, 63 for a program that failed due to version mismatch).
2070a6b08f8Smrgexit $st
208126a8a12Smrg
209126a8a12Smrg# Local variables:
210126a8a12Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
211126a8a12Smrg# time-stamp-start: "scriptversion="
212126a8a12Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213d656433aSmrg# time-stamp-time-zone: "UTC"
214d656433aSmrg# time-stamp-end: "; # UTC"
215126a8a12Smrg# End:
216