missing revision 5eeb4e8f
1972599cfSmrg#! /bin/sh
25eeb4e8fSmrg# Common wrapper for a few potentially missing GNU programs.
3972599cfSmrg
45eeb4e8fSmrgscriptversion=2013-10-28.13; # UTC
5972599cfSmrg
65eeb4e8fSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
75eeb4e8fSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8972599cfSmrg
9972599cfSmrg# This program is free software; you can redistribute it and/or modify
10972599cfSmrg# it under the terms of the GNU General Public License as published by
11972599cfSmrg# the Free Software Foundation; either version 2, or (at your option)
12972599cfSmrg# any later version.
13972599cfSmrg
14972599cfSmrg# This program is distributed in the hope that it will be useful,
15972599cfSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16972599cfSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17972599cfSmrg# GNU General Public License for more details.
18972599cfSmrg
19972599cfSmrg# You should have received a copy of the GNU General Public License
20972599cfSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21972599cfSmrg
22972599cfSmrg# As a special exception to the GNU General Public License, if you
23972599cfSmrg# distribute this file as part of a program that contains a
24972599cfSmrg# configuration script generated by Autoconf, you may include it under
25972599cfSmrg# the same distribution terms that you use for the rest of that program.
26972599cfSmrg
27972599cfSmrgif test $# -eq 0; then
285eeb4e8fSmrg  echo 1>&2 "Try '$0 --help' for more information"
29972599cfSmrg  exit 1
30972599cfSmrgfi
31972599cfSmrg
325eeb4e8fSmrgcase $1 in
33972599cfSmrg
345eeb4e8fSmrg  --is-lightweight)
355eeb4e8fSmrg    # Used by our autoconf macros to check whether the available missing
365eeb4e8fSmrg    # script is modern enough.
375eeb4e8fSmrg    exit 0
385eeb4e8fSmrg    ;;
39972599cfSmrg
405eeb4e8fSmrg  --run)
415eeb4e8fSmrg    # Back-compat with the calling convention used by older automake.
425eeb4e8fSmrg    shift
435eeb4e8fSmrg    ;;
44972599cfSmrg
45972599cfSmrg  -h|--h|--he|--hel|--help)
46972599cfSmrg    echo "\
47972599cfSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48972599cfSmrg
495eeb4e8fSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
505eeb4e8fSmrgto PROGRAM being missing or too old.
51972599cfSmrg
52972599cfSmrgOptions:
53972599cfSmrg  -h, --help      display this help and exit
54972599cfSmrg  -v, --version   output version information and exit
55972599cfSmrg
56972599cfSmrgSupported PROGRAM values:
575eeb4e8fSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
585eeb4e8fSmrg  bison     yacc      flex         lex       help2man
59972599cfSmrg
605eeb4e8fSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
615eeb4e8fSmrg'g' are ignored when checking the name.
62972599cfSmrg
63972599cfSmrgSend bug reports to <bug-automake@gnu.org>."
64972599cfSmrg    exit $?
65972599cfSmrg    ;;
66972599cfSmrg
67972599cfSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68972599cfSmrg    echo "missing $scriptversion (GNU Automake)"
69972599cfSmrg    exit $?
70972599cfSmrg    ;;
71972599cfSmrg
72972599cfSmrg  -*)
735eeb4e8fSmrg    echo 1>&2 "$0: unknown '$1' option"
745eeb4e8fSmrg    echo 1>&2 "Try '$0 --help' for more information"
75972599cfSmrg    exit 1
76972599cfSmrg    ;;
77972599cfSmrg
78972599cfSmrgesac
79972599cfSmrg
805eeb4e8fSmrg# Run the given program, remember its exit status.
815eeb4e8fSmrg"$@"; st=$?
825eeb4e8fSmrg
835eeb4e8fSmrg# If it succeeded, we are done.
845eeb4e8fSmrgtest $st -eq 0 && exit 0
855eeb4e8fSmrg
865eeb4e8fSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
875eeb4e8fSmrg# passed; such an option is passed most likely to detect whether the
885eeb4e8fSmrg# program is present and works.
895eeb4e8fSmrgcase $2 in --version|--help) exit $st;; esac
905eeb4e8fSmrg
915eeb4e8fSmrg# Exit code 63 means version mismatch.  This often happens when the user
925eeb4e8fSmrg# tries to use an ancient version of a tool on a file that requires a
935eeb4e8fSmrg# minimum version.
945eeb4e8fSmrgif test $st -eq 63; then
955eeb4e8fSmrg  msg="probably too old"
965eeb4e8fSmrgelif test $st -eq 127; then
975eeb4e8fSmrg  # Program was missing.
985eeb4e8fSmrg  msg="missing on your system"
995eeb4e8fSmrgelse
1005eeb4e8fSmrg  # Program was found and executed, but failed.  Give up.
1015eeb4e8fSmrg  exit $st
1025eeb4e8fSmrgfi
103972599cfSmrg
1045eeb4e8fSmrgperl_URL=http://www.perl.org/
1055eeb4e8fSmrgflex_URL=http://flex.sourceforge.net/
1065eeb4e8fSmrggnu_software_URL=http://www.gnu.org/software
1075eeb4e8fSmrg
1085eeb4e8fSmrgprogram_details ()
1095eeb4e8fSmrg{
1105eeb4e8fSmrg  case $1 in
1115eeb4e8fSmrg    aclocal|automake)
1125eeb4e8fSmrg      echo "The '$1' program is part of the GNU Automake package:"
1135eeb4e8fSmrg      echo "<$gnu_software_URL/automake>"
1145eeb4e8fSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1155eeb4e8fSmrg      echo "<$gnu_software_URL/autoconf>"
1165eeb4e8fSmrg      echo "<$gnu_software_URL/m4/>"
1175eeb4e8fSmrg      echo "<$perl_URL>"
1185eeb4e8fSmrg      ;;
1195eeb4e8fSmrg    autoconf|autom4te|autoheader)
1205eeb4e8fSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
1215eeb4e8fSmrg      echo "<$gnu_software_URL/autoconf/>"
1225eeb4e8fSmrg      echo "It also requires GNU m4 and Perl in order to run:"
1235eeb4e8fSmrg      echo "<$gnu_software_URL/m4/>"
1245eeb4e8fSmrg      echo "<$perl_URL>"
1255eeb4e8fSmrg      ;;
1265eeb4e8fSmrg  esac
1275eeb4e8fSmrg}
1285eeb4e8fSmrg
1295eeb4e8fSmrggive_advice ()
1305eeb4e8fSmrg{
1315eeb4e8fSmrg  # Normalize program name to check for.
1325eeb4e8fSmrg  normalized_program=`echo "$1" | sed '
1335eeb4e8fSmrg    s/^gnu-//; t
1345eeb4e8fSmrg    s/^gnu//; t
1355eeb4e8fSmrg    s/^g//; t'`
1365eeb4e8fSmrg
1375eeb4e8fSmrg  printf '%s\n' "'$1' is $msg."
1385eeb4e8fSmrg
1395eeb4e8fSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1405eeb4e8fSmrg  case $normalized_program in
1415eeb4e8fSmrg    autoconf*)
1425eeb4e8fSmrg      echo "You should only need it if you modified 'configure.ac',"
1435eeb4e8fSmrg      echo "or m4 files included by it."
1445eeb4e8fSmrg      program_details 'autoconf'
1455eeb4e8fSmrg      ;;
1465eeb4e8fSmrg    autoheader*)
1475eeb4e8fSmrg      echo "You should only need it if you modified 'acconfig.h' or"
1485eeb4e8fSmrg      echo "$configure_deps."
1495eeb4e8fSmrg      program_details 'autoheader'
1505eeb4e8fSmrg      ;;
1515eeb4e8fSmrg    automake*)
1525eeb4e8fSmrg      echo "You should only need it if you modified 'Makefile.am' or"
1535eeb4e8fSmrg      echo "$configure_deps."
1545eeb4e8fSmrg      program_details 'automake'
1555eeb4e8fSmrg      ;;
1565eeb4e8fSmrg    aclocal*)
1575eeb4e8fSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
1585eeb4e8fSmrg      echo "$configure_deps."
1595eeb4e8fSmrg      program_details 'aclocal'
1605eeb4e8fSmrg      ;;
1615eeb4e8fSmrg   autom4te*)
1625eeb4e8fSmrg      echo "You might have modified some maintainer files that require"
1635eeb4e8fSmrg      echo "the 'autom4te' program to be rebuilt."
1645eeb4e8fSmrg      program_details 'autom4te'
1655eeb4e8fSmrg      ;;
1665eeb4e8fSmrg    bison*|yacc*)
1675eeb4e8fSmrg      echo "You should only need it if you modified a '.y' file."
1685eeb4e8fSmrg      echo "You may want to install the GNU Bison package:"
1695eeb4e8fSmrg      echo "<$gnu_software_URL/bison/>"
1705eeb4e8fSmrg      ;;
1715eeb4e8fSmrg    lex*|flex*)
1725eeb4e8fSmrg      echo "You should only need it if you modified a '.l' file."
1735eeb4e8fSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
1745eeb4e8fSmrg      echo "<$flex_URL>"
1755eeb4e8fSmrg      ;;
1765eeb4e8fSmrg    help2man*)
1775eeb4e8fSmrg      echo "You should only need it if you modified a dependency" \
1785eeb4e8fSmrg           "of a man page."
1795eeb4e8fSmrg      echo "You may want to install the GNU Help2man package:"
1805eeb4e8fSmrg      echo "<$gnu_software_URL/help2man/>"
1815eeb4e8fSmrg    ;;
1825eeb4e8fSmrg    makeinfo*)
1835eeb4e8fSmrg      echo "You should only need it if you modified a '.texi' file, or"
1845eeb4e8fSmrg      echo "any other file indirectly affecting the aspect of the manual."
1855eeb4e8fSmrg      echo "You might want to install the Texinfo package:"
1865eeb4e8fSmrg      echo "<$gnu_software_URL/texinfo/>"
1875eeb4e8fSmrg      echo "The spurious makeinfo call might also be the consequence of"
1885eeb4e8fSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1895eeb4e8fSmrg      echo "want to install GNU make:"
1905eeb4e8fSmrg      echo "<$gnu_software_URL/make/>"
1915eeb4e8fSmrg      ;;
1925eeb4e8fSmrg    *)
1935eeb4e8fSmrg      echo "You might have modified some files without having the proper"
1945eeb4e8fSmrg      echo "tools for further handling them.  Check the 'README' file, it"
1955eeb4e8fSmrg      echo "often tells you about the needed prerequisites for installing"
1965eeb4e8fSmrg      echo "this package.  You may also peek at any GNU archive site, in"
1975eeb4e8fSmrg      echo "case some other package contains this missing '$1' program."
1985eeb4e8fSmrg      ;;
1995eeb4e8fSmrg  esac
2005eeb4e8fSmrg}
2015eeb4e8fSmrg
2025eeb4e8fSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2035eeb4e8fSmrg                       -e '2,$s/^/         /' >&2
2045eeb4e8fSmrg
2055eeb4e8fSmrg# Propagate the correct exit status (expected to be 127 for a program
2065eeb4e8fSmrg# not found, 63 for a program that failed due to version mismatch).
2075eeb4e8fSmrgexit $st
208972599cfSmrg
209972599cfSmrg# Local variables:
210972599cfSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
211972599cfSmrg# time-stamp-start: "scriptversion="
212972599cfSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213972599cfSmrg# time-stamp-time-zone: "UTC"
214972599cfSmrg# time-stamp-end: "; # UTC"
215972599cfSmrg# End:
216