missing revision 5dd5f640
1e9554658Smrg#! /bin/sh
25dd5f640Smrg# Common wrapper for a few potentially missing GNU programs.
3e9554658Smrg
45dd5f640Smrgscriptversion=2012-06-26.16; # UTC
5e9554658Smrg
65dd5f640Smrg# Copyright (C) 1996-2013 Free Software Foundation, Inc.
75dd5f640Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8e9554658Smrg
9e9554658Smrg# This program is free software; you can redistribute it and/or modify
10e9554658Smrg# it under the terms of the GNU General Public License as published by
11e9554658Smrg# the Free Software Foundation; either version 2, or (at your option)
12e9554658Smrg# any later version.
13e9554658Smrg
14e9554658Smrg# This program is distributed in the hope that it will be useful,
15e9554658Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16e9554658Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17e9554658Smrg# GNU General Public License for more details.
18e9554658Smrg
19e9554658Smrg# You should have received a copy of the GNU General Public License
20c2b339b4Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21e9554658Smrg
22e9554658Smrg# As a special exception to the GNU General Public License, if you
23e9554658Smrg# distribute this file as part of a program that contains a
24e9554658Smrg# configuration script generated by Autoconf, you may include it under
25e9554658Smrg# the same distribution terms that you use for the rest of that program.
26e9554658Smrg
27e9554658Smrgif test $# -eq 0; then
285dd5f640Smrg  echo 1>&2 "Try '$0 --help' for more information"
29e9554658Smrg  exit 1
30e9554658Smrgfi
31e9554658Smrg
325dd5f640Smrgcase $1 in
33e9554658Smrg
345dd5f640Smrg  --is-lightweight)
355dd5f640Smrg    # Used by our autoconf macros to check whether the available missing
365dd5f640Smrg    # script is modern enough.
375dd5f640Smrg    exit 0
385dd5f640Smrg    ;;
39e9554658Smrg
405dd5f640Smrg  --run)
415dd5f640Smrg    # Back-compat with the calling convention used by older automake.
425dd5f640Smrg    shift
435dd5f640Smrg    ;;
44e9554658Smrg
45e9554658Smrg  -h|--h|--he|--hel|--help)
46e9554658Smrg    echo "\
47e9554658Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
48e9554658Smrg
495dd5f640SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
505dd5f640Smrgto PROGRAM being missing or too old.
51e9554658Smrg
52e9554658SmrgOptions:
53e9554658Smrg  -h, --help      display this help and exit
54e9554658Smrg  -v, --version   output version information and exit
55e9554658Smrg
56e9554658SmrgSupported PROGRAM values:
575dd5f640Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
585dd5f640Smrg  bison     yacc      flex         lex       help2man
59e9554658Smrg
605dd5f640SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
615dd5f640Smrg'g' are ignored when checking the name.
62c2b339b4Smrg
63e9554658SmrgSend bug reports to <bug-automake@gnu.org>."
64e9554658Smrg    exit $?
65e9554658Smrg    ;;
66e9554658Smrg
67e9554658Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
68e9554658Smrg    echo "missing $scriptversion (GNU Automake)"
69e9554658Smrg    exit $?
70e9554658Smrg    ;;
71e9554658Smrg
72e9554658Smrg  -*)
735dd5f640Smrg    echo 1>&2 "$0: unknown '$1' option"
745dd5f640Smrg    echo 1>&2 "Try '$0 --help' for more information"
75e9554658Smrg    exit 1
76e9554658Smrg    ;;
77e9554658Smrg
78e9554658Smrgesac
79e9554658Smrg
805dd5f640Smrg# Run the given program, remember its exit status.
815dd5f640Smrg"$@"; st=$?
825dd5f640Smrg
835dd5f640Smrg# If it succeeded, we are done.
845dd5f640Smrgtest $st -eq 0 && exit 0
855dd5f640Smrg
865dd5f640Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
875dd5f640Smrg# passed; such an option is passed most likely to detect whether the
885dd5f640Smrg# program is present and works.
895dd5f640Smrgcase $2 in --version|--help) exit $st;; esac
905dd5f640Smrg
915dd5f640Smrg# Exit code 63 means version mismatch.  This often happens when the user
925dd5f640Smrg# tries to use an ancient version of a tool on a file that requires a
935dd5f640Smrg# minimum version.
945dd5f640Smrgif test $st -eq 63; then
955dd5f640Smrg  msg="probably too old"
965dd5f640Smrgelif test $st -eq 127; then
975dd5f640Smrg  # Program was missing.
985dd5f640Smrg  msg="missing on your system"
995dd5f640Smrgelse
1005dd5f640Smrg  # Program was found and executed, but failed.  Give up.
1015dd5f640Smrg  exit $st
1025dd5f640Smrgfi
103e9554658Smrg
1045dd5f640Smrgperl_URL=http://www.perl.org/
1055dd5f640Smrgflex_URL=http://flex.sourceforge.net/
1065dd5f640Smrggnu_software_URL=http://www.gnu.org/software
1075dd5f640Smrg
1085dd5f640Smrgprogram_details ()
1095dd5f640Smrg{
1105dd5f640Smrg  case $1 in
1115dd5f640Smrg    aclocal|automake)
1125dd5f640Smrg      echo "The '$1' program is part of the GNU Automake package:"
1135dd5f640Smrg      echo "<$gnu_software_URL/automake>"
1145dd5f640Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1155dd5f640Smrg      echo "<$gnu_software_URL/autoconf>"
1165dd5f640Smrg      echo "<$gnu_software_URL/m4/>"
1175dd5f640Smrg      echo "<$perl_URL>"
1185dd5f640Smrg      ;;
1195dd5f640Smrg    autoconf|autom4te|autoheader)
1205dd5f640Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
1215dd5f640Smrg      echo "<$gnu_software_URL/autoconf/>"
1225dd5f640Smrg      echo "It also requires GNU m4 and Perl in order to run:"
1235dd5f640Smrg      echo "<$gnu_software_URL/m4/>"
1245dd5f640Smrg      echo "<$perl_URL>"
1255dd5f640Smrg      ;;
1265dd5f640Smrg  esac
1275dd5f640Smrg}
1285dd5f640Smrg
1295dd5f640Smrggive_advice ()
1305dd5f640Smrg{
1315dd5f640Smrg  # Normalize program name to check for.
1325dd5f640Smrg  normalized_program=`echo "$1" | sed '
1335dd5f640Smrg    s/^gnu-//; t
1345dd5f640Smrg    s/^gnu//; t
1355dd5f640Smrg    s/^g//; t'`
1365dd5f640Smrg
1375dd5f640Smrg  printf '%s\n' "'$1' is $msg."
1385dd5f640Smrg
1395dd5f640Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1405dd5f640Smrg  case $normalized_program in
1415dd5f640Smrg    autoconf*)
1425dd5f640Smrg      echo "You should only need it if you modified 'configure.ac',"
1435dd5f640Smrg      echo "or m4 files included by it."
1445dd5f640Smrg      program_details 'autoconf'
1455dd5f640Smrg      ;;
1465dd5f640Smrg    autoheader*)
1475dd5f640Smrg      echo "You should only need it if you modified 'acconfig.h' or"
1485dd5f640Smrg      echo "$configure_deps."
1495dd5f640Smrg      program_details 'autoheader'
1505dd5f640Smrg      ;;
1515dd5f640Smrg    automake*)
1525dd5f640Smrg      echo "You should only need it if you modified 'Makefile.am' or"
1535dd5f640Smrg      echo "$configure_deps."
1545dd5f640Smrg      program_details 'automake'
1555dd5f640Smrg      ;;
1565dd5f640Smrg    aclocal*)
1575dd5f640Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
1585dd5f640Smrg      echo "$configure_deps."
1595dd5f640Smrg      program_details 'aclocal'
1605dd5f640Smrg      ;;
1615dd5f640Smrg   autom4te*)
1625dd5f640Smrg      echo "You might have modified some maintainer files that require"
1635dd5f640Smrg      echo "the 'automa4te' program to be rebuilt."
1645dd5f640Smrg      program_details 'autom4te'
1655dd5f640Smrg      ;;
1665dd5f640Smrg    bison*|yacc*)
1675dd5f640Smrg      echo "You should only need it if you modified a '.y' file."
1685dd5f640Smrg      echo "You may want to install the GNU Bison package:"
1695dd5f640Smrg      echo "<$gnu_software_URL/bison/>"
1705dd5f640Smrg      ;;
1715dd5f640Smrg    lex*|flex*)
1725dd5f640Smrg      echo "You should only need it if you modified a '.l' file."
1735dd5f640Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
1745dd5f640Smrg      echo "<$flex_URL>"
1755dd5f640Smrg      ;;
1765dd5f640Smrg    help2man*)
1775dd5f640Smrg      echo "You should only need it if you modified a dependency" \
1785dd5f640Smrg           "of a man page."
1795dd5f640Smrg      echo "You may want to install the GNU Help2man package:"
1805dd5f640Smrg      echo "<$gnu_software_URL/help2man/>"
1815dd5f640Smrg    ;;
1825dd5f640Smrg    makeinfo*)
1835dd5f640Smrg      echo "You should only need it if you modified a '.texi' file, or"
1845dd5f640Smrg      echo "any other file indirectly affecting the aspect of the manual."
1855dd5f640Smrg      echo "You might want to install the Texinfo package:"
1865dd5f640Smrg      echo "<$gnu_software_URL/texinfo/>"
1875dd5f640Smrg      echo "The spurious makeinfo call might also be the consequence of"
1885dd5f640Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1895dd5f640Smrg      echo "want to install GNU make:"
1905dd5f640Smrg      echo "<$gnu_software_URL/make/>"
1915dd5f640Smrg      ;;
1925dd5f640Smrg    *)
1935dd5f640Smrg      echo "You might have modified some files without having the proper"
1945dd5f640Smrg      echo "tools for further handling them.  Check the 'README' file, it"
1955dd5f640Smrg      echo "often tells you about the needed prerequisites for installing"
1965dd5f640Smrg      echo "this package.  You may also peek at any GNU archive site, in"
1975dd5f640Smrg      echo "case some other package contains this missing '$1' program."
1985dd5f640Smrg      ;;
1995dd5f640Smrg  esac
2005dd5f640Smrg}
2015dd5f640Smrg
2025dd5f640Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2035dd5f640Smrg                       -e '2,$s/^/         /' >&2
2045dd5f640Smrg
2055dd5f640Smrg# Propagate the correct exit status (expected to be 127 for a program
2065dd5f640Smrg# not found, 63 for a program that failed due to version mismatch).
2075dd5f640Smrgexit $st
208e9554658Smrg
209e9554658Smrg# Local variables:
210e9554658Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
211e9554658Smrg# time-stamp-start: "scriptversion="
212e9554658Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213c2b339b4Smrg# time-stamp-time-zone: "UTC"
214c2b339b4Smrg# time-stamp-end: "; # UTC"
215e9554658Smrg# End:
216