172b676d7Smrg#! /bin/sh
293d9adc1Smrg# Common wrapper for a few potentially missing GNU programs.
372b676d7Smrg
493d9adc1Smrgscriptversion=2013-10-28.13; # UTC
572b676d7Smrg
693d9adc1Smrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
793d9adc1Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
872b676d7Smrg
972b676d7Smrg# This program is free software; you can redistribute it and/or modify
1072b676d7Smrg# it under the terms of the GNU General Public License as published by
1172b676d7Smrg# the Free Software Foundation; either version 2, or (at your option)
1272b676d7Smrg# any later version.
1372b676d7Smrg
1472b676d7Smrg# This program is distributed in the hope that it will be useful,
1572b676d7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1672b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1772b676d7Smrg# GNU General Public License for more details.
1872b676d7Smrg
1972b676d7Smrg# You should have received a copy of the GNU General Public License
2074c14cd6Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2172b676d7Smrg
2272b676d7Smrg# As a special exception to the GNU General Public License, if you
2372b676d7Smrg# distribute this file as part of a program that contains a
2472b676d7Smrg# configuration script generated by Autoconf, you may include it under
2572b676d7Smrg# the same distribution terms that you use for the rest of that program.
2672b676d7Smrg
2772b676d7Smrgif test $# -eq 0; then
2893d9adc1Smrg  echo 1>&2 "Try '$0 --help' for more information"
2972b676d7Smrg  exit 1
3072b676d7Smrgfi
3172b676d7Smrg
3293d9adc1Smrgcase $1 in
3372b676d7Smrg
3493d9adc1Smrg  --is-lightweight)
3593d9adc1Smrg    # Used by our autoconf macros to check whether the available missing
3693d9adc1Smrg    # script is modern enough.
3793d9adc1Smrg    exit 0
3893d9adc1Smrg    ;;
3972b676d7Smrg
4093d9adc1Smrg  --run)
4193d9adc1Smrg    # Back-compat with the calling convention used by older automake.
4293d9adc1Smrg    shift
4393d9adc1Smrg    ;;
4472b676d7Smrg
4572b676d7Smrg  -h|--h|--he|--hel|--help)
4672b676d7Smrg    echo "\
4772b676d7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4872b676d7Smrg
4993d9adc1SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5093d9adc1Smrgto PROGRAM being missing or too old.
5172b676d7Smrg
5272b676d7SmrgOptions:
5372b676d7Smrg  -h, --help      display this help and exit
5472b676d7Smrg  -v, --version   output version information and exit
5572b676d7Smrg
5672b676d7SmrgSupported PROGRAM values:
5793d9adc1Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5893d9adc1Smrg  bison     yacc      flex         lex       help2man
5972b676d7Smrg
6093d9adc1SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6193d9adc1Smrg'g' are ignored when checking the name.
6274c14cd6Smrg
6372b676d7SmrgSend bug reports to <bug-automake@gnu.org>."
6472b676d7Smrg    exit $?
6572b676d7Smrg    ;;
6672b676d7Smrg
6772b676d7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6872b676d7Smrg    echo "missing $scriptversion (GNU Automake)"
6972b676d7Smrg    exit $?
7072b676d7Smrg    ;;
7172b676d7Smrg
7272b676d7Smrg  -*)
7393d9adc1Smrg    echo 1>&2 "$0: unknown '$1' option"
7493d9adc1Smrg    echo 1>&2 "Try '$0 --help' for more information"
7572b676d7Smrg    exit 1
7672b676d7Smrg    ;;
7772b676d7Smrg
7872b676d7Smrgesac
7972b676d7Smrg
8093d9adc1Smrg# Run the given program, remember its exit status.
8193d9adc1Smrg"$@"; st=$?
8293d9adc1Smrg
8393d9adc1Smrg# If it succeeded, we are done.
8493d9adc1Smrgtest $st -eq 0 && exit 0
8593d9adc1Smrg
8693d9adc1Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
8793d9adc1Smrg# passed; such an option is passed most likely to detect whether the
8893d9adc1Smrg# program is present and works.
8993d9adc1Smrgcase $2 in --version|--help) exit $st;; esac
9093d9adc1Smrg
9193d9adc1Smrg# Exit code 63 means version mismatch.  This often happens when the user
9293d9adc1Smrg# tries to use an ancient version of a tool on a file that requires a
9393d9adc1Smrg# minimum version.
9493d9adc1Smrgif test $st -eq 63; then
9593d9adc1Smrg  msg="probably too old"
9693d9adc1Smrgelif test $st -eq 127; then
9793d9adc1Smrg  # Program was missing.
9893d9adc1Smrg  msg="missing on your system"
9993d9adc1Smrgelse
10093d9adc1Smrg  # Program was found and executed, but failed.  Give up.
10193d9adc1Smrg  exit $st
10293d9adc1Smrgfi
10372b676d7Smrg
10493d9adc1Smrgperl_URL=http://www.perl.org/
10593d9adc1Smrgflex_URL=http://flex.sourceforge.net/
10693d9adc1Smrggnu_software_URL=http://www.gnu.org/software
10793d9adc1Smrg
10893d9adc1Smrgprogram_details ()
10993d9adc1Smrg{
11093d9adc1Smrg  case $1 in
11193d9adc1Smrg    aclocal|automake)
11293d9adc1Smrg      echo "The '$1' program is part of the GNU Automake package:"
11393d9adc1Smrg      echo "<$gnu_software_URL/automake>"
11493d9adc1Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11593d9adc1Smrg      echo "<$gnu_software_URL/autoconf>"
11693d9adc1Smrg      echo "<$gnu_software_URL/m4/>"
11793d9adc1Smrg      echo "<$perl_URL>"
11893d9adc1Smrg      ;;
11993d9adc1Smrg    autoconf|autom4te|autoheader)
12093d9adc1Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
12193d9adc1Smrg      echo "<$gnu_software_URL/autoconf/>"
12293d9adc1Smrg      echo "It also requires GNU m4 and Perl in order to run:"
12393d9adc1Smrg      echo "<$gnu_software_URL/m4/>"
12493d9adc1Smrg      echo "<$perl_URL>"
12593d9adc1Smrg      ;;
12693d9adc1Smrg  esac
12793d9adc1Smrg}
12893d9adc1Smrg
12993d9adc1Smrggive_advice ()
13093d9adc1Smrg{
13193d9adc1Smrg  # Normalize program name to check for.
13293d9adc1Smrg  normalized_program=`echo "$1" | sed '
13393d9adc1Smrg    s/^gnu-//; t
13493d9adc1Smrg    s/^gnu//; t
13593d9adc1Smrg    s/^g//; t'`
13693d9adc1Smrg
13793d9adc1Smrg  printf '%s\n' "'$1' is $msg."
13893d9adc1Smrg
13993d9adc1Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14093d9adc1Smrg  case $normalized_program in
14193d9adc1Smrg    autoconf*)
14293d9adc1Smrg      echo "You should only need it if you modified 'configure.ac',"
14393d9adc1Smrg      echo "or m4 files included by it."
14493d9adc1Smrg      program_details 'autoconf'
14593d9adc1Smrg      ;;
14693d9adc1Smrg    autoheader*)
14793d9adc1Smrg      echo "You should only need it if you modified 'acconfig.h' or"
14893d9adc1Smrg      echo "$configure_deps."
14993d9adc1Smrg      program_details 'autoheader'
15093d9adc1Smrg      ;;
15193d9adc1Smrg    automake*)
15293d9adc1Smrg      echo "You should only need it if you modified 'Makefile.am' or"
15393d9adc1Smrg      echo "$configure_deps."
15493d9adc1Smrg      program_details 'automake'
15593d9adc1Smrg      ;;
15693d9adc1Smrg    aclocal*)
15793d9adc1Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
15893d9adc1Smrg      echo "$configure_deps."
15993d9adc1Smrg      program_details 'aclocal'
16093d9adc1Smrg      ;;
16193d9adc1Smrg   autom4te*)
16293d9adc1Smrg      echo "You might have modified some maintainer files that require"
16393d9adc1Smrg      echo "the 'autom4te' program to be rebuilt."
16493d9adc1Smrg      program_details 'autom4te'
16593d9adc1Smrg      ;;
16693d9adc1Smrg    bison*|yacc*)
16793d9adc1Smrg      echo "You should only need it if you modified a '.y' file."
16893d9adc1Smrg      echo "You may want to install the GNU Bison package:"
16993d9adc1Smrg      echo "<$gnu_software_URL/bison/>"
17093d9adc1Smrg      ;;
17193d9adc1Smrg    lex*|flex*)
17293d9adc1Smrg      echo "You should only need it if you modified a '.l' file."
17393d9adc1Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
17493d9adc1Smrg      echo "<$flex_URL>"
17593d9adc1Smrg      ;;
17693d9adc1Smrg    help2man*)
17793d9adc1Smrg      echo "You should only need it if you modified a dependency" \
17893d9adc1Smrg           "of a man page."
17993d9adc1Smrg      echo "You may want to install the GNU Help2man package:"
18093d9adc1Smrg      echo "<$gnu_software_URL/help2man/>"
18193d9adc1Smrg    ;;
18293d9adc1Smrg    makeinfo*)
18393d9adc1Smrg      echo "You should only need it if you modified a '.texi' file, or"
18493d9adc1Smrg      echo "any other file indirectly affecting the aspect of the manual."
18593d9adc1Smrg      echo "You might want to install the Texinfo package:"
18693d9adc1Smrg      echo "<$gnu_software_URL/texinfo/>"
18793d9adc1Smrg      echo "The spurious makeinfo call might also be the consequence of"
18893d9adc1Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18993d9adc1Smrg      echo "want to install GNU make:"
19093d9adc1Smrg      echo "<$gnu_software_URL/make/>"
19193d9adc1Smrg      ;;
19293d9adc1Smrg    *)
19393d9adc1Smrg      echo "You might have modified some files without having the proper"
19493d9adc1Smrg      echo "tools for further handling them.  Check the 'README' file, it"
19593d9adc1Smrg      echo "often tells you about the needed prerequisites for installing"
19693d9adc1Smrg      echo "this package.  You may also peek at any GNU archive site, in"
19793d9adc1Smrg      echo "case some other package contains this missing '$1' program."
19893d9adc1Smrg      ;;
19993d9adc1Smrg  esac
20093d9adc1Smrg}
20193d9adc1Smrg
20293d9adc1Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20393d9adc1Smrg                       -e '2,$s/^/         /' >&2
20493d9adc1Smrg
20593d9adc1Smrg# Propagate the correct exit status (expected to be 127 for a program
20693d9adc1Smrg# not found, 63 for a program that failed due to version mismatch).
20793d9adc1Smrgexit $st
20872b676d7Smrg
20972b676d7Smrg# Local variables:
21072b676d7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
21172b676d7Smrg# time-stamp-start: "scriptversion="
21272b676d7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
21374c14cd6Smrg# time-stamp-time-zone: "UTC"
21474c14cd6Smrg# time-stamp-end: "; # UTC"
21572b676d7Smrg# End:
216