missing revision 9ff100ac
176910425Smrg#! /bin/sh
29ff100acSmrg# Common wrapper for a few potentially missing GNU programs.
376910425Smrg
49ff100acSmrgscriptversion=2013-10-28.13; # UTC
576910425Smrg
69ff100acSmrg# Copyright (C) 1996-2014 Free Software Foundation, Inc.
79ff100acSmrg# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
876910425Smrg
976910425Smrg# This program is free software; you can redistribute it and/or modify
1076910425Smrg# it under the terms of the GNU General Public License as published by
1176910425Smrg# the Free Software Foundation; either version 2, or (at your option)
1276910425Smrg# any later version.
1376910425Smrg
1476910425Smrg# This program is distributed in the hope that it will be useful,
1576910425Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1676910425Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1776910425Smrg# GNU General Public License for more details.
1876910425Smrg
1976910425Smrg# You should have received a copy of the GNU General Public License
20db17cd6dSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2176910425Smrg
2276910425Smrg# As a special exception to the GNU General Public License, if you
2376910425Smrg# distribute this file as part of a program that contains a
2476910425Smrg# configuration script generated by Autoconf, you may include it under
2576910425Smrg# the same distribution terms that you use for the rest of that program.
2676910425Smrg
2776910425Smrgif test $# -eq 0; then
289ff100acSmrg  echo 1>&2 "Try '$0 --help' for more information"
2976910425Smrg  exit 1
3076910425Smrgfi
3176910425Smrg
329ff100acSmrgcase $1 in
3376910425Smrg
349ff100acSmrg  --is-lightweight)
359ff100acSmrg    # Used by our autoconf macros to check whether the available missing
369ff100acSmrg    # script is modern enough.
379ff100acSmrg    exit 0
389ff100acSmrg    ;;
3976910425Smrg
409ff100acSmrg  --run)
419ff100acSmrg    # Back-compat with the calling convention used by older automake.
429ff100acSmrg    shift
439ff100acSmrg    ;;
4476910425Smrg
4576910425Smrg  -h|--h|--he|--hel|--help)
4676910425Smrg    echo "\
4776910425Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
4876910425Smrg
499ff100acSmrgRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
509ff100acSmrgto PROGRAM being missing or too old.
5176910425Smrg
5276910425SmrgOptions:
5376910425Smrg  -h, --help      display this help and exit
5476910425Smrg  -v, --version   output version information and exit
5576910425Smrg
5676910425SmrgSupported PROGRAM values:
579ff100acSmrg  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
589ff100acSmrg  bison     yacc      flex         lex       help2man
5976910425Smrg
609ff100acSmrgVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
619ff100acSmrg'g' are ignored when checking the name.
62db17cd6dSmrg
6376910425SmrgSend bug reports to <bug-automake@gnu.org>."
6476910425Smrg    exit $?
6576910425Smrg    ;;
6676910425Smrg
6776910425Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
6876910425Smrg    echo "missing $scriptversion (GNU Automake)"
6976910425Smrg    exit $?
7076910425Smrg    ;;
7176910425Smrg
7276910425Smrg  -*)
739ff100acSmrg    echo 1>&2 "$0: unknown '$1' option"
749ff100acSmrg    echo 1>&2 "Try '$0 --help' for more information"
7576910425Smrg    exit 1
7676910425Smrg    ;;
7776910425Smrg
7876910425Smrgesac
7976910425Smrg
809ff100acSmrg# Run the given program, remember its exit status.
819ff100acSmrg"$@"; st=$?
829ff100acSmrg
839ff100acSmrg# If it succeeded, we are done.
849ff100acSmrgtest $st -eq 0 && exit 0
859ff100acSmrg
869ff100acSmrg# Also exit now if we it failed (or wasn't found), and '--version' was
879ff100acSmrg# passed; such an option is passed most likely to detect whether the
889ff100acSmrg# program is present and works.
899ff100acSmrgcase $2 in --version|--help) exit $st;; esac
909ff100acSmrg
919ff100acSmrg# Exit code 63 means version mismatch.  This often happens when the user
929ff100acSmrg# tries to use an ancient version of a tool on a file that requires a
939ff100acSmrg# minimum version.
949ff100acSmrgif test $st -eq 63; then
959ff100acSmrg  msg="probably too old"
969ff100acSmrgelif test $st -eq 127; then
979ff100acSmrg  # Program was missing.
989ff100acSmrg  msg="missing on your system"
999ff100acSmrgelse
1009ff100acSmrg  # Program was found and executed, but failed.  Give up.
1019ff100acSmrg  exit $st
1029ff100acSmrgfi
10376910425Smrg
1049ff100acSmrgperl_URL=http://www.perl.org/
1059ff100acSmrgflex_URL=http://flex.sourceforge.net/
1069ff100acSmrggnu_software_URL=http://www.gnu.org/software
1079ff100acSmrg
1089ff100acSmrgprogram_details ()
1099ff100acSmrg{
1109ff100acSmrg  case $1 in
1119ff100acSmrg    aclocal|automake)
1129ff100acSmrg      echo "The '$1' program is part of the GNU Automake package:"
1139ff100acSmrg      echo "<$gnu_software_URL/automake>"
1149ff100acSmrg      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1159ff100acSmrg      echo "<$gnu_software_URL/autoconf>"
1169ff100acSmrg      echo "<$gnu_software_URL/m4/>"
1179ff100acSmrg      echo "<$perl_URL>"
1189ff100acSmrg      ;;
1199ff100acSmrg    autoconf|autom4te|autoheader)
1209ff100acSmrg      echo "The '$1' program is part of the GNU Autoconf package:"
1219ff100acSmrg      echo "<$gnu_software_URL/autoconf/>"
1229ff100acSmrg      echo "It also requires GNU m4 and Perl in order to run:"
1239ff100acSmrg      echo "<$gnu_software_URL/m4/>"
1249ff100acSmrg      echo "<$perl_URL>"
1259ff100acSmrg      ;;
1269ff100acSmrg  esac
1279ff100acSmrg}
1289ff100acSmrg
1299ff100acSmrggive_advice ()
1309ff100acSmrg{
1319ff100acSmrg  # Normalize program name to check for.
1329ff100acSmrg  normalized_program=`echo "$1" | sed '
1339ff100acSmrg    s/^gnu-//; t
1349ff100acSmrg    s/^gnu//; t
1359ff100acSmrg    s/^g//; t'`
1369ff100acSmrg
1379ff100acSmrg  printf '%s\n' "'$1' is $msg."
1389ff100acSmrg
1399ff100acSmrg  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1409ff100acSmrg  case $normalized_program in
1419ff100acSmrg    autoconf*)
1429ff100acSmrg      echo "You should only need it if you modified 'configure.ac',"
1439ff100acSmrg      echo "or m4 files included by it."
1449ff100acSmrg      program_details 'autoconf'
1459ff100acSmrg      ;;
1469ff100acSmrg    autoheader*)
1479ff100acSmrg      echo "You should only need it if you modified 'acconfig.h' or"
1489ff100acSmrg      echo "$configure_deps."
1499ff100acSmrg      program_details 'autoheader'
1509ff100acSmrg      ;;
1519ff100acSmrg    automake*)
1529ff100acSmrg      echo "You should only need it if you modified 'Makefile.am' or"
1539ff100acSmrg      echo "$configure_deps."
1549ff100acSmrg      program_details 'automake'
1559ff100acSmrg      ;;
1569ff100acSmrg    aclocal*)
1579ff100acSmrg      echo "You should only need it if you modified 'acinclude.m4' or"
1589ff100acSmrg      echo "$configure_deps."
1599ff100acSmrg      program_details 'aclocal'
1609ff100acSmrg      ;;
1619ff100acSmrg   autom4te*)
1629ff100acSmrg      echo "You might have modified some maintainer files that require"
1639ff100acSmrg      echo "the 'autom4te' program to be rebuilt."
1649ff100acSmrg      program_details 'autom4te'
1659ff100acSmrg      ;;
1669ff100acSmrg    bison*|yacc*)
1679ff100acSmrg      echo "You should only need it if you modified a '.y' file."
1689ff100acSmrg      echo "You may want to install the GNU Bison package:"
1699ff100acSmrg      echo "<$gnu_software_URL/bison/>"
1709ff100acSmrg      ;;
1719ff100acSmrg    lex*|flex*)
1729ff100acSmrg      echo "You should only need it if you modified a '.l' file."
1739ff100acSmrg      echo "You may want to install the Fast Lexical Analyzer package:"
1749ff100acSmrg      echo "<$flex_URL>"
1759ff100acSmrg      ;;
1769ff100acSmrg    help2man*)
1779ff100acSmrg      echo "You should only need it if you modified a dependency" \
1789ff100acSmrg           "of a man page."
1799ff100acSmrg      echo "You may want to install the GNU Help2man package:"
1809ff100acSmrg      echo "<$gnu_software_URL/help2man/>"
1819ff100acSmrg    ;;
1829ff100acSmrg    makeinfo*)
1839ff100acSmrg      echo "You should only need it if you modified a '.texi' file, or"
1849ff100acSmrg      echo "any other file indirectly affecting the aspect of the manual."
1859ff100acSmrg      echo "You might want to install the Texinfo package:"
1869ff100acSmrg      echo "<$gnu_software_URL/texinfo/>"
1879ff100acSmrg      echo "The spurious makeinfo call might also be the consequence of"
1889ff100acSmrg      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1899ff100acSmrg      echo "want to install GNU make:"
1909ff100acSmrg      echo "<$gnu_software_URL/make/>"
1919ff100acSmrg      ;;
1929ff100acSmrg    *)
1939ff100acSmrg      echo "You might have modified some files without having the proper"
1949ff100acSmrg      echo "tools for further handling them.  Check the 'README' file, it"
1959ff100acSmrg      echo "often tells you about the needed prerequisites for installing"
1969ff100acSmrg      echo "this package.  You may also peek at any GNU archive site, in"
1979ff100acSmrg      echo "case some other package contains this missing '$1' program."
1989ff100acSmrg      ;;
1999ff100acSmrg  esac
2009ff100acSmrg}
2019ff100acSmrg
2029ff100acSmrggive_advice "$1" | sed -e '1s/^/WARNING: /' \
2039ff100acSmrg                       -e '2,$s/^/         /' >&2
2049ff100acSmrg
2059ff100acSmrg# Propagate the correct exit status (expected to be 127 for a program
2069ff100acSmrg# not found, 63 for a program that failed due to version mismatch).
2079ff100acSmrgexit $st
20876910425Smrg
20976910425Smrg# Local variables:
21076910425Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
21176910425Smrg# time-stamp-start: "scriptversion="
21276910425Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
213db17cd6dSmrg# time-stamp-time-zone: "UTC"
214db17cd6dSmrg# time-stamp-end: "; # UTC"
21576910425Smrg# End:
216