12007c8b2Snia#! /bin/sh
22007c8b2Snia# Common wrapper for a few potentially missing GNU programs.
32007c8b2Snia
42007c8b2Sniascriptversion=2013-10-28.13; # UTC
52007c8b2Snia
62007c8b2Snia# Copyright (C) 1996-2014 Free Software Foundation, Inc.
72007c8b2Snia# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
82007c8b2Snia
92007c8b2Snia# This program is free software; you can redistribute it and/or modify
102007c8b2Snia# it under the terms of the GNU General Public License as published by
112007c8b2Snia# the Free Software Foundation; either version 2, or (at your option)
122007c8b2Snia# any later version.
132007c8b2Snia
142007c8b2Snia# This program is distributed in the hope that it will be useful,
152007c8b2Snia# but WITHOUT ANY WARRANTY; without even the implied warranty of
162007c8b2Snia# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
172007c8b2Snia# GNU General Public License for more details.
182007c8b2Snia
192007c8b2Snia# You should have received a copy of the GNU General Public License
202007c8b2Snia# along with this program.  If not, see <http://www.gnu.org/licenses/>.
212007c8b2Snia
222007c8b2Snia# As a special exception to the GNU General Public License, if you
232007c8b2Snia# distribute this file as part of a program that contains a
242007c8b2Snia# configuration script generated by Autoconf, you may include it under
252007c8b2Snia# the same distribution terms that you use for the rest of that program.
262007c8b2Snia
272007c8b2Sniaif test $# -eq 0; then
282007c8b2Snia  echo 1>&2 "Try '$0 --help' for more information"
292007c8b2Snia  exit 1
302007c8b2Sniafi
312007c8b2Snia
322007c8b2Sniacase $1 in
332007c8b2Snia
342007c8b2Snia  --is-lightweight)
352007c8b2Snia    # Used by our autoconf macros to check whether the available missing
362007c8b2Snia    # script is modern enough.
372007c8b2Snia    exit 0
382007c8b2Snia    ;;
392007c8b2Snia
402007c8b2Snia  --run)
412007c8b2Snia    # Back-compat with the calling convention used by older automake.
422007c8b2Snia    shift
432007c8b2Snia    ;;
442007c8b2Snia
452007c8b2Snia  -h|--h|--he|--hel|--help)
462007c8b2Snia    echo "\
472007c8b2Snia$0 [OPTION]... PROGRAM [ARGUMENT]...
482007c8b2Snia
492007c8b2SniaRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
502007c8b2Sniato PROGRAM being missing or too old.
512007c8b2Snia
522007c8b2SniaOptions:
532007c8b2Snia  -h, --help      display this help and exit
542007c8b2Snia  -v, --version   output version information and exit
552007c8b2Snia
562007c8b2SniaSupported PROGRAM values:
572007c8b2Snia  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
582007c8b2Snia  bison     yacc      flex         lex       help2man
592007c8b2Snia
602007c8b2SniaVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
612007c8b2Snia'g' are ignored when checking the name.
622007c8b2Snia
632007c8b2SniaSend bug reports to <bug-automake@gnu.org>."
642007c8b2Snia    exit $?
652007c8b2Snia    ;;
662007c8b2Snia
672007c8b2Snia  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
682007c8b2Snia    echo "missing $scriptversion (GNU Automake)"
692007c8b2Snia    exit $?
702007c8b2Snia    ;;
712007c8b2Snia
722007c8b2Snia  -*)
732007c8b2Snia    echo 1>&2 "$0: unknown '$1' option"
742007c8b2Snia    echo 1>&2 "Try '$0 --help' for more information"
752007c8b2Snia    exit 1
762007c8b2Snia    ;;
772007c8b2Snia
782007c8b2Sniaesac
792007c8b2Snia
802007c8b2Snia# Run the given program, remember its exit status.
812007c8b2Snia"$@"; st=$?
822007c8b2Snia
832007c8b2Snia# If it succeeded, we are done.
842007c8b2Sniatest $st -eq 0 && exit 0
852007c8b2Snia
862007c8b2Snia# Also exit now if we it failed (or wasn't found), and '--version' was
872007c8b2Snia# passed; such an option is passed most likely to detect whether the
882007c8b2Snia# program is present and works.
892007c8b2Sniacase $2 in --version|--help) exit $st;; esac
902007c8b2Snia
912007c8b2Snia# Exit code 63 means version mismatch.  This often happens when the user
922007c8b2Snia# tries to use an ancient version of a tool on a file that requires a
932007c8b2Snia# minimum version.
942007c8b2Sniaif test $st -eq 63; then
952007c8b2Snia  msg="probably too old"
962007c8b2Sniaelif test $st -eq 127; then
972007c8b2Snia  # Program was missing.
982007c8b2Snia  msg="missing on your system"
992007c8b2Sniaelse
1002007c8b2Snia  # Program was found and executed, but failed.  Give up.
1012007c8b2Snia  exit $st
1022007c8b2Sniafi
1032007c8b2Snia
1042007c8b2Sniaperl_URL=http://www.perl.org/
1052007c8b2Sniaflex_URL=http://flex.sourceforge.net/
1062007c8b2Sniagnu_software_URL=http://www.gnu.org/software
1072007c8b2Snia
1082007c8b2Sniaprogram_details ()
1092007c8b2Snia{
1102007c8b2Snia  case $1 in
1112007c8b2Snia    aclocal|automake)
1122007c8b2Snia      echo "The '$1' program is part of the GNU Automake package:"
1132007c8b2Snia      echo "<$gnu_software_URL/automake>"
1142007c8b2Snia      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1152007c8b2Snia      echo "<$gnu_software_URL/autoconf>"
1162007c8b2Snia      echo "<$gnu_software_URL/m4/>"
1172007c8b2Snia      echo "<$perl_URL>"
1182007c8b2Snia      ;;
1192007c8b2Snia    autoconf|autom4te|autoheader)
1202007c8b2Snia      echo "The '$1' program is part of the GNU Autoconf package:"
1212007c8b2Snia      echo "<$gnu_software_URL/autoconf/>"
1222007c8b2Snia      echo "It also requires GNU m4 and Perl in order to run:"
1232007c8b2Snia      echo "<$gnu_software_URL/m4/>"
1242007c8b2Snia      echo "<$perl_URL>"
1252007c8b2Snia      ;;
1262007c8b2Snia  esac
1272007c8b2Snia}
1282007c8b2Snia
1292007c8b2Sniagive_advice ()
1302007c8b2Snia{
1312007c8b2Snia  # Normalize program name to check for.
1322007c8b2Snia  normalized_program=`echo "$1" | sed '
1332007c8b2Snia    s/^gnu-//; t
1342007c8b2Snia    s/^gnu//; t
1352007c8b2Snia    s/^g//; t'`
1362007c8b2Snia
1372007c8b2Snia  printf '%s\n' "'$1' is $msg."
1382007c8b2Snia
1392007c8b2Snia  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1402007c8b2Snia  case $normalized_program in
1412007c8b2Snia    autoconf*)
1422007c8b2Snia      echo "You should only need it if you modified 'configure.ac',"
1432007c8b2Snia      echo "or m4 files included by it."
1442007c8b2Snia      program_details 'autoconf'
1452007c8b2Snia      ;;
1462007c8b2Snia    autoheader*)
1472007c8b2Snia      echo "You should only need it if you modified 'acconfig.h' or"
1482007c8b2Snia      echo "$configure_deps."
1492007c8b2Snia      program_details 'autoheader'
1502007c8b2Snia      ;;
1512007c8b2Snia    automake*)
1522007c8b2Snia      echo "You should only need it if you modified 'Makefile.am' or"
1532007c8b2Snia      echo "$configure_deps."
1542007c8b2Snia      program_details 'automake'
1552007c8b2Snia      ;;
1562007c8b2Snia    aclocal*)
1572007c8b2Snia      echo "You should only need it if you modified 'acinclude.m4' or"
1582007c8b2Snia      echo "$configure_deps."
1592007c8b2Snia      program_details 'aclocal'
1602007c8b2Snia      ;;
1612007c8b2Snia   autom4te*)
1622007c8b2Snia      echo "You might have modified some maintainer files that require"
1632007c8b2Snia      echo "the 'autom4te' program to be rebuilt."
1642007c8b2Snia      program_details 'autom4te'
1652007c8b2Snia      ;;
1662007c8b2Snia    bison*|yacc*)
1672007c8b2Snia      echo "You should only need it if you modified a '.y' file."
1682007c8b2Snia      echo "You may want to install the GNU Bison package:"
1692007c8b2Snia      echo "<$gnu_software_URL/bison/>"
1702007c8b2Snia      ;;
1712007c8b2Snia    lex*|flex*)
1722007c8b2Snia      echo "You should only need it if you modified a '.l' file."
1732007c8b2Snia      echo "You may want to install the Fast Lexical Analyzer package:"
1742007c8b2Snia      echo "<$flex_URL>"
1752007c8b2Snia      ;;
1762007c8b2Snia    help2man*)
1772007c8b2Snia      echo "You should only need it if you modified a dependency" \
1782007c8b2Snia           "of a man page."
1792007c8b2Snia      echo "You may want to install the GNU Help2man package:"
1802007c8b2Snia      echo "<$gnu_software_URL/help2man/>"
1812007c8b2Snia    ;;
1822007c8b2Snia    makeinfo*)
1832007c8b2Snia      echo "You should only need it if you modified a '.texi' file, or"
1842007c8b2Snia      echo "any other file indirectly affecting the aspect of the manual."
1852007c8b2Snia      echo "You might want to install the Texinfo package:"
1862007c8b2Snia      echo "<$gnu_software_URL/texinfo/>"
1872007c8b2Snia      echo "The spurious makeinfo call might also be the consequence of"
1882007c8b2Snia      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1892007c8b2Snia      echo "want to install GNU make:"
1902007c8b2Snia      echo "<$gnu_software_URL/make/>"
1912007c8b2Snia      ;;
1922007c8b2Snia    *)
1932007c8b2Snia      echo "You might have modified some files without having the proper"
1942007c8b2Snia      echo "tools for further handling them.  Check the 'README' file, it"
1952007c8b2Snia      echo "often tells you about the needed prerequisites for installing"
1962007c8b2Snia      echo "this package.  You may also peek at any GNU archive site, in"
1972007c8b2Snia      echo "case some other package contains this missing '$1' program."
1982007c8b2Snia      ;;
1992007c8b2Snia  esac
2002007c8b2Snia}
2012007c8b2Snia
2022007c8b2Sniagive_advice "$1" | sed -e '1s/^/WARNING: /' \
2032007c8b2Snia                       -e '2,$s/^/         /' >&2
2042007c8b2Snia
2052007c8b2Snia# Propagate the correct exit status (expected to be 127 for a program
2062007c8b2Snia# not found, 63 for a program that failed due to version mismatch).
2072007c8b2Sniaexit $st
2082007c8b2Snia
2092007c8b2Snia# Local variables:
2102007c8b2Snia# eval: (add-hook 'write-file-hooks 'time-stamp)
2112007c8b2Snia# time-stamp-start: "scriptversion="
2122007c8b2Snia# time-stamp-format: "%:y-%02m-%02d.%02H"
2132007c8b2Snia# time-stamp-time-zone: "UTC"
2142007c8b2Snia# time-stamp-end: "; # UTC"
2152007c8b2Snia# End:
216