16abeab63Snia#! /bin/sh
26abeab63Snia# Common wrapper for a few potentially missing GNU programs.
36abeab63Snia
46abeab63Sniascriptversion=2013-10-28.13; # UTC
56abeab63Snia
66abeab63Snia# Copyright (C) 1996-2014 Free Software Foundation, Inc.
76abeab63Snia# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
86abeab63Snia
96abeab63Snia# This program is free software; you can redistribute it and/or modify
106abeab63Snia# it under the terms of the GNU General Public License as published by
116abeab63Snia# the Free Software Foundation; either version 2, or (at your option)
126abeab63Snia# any later version.
136abeab63Snia
146abeab63Snia# This program is distributed in the hope that it will be useful,
156abeab63Snia# but WITHOUT ANY WARRANTY; without even the implied warranty of
166abeab63Snia# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
176abeab63Snia# GNU General Public License for more details.
186abeab63Snia
196abeab63Snia# You should have received a copy of the GNU General Public License
206abeab63Snia# along with this program.  If not, see <http://www.gnu.org/licenses/>.
216abeab63Snia
226abeab63Snia# As a special exception to the GNU General Public License, if you
236abeab63Snia# distribute this file as part of a program that contains a
246abeab63Snia# configuration script generated by Autoconf, you may include it under
256abeab63Snia# the same distribution terms that you use for the rest of that program.
266abeab63Snia
276abeab63Sniaif test $# -eq 0; then
286abeab63Snia  echo 1>&2 "Try '$0 --help' for more information"
296abeab63Snia  exit 1
306abeab63Sniafi
316abeab63Snia
326abeab63Sniacase $1 in
336abeab63Snia
346abeab63Snia  --is-lightweight)
356abeab63Snia    # Used by our autoconf macros to check whether the available missing
366abeab63Snia    # script is modern enough.
376abeab63Snia    exit 0
386abeab63Snia    ;;
396abeab63Snia
406abeab63Snia  --run)
416abeab63Snia    # Back-compat with the calling convention used by older automake.
426abeab63Snia    shift
436abeab63Snia    ;;
446abeab63Snia
456abeab63Snia  -h|--h|--he|--hel|--help)
466abeab63Snia    echo "\
476abeab63Snia$0 [OPTION]... PROGRAM [ARGUMENT]...
486abeab63Snia
496abeab63SniaRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
506abeab63Sniato PROGRAM being missing or too old.
516abeab63Snia
526abeab63SniaOptions:
536abeab63Snia  -h, --help      display this help and exit
546abeab63Snia  -v, --version   output version information and exit
556abeab63Snia
566abeab63SniaSupported PROGRAM values:
576abeab63Snia  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
586abeab63Snia  bison     yacc      flex         lex       help2man
596abeab63Snia
606abeab63SniaVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
616abeab63Snia'g' are ignored when checking the name.
626abeab63Snia
636abeab63SniaSend bug reports to <bug-automake@gnu.org>."
646abeab63Snia    exit $?
656abeab63Snia    ;;
666abeab63Snia
676abeab63Snia  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
686abeab63Snia    echo "missing $scriptversion (GNU Automake)"
696abeab63Snia    exit $?
706abeab63Snia    ;;
716abeab63Snia
726abeab63Snia  -*)
736abeab63Snia    echo 1>&2 "$0: unknown '$1' option"
746abeab63Snia    echo 1>&2 "Try '$0 --help' for more information"
756abeab63Snia    exit 1
766abeab63Snia    ;;
776abeab63Snia
786abeab63Sniaesac
796abeab63Snia
806abeab63Snia# Run the given program, remember its exit status.
816abeab63Snia"$@"; st=$?
826abeab63Snia
836abeab63Snia# If it succeeded, we are done.
846abeab63Sniatest $st -eq 0 && exit 0
856abeab63Snia
866abeab63Snia# Also exit now if we it failed (or wasn't found), and '--version' was
876abeab63Snia# passed; such an option is passed most likely to detect whether the
886abeab63Snia# program is present and works.
896abeab63Sniacase $2 in --version|--help) exit $st;; esac
906abeab63Snia
916abeab63Snia# Exit code 63 means version mismatch.  This often happens when the user
926abeab63Snia# tries to use an ancient version of a tool on a file that requires a
936abeab63Snia# minimum version.
946abeab63Sniaif test $st -eq 63; then
956abeab63Snia  msg="probably too old"
966abeab63Sniaelif test $st -eq 127; then
976abeab63Snia  # Program was missing.
986abeab63Snia  msg="missing on your system"
996abeab63Sniaelse
1006abeab63Snia  # Program was found and executed, but failed.  Give up.
1016abeab63Snia  exit $st
1026abeab63Sniafi
1036abeab63Snia
1046abeab63Sniaperl_URL=http://www.perl.org/
1056abeab63Sniaflex_URL=http://flex.sourceforge.net/
1066abeab63Sniagnu_software_URL=http://www.gnu.org/software
1076abeab63Snia
1086abeab63Sniaprogram_details ()
1096abeab63Snia{
1106abeab63Snia  case $1 in
1116abeab63Snia    aclocal|automake)
1126abeab63Snia      echo "The '$1' program is part of the GNU Automake package:"
1136abeab63Snia      echo "<$gnu_software_URL/automake>"
1146abeab63Snia      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1156abeab63Snia      echo "<$gnu_software_URL/autoconf>"
1166abeab63Snia      echo "<$gnu_software_URL/m4/>"
1176abeab63Snia      echo "<$perl_URL>"
1186abeab63Snia      ;;
1196abeab63Snia    autoconf|autom4te|autoheader)
1206abeab63Snia      echo "The '$1' program is part of the GNU Autoconf package:"
1216abeab63Snia      echo "<$gnu_software_URL/autoconf/>"
1226abeab63Snia      echo "It also requires GNU m4 and Perl in order to run:"
1236abeab63Snia      echo "<$gnu_software_URL/m4/>"
1246abeab63Snia      echo "<$perl_URL>"
1256abeab63Snia      ;;
1266abeab63Snia  esac
1276abeab63Snia}
1286abeab63Snia
1296abeab63Sniagive_advice ()
1306abeab63Snia{
1316abeab63Snia  # Normalize program name to check for.
1326abeab63Snia  normalized_program=`echo "$1" | sed '
1336abeab63Snia    s/^gnu-//; t
1346abeab63Snia    s/^gnu//; t
1356abeab63Snia    s/^g//; t'`
1366abeab63Snia
1376abeab63Snia  printf '%s\n' "'$1' is $msg."
1386abeab63Snia
1396abeab63Snia  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1406abeab63Snia  case $normalized_program in
1416abeab63Snia    autoconf*)
1426abeab63Snia      echo "You should only need it if you modified 'configure.ac',"
1436abeab63Snia      echo "or m4 files included by it."
1446abeab63Snia      program_details 'autoconf'
1456abeab63Snia      ;;
1466abeab63Snia    autoheader*)
1476abeab63Snia      echo "You should only need it if you modified 'acconfig.h' or"
1486abeab63Snia      echo "$configure_deps."
1496abeab63Snia      program_details 'autoheader'
1506abeab63Snia      ;;
1516abeab63Snia    automake*)
1526abeab63Snia      echo "You should only need it if you modified 'Makefile.am' or"
1536abeab63Snia      echo "$configure_deps."
1546abeab63Snia      program_details 'automake'
1556abeab63Snia      ;;
1566abeab63Snia    aclocal*)
1576abeab63Snia      echo "You should only need it if you modified 'acinclude.m4' or"
1586abeab63Snia      echo "$configure_deps."
1596abeab63Snia      program_details 'aclocal'
1606abeab63Snia      ;;
1616abeab63Snia   autom4te*)
1626abeab63Snia      echo "You might have modified some maintainer files that require"
1636abeab63Snia      echo "the 'autom4te' program to be rebuilt."
1646abeab63Snia      program_details 'autom4te'
1656abeab63Snia      ;;
1666abeab63Snia    bison*|yacc*)
1676abeab63Snia      echo "You should only need it if you modified a '.y' file."
1686abeab63Snia      echo "You may want to install the GNU Bison package:"
1696abeab63Snia      echo "<$gnu_software_URL/bison/>"
1706abeab63Snia      ;;
1716abeab63Snia    lex*|flex*)
1726abeab63Snia      echo "You should only need it if you modified a '.l' file."
1736abeab63Snia      echo "You may want to install the Fast Lexical Analyzer package:"
1746abeab63Snia      echo "<$flex_URL>"
1756abeab63Snia      ;;
1766abeab63Snia    help2man*)
1776abeab63Snia      echo "You should only need it if you modified a dependency" \
1786abeab63Snia           "of a man page."
1796abeab63Snia      echo "You may want to install the GNU Help2man package:"
1806abeab63Snia      echo "<$gnu_software_URL/help2man/>"
1816abeab63Snia    ;;
1826abeab63Snia    makeinfo*)
1836abeab63Snia      echo "You should only need it if you modified a '.texi' file, or"
1846abeab63Snia      echo "any other file indirectly affecting the aspect of the manual."
1856abeab63Snia      echo "You might want to install the Texinfo package:"
1866abeab63Snia      echo "<$gnu_software_URL/texinfo/>"
1876abeab63Snia      echo "The spurious makeinfo call might also be the consequence of"
1886abeab63Snia      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1896abeab63Snia      echo "want to install GNU make:"
1906abeab63Snia      echo "<$gnu_software_URL/make/>"
1916abeab63Snia      ;;
1926abeab63Snia    *)
1936abeab63Snia      echo "You might have modified some files without having the proper"
1946abeab63Snia      echo "tools for further handling them.  Check the 'README' file, it"
1956abeab63Snia      echo "often tells you about the needed prerequisites for installing"
1966abeab63Snia      echo "this package.  You may also peek at any GNU archive site, in"
1976abeab63Snia      echo "case some other package contains this missing '$1' program."
1986abeab63Snia      ;;
1996abeab63Snia  esac
2006abeab63Snia}
2016abeab63Snia
2026abeab63Sniagive_advice "$1" | sed -e '1s/^/WARNING: /' \
2036abeab63Snia                       -e '2,$s/^/         /' >&2
2046abeab63Snia
2056abeab63Snia# Propagate the correct exit status (expected to be 127 for a program
2066abeab63Snia# not found, 63 for a program that failed due to version mismatch).
2076abeab63Sniaexit $st
2086abeab63Snia
2096abeab63Snia# Local variables:
2106abeab63Snia# eval: (add-hook 'write-file-hooks 'time-stamp)
2116abeab63Snia# time-stamp-start: "scriptversion="
2126abeab63Snia# time-stamp-format: "%:y-%02m-%02d.%02H"
2136abeab63Snia# time-stamp-time-zone: "UTC"
2146abeab63Snia# time-stamp-end: "; # UTC"
2156abeab63Snia# End:
216