missing revision 95fdd44c
164ce7165Smrg#! /bin/sh
281440437Smrg# Common wrapper for a few potentially missing GNU programs.
364ce7165Smrg
495fdd44cSmrgscriptversion=2013-10-28.13; # UTC
564ce7165Smrg
695fdd44cSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
781440437Smrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
864ce7165Smrg
964ce7165Smrg# This program is free software; you can redistribute it and/or modify
1064ce7165Smrg# it under the terms of the GNU General Public License as published by
1164ce7165Smrg# the Free Software Foundation; either version 2, or (at your option)
1264ce7165Smrg# any later version.
1364ce7165Smrg
1464ce7165Smrg# This program is distributed in the hope that it will be useful,
1564ce7165Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1664ce7165Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1764ce7165Smrg# GNU General Public License for more details.
1864ce7165Smrg
1964ce7165Smrg# You should have received a copy of the GNU General Public License
20fb23d3a8Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2164ce7165Smrg
2264ce7165Smrg# As a special exception to the GNU General Public License, if you
2364ce7165Smrg# distribute this file as part of a program that contains a
2464ce7165Smrg# configuration script generated by Autoconf, you may include it under
2564ce7165Smrg# the same distribution terms that you use for the rest of that program.
2664ce7165Smrg
2764ce7165Smrgif test $# -eq 0; then
2881440437Smrg  echo 1>&2 "Try '$0 --help' for more information"
2964ce7165Smrg  exit 1
3064ce7165Smrgfi
3164ce7165Smrg
3281440437Smrgcase $1 in
3364ce7165Smrg
3481440437Smrg  --is-lightweight)
3581440437Smrg    # Used by our autoconf macros to check whether the available missing
3681440437Smrg    # script is modern enough.
3781440437Smrg    exit 0
3881440437Smrg    ;;
3964ce7165Smrg
4081440437Smrg  --run)
4181440437Smrg    # Back-compat with the calling convention used by older automake.
4281440437Smrg    shift
4381440437Smrg    ;;
4464ce7165Smrg
4564ce7165Smrg  -h|--h|--he|--hel|--help)
4664ce7165Smrg    echo "\
4764ce7165Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4864ce7165Smrg
4981440437SmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
5081440437Smrgto PROGRAM being missing or too old.
5164ce7165Smrg
5264ce7165SmrgOptions:
5364ce7165Smrg  -h, --help      display this help and exit
5464ce7165Smrg  -v, --version   output version information and exit
5564ce7165Smrg
5664ce7165SmrgSupported PROGRAM values:
5781440437Smrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
5881440437Smrg  bison     yacc      flex         lex       help2man
5964ce7165Smrg
6081440437SmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
6181440437Smrg'g' are ignored when checking the name.
62fb23d3a8Smrg
6364ce7165SmrgSend bug reports to <bug-automake@gnu.org>."
6464ce7165Smrg    exit $?
6564ce7165Smrg    ;;
6664ce7165Smrg
6764ce7165Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6864ce7165Smrg    echo "missing $scriptversion (GNU Automake)"
6964ce7165Smrg    exit $?
7064ce7165Smrg    ;;
7164ce7165Smrg
7264ce7165Smrg  -*)
7381440437Smrg    echo 1>&2 "$0: unknown '$1' option"
7481440437Smrg    echo 1>&2 "Try '$0 --help' for more information"
7564ce7165Smrg    exit 1
7664ce7165Smrg    ;;
7764ce7165Smrg
7864ce7165Smrgesac
7964ce7165Smrg
8081440437Smrg# Run the given program, remember its exit status.
8181440437Smrg"$@"; st=$?
8281440437Smrg
8381440437Smrg# If it succeeded, we are done.
8481440437Smrgtest $st -eq 0 && exit 0
8581440437Smrg
8681440437Smrg# Also exit now if we it failed (or wasn't found), and '--version' was
8781440437Smrg# passed; such an option is passed most likely to detect whether the
8881440437Smrg# program is present and works.
8981440437Smrgcase $2 in --version|--help) exit $st;; esac
9081440437Smrg
9181440437Smrg# Exit code 63 means version mismatch.  This often happens when the user
9281440437Smrg# tries to use an ancient version of a tool on a file that requires a
9381440437Smrg# minimum version.
9481440437Smrgif test $st -eq 63; then
9581440437Smrg  msg="probably too old"
9681440437Smrgelif test $st -eq 127; then
9781440437Smrg  # Program was missing.
9881440437Smrg  msg="missing on your system"
9981440437Smrgelse
10081440437Smrg  # Program was found and executed, but failed.  Give up.
10181440437Smrg  exit $st
10281440437Smrgfi
10364ce7165Smrg
10481440437Smrgperl_URL=http://www.perl.org/
10581440437Smrgflex_URL=http://flex.sourceforge.net/
10681440437Smrggnu_software_URL=http://www.gnu.org/software
10781440437Smrg
10881440437Smrgprogram_details ()
10981440437Smrg{
11081440437Smrg  case $1 in
11181440437Smrg    aclocal|automake)
11281440437Smrg      echo "The '$1' program is part of the GNU Automake package:"
11381440437Smrg      echo "<$gnu_software_URL/automake>"
11481440437Smrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
11581440437Smrg      echo "<$gnu_software_URL/autoconf>"
11681440437Smrg      echo "<$gnu_software_URL/m4/>"
11781440437Smrg      echo "<$perl_URL>"
11881440437Smrg      ;;
11981440437Smrg    autoconf|autom4te|autoheader)
12081440437Smrg      echo "The '$1' program is part of the GNU Autoconf package:"
12181440437Smrg      echo "<$gnu_software_URL/autoconf/>"
12281440437Smrg      echo "It also requires GNU m4 and Perl in order to run:"
12381440437Smrg      echo "<$gnu_software_URL/m4/>"
12481440437Smrg      echo "<$perl_URL>"
12581440437Smrg      ;;
12681440437Smrg  esac
12781440437Smrg}
12881440437Smrg
12981440437Smrggive_advice ()
13081440437Smrg{
13181440437Smrg  # Normalize program name to check for.
13281440437Smrg  normalized_program=`echo "$1" | sed '
13381440437Smrg    s/^gnu-//; t
13481440437Smrg    s/^gnu//; t
13581440437Smrg    s/^g//; t'`
13681440437Smrg
13781440437Smrg  printf '%s\n' "'$1' is $msg."
13881440437Smrg
13981440437Smrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
14081440437Smrg  case $normalized_program in
14181440437Smrg    autoconf*)
14281440437Smrg      echo "You should only need it if you modified 'configure.ac',"
14381440437Smrg      echo "or m4 files included by it."
14481440437Smrg      program_details 'autoconf'
14581440437Smrg      ;;
14681440437Smrg    autoheader*)
14781440437Smrg      echo "You should only need it if you modified 'acconfig.h' or"
14881440437Smrg      echo "$configure_deps."
14981440437Smrg      program_details 'autoheader'
15081440437Smrg      ;;
15181440437Smrg    automake*)
15281440437Smrg      echo "You should only need it if you modified 'Makefile.am' or"
15381440437Smrg      echo "$configure_deps."
15481440437Smrg      program_details 'automake'
15581440437Smrg      ;;
15681440437Smrg    aclocal*)
15781440437Smrg      echo "You should only need it if you modified 'acinclude.m4' or"
15881440437Smrg      echo "$configure_deps."
15981440437Smrg      program_details 'aclocal'
16081440437Smrg      ;;
16181440437Smrg   autom4te*)
16281440437Smrg      echo "You might have modified some maintainer files that require"
16395fdd44cSmrg      echo "the 'autom4te' program to be rebuilt."
16481440437Smrg      program_details 'autom4te'
16581440437Smrg      ;;
16681440437Smrg    bison*|yacc*)
16781440437Smrg      echo "You should only need it if you modified a '.y' file."
16881440437Smrg      echo "You may want to install the GNU Bison package:"
16981440437Smrg      echo "<$gnu_software_URL/bison/>"
17081440437Smrg      ;;
17181440437Smrg    lex*|flex*)
17281440437Smrg      echo "You should only need it if you modified a '.l' file."
17381440437Smrg      echo "You may want to install the Fast Lexical Analyzer package:"
17481440437Smrg      echo "<$flex_URL>"
17581440437Smrg      ;;
17681440437Smrg    help2man*)
17781440437Smrg      echo "You should only need it if you modified a dependency" \
17881440437Smrg           "of a man page."
17981440437Smrg      echo "You may want to install the GNU Help2man package:"
18081440437Smrg      echo "<$gnu_software_URL/help2man/>"
18181440437Smrg    ;;
18281440437Smrg    makeinfo*)
18381440437Smrg      echo "You should only need it if you modified a '.texi' file, or"
18481440437Smrg      echo "any other file indirectly affecting the aspect of the manual."
18581440437Smrg      echo "You might want to install the Texinfo package:"
18681440437Smrg      echo "<$gnu_software_URL/texinfo/>"
18781440437Smrg      echo "The spurious makeinfo call might also be the consequence of"
18881440437Smrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
18981440437Smrg      echo "want to install GNU make:"
19081440437Smrg      echo "<$gnu_software_URL/make/>"
19181440437Smrg      ;;
19281440437Smrg    *)
19381440437Smrg      echo "You might have modified some files without having the proper"
19481440437Smrg      echo "tools for further handling them.  Check the 'README' file, it"
19581440437Smrg      echo "often tells you about the needed prerequisites for installing"
19681440437Smrg      echo "this package.  You may also peek at any GNU archive site, in"
19781440437Smrg      echo "case some other package contains this missing '$1' program."
19881440437Smrg      ;;
19981440437Smrg  esac
20081440437Smrg}
20181440437Smrg
20281440437Smrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
20381440437Smrg                       -e '2,$s/^/         /' >&2
20481440437Smrg
20581440437Smrg# Propagate the correct exit status (expected to be 127 for a program
20681440437Smrg# not found, 63 for a program that failed due to version mismatch).
20781440437Smrgexit $st
20864ce7165Smrg
20964ce7165Smrg# Local variables:
21064ce7165Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
21164ce7165Smrg# time-stamp-start: "scriptversion="
21264ce7165Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213fb23d3a8Smrg# time-stamp-time-zone: "UTC"
214fb23d3a8Smrg# time-stamp-end: "; # UTC"
21564ce7165Smrg# End:
216