11.1Sriastrad#! /bin/sh
21.1Sriastrad# Common wrapper for a few potentially missing GNU programs.
31.1Sriastrad
41.1Sriastradscriptversion=2016-01-11.22; # UTC
51.1Sriastrad
61.1Sriastrad# Copyright (C) 1996-2017 Free Software Foundation, Inc.
71.1Sriastrad# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
81.1Sriastrad
91.1Sriastrad# This program is free software; you can redistribute it and/or modify
101.1Sriastrad# it under the terms of the GNU General Public License as published by
111.1Sriastrad# the Free Software Foundation; either version 2, or (at your option)
121.1Sriastrad# any later version.
131.1Sriastrad
141.1Sriastrad# This program is distributed in the hope that it will be useful,
151.1Sriastrad# but WITHOUT ANY WARRANTY; without even the implied warranty of
161.1Sriastrad# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171.1Sriastrad# GNU General Public License for more details.
181.1Sriastrad
191.1Sriastrad# You should have received a copy of the GNU General Public License
201.1Sriastrad# along with this program.  If not, see <http://www.gnu.org/licenses/>.
211.1Sriastrad
221.1Sriastrad# As a special exception to the GNU General Public License, if you
231.1Sriastrad# distribute this file as part of a program that contains a
241.1Sriastrad# configuration script generated by Autoconf, you may include it under
251.1Sriastrad# the same distribution terms that you use for the rest of that program.
261.1Sriastrad
271.1Sriastradif test $# -eq 0; then
281.1Sriastrad  echo 1>&2 "Try '$0 --help' for more information"
291.1Sriastrad  exit 1
301.1Sriastradfi
311.1Sriastrad
321.1Sriastradcase $1 in
331.1Sriastrad
341.1Sriastrad  --is-lightweight)
351.1Sriastrad    # Used by our autoconf macros to check whether the available missing
361.1Sriastrad    # script is modern enough.
371.1Sriastrad    exit 0
381.1Sriastrad    ;;
391.1Sriastrad
401.1Sriastrad  --run)
411.1Sriastrad    # Back-compat with the calling convention used by older automake.
421.1Sriastrad    shift
431.1Sriastrad    ;;
441.1Sriastrad
451.1Sriastrad  -h|--h|--he|--hel|--help)
461.1Sriastrad    echo "\
471.1Sriastrad$0 [OPTION]... PROGRAM [ARGUMENT]...
481.1Sriastrad
491.1SriastradRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
501.1Sriastradto PROGRAM being missing or too old.
511.1Sriastrad
521.1SriastradOptions:
531.1Sriastrad  -h, --help      display this help and exit
541.1Sriastrad  -v, --version   output version information and exit
551.1Sriastrad
561.1SriastradSupported PROGRAM values:
571.1Sriastrad  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
581.1Sriastrad  bison     yacc      flex         lex       help2man
591.1Sriastrad
601.1SriastradVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
611.1Sriastrad'g' are ignored when checking the name.
621.1Sriastrad
631.1SriastradSend bug reports to <bug-automake@gnu.org>."
641.1Sriastrad    exit $?
651.1Sriastrad    ;;
661.1Sriastrad
671.1Sriastrad  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
681.1Sriastrad    echo "missing $scriptversion (GNU Automake)"
691.1Sriastrad    exit $?
701.1Sriastrad    ;;
711.1Sriastrad
721.1Sriastrad  -*)
731.1Sriastrad    echo 1>&2 "$0: unknown '$1' option"
741.1Sriastrad    echo 1>&2 "Try '$0 --help' for more information"
751.1Sriastrad    exit 1
761.1Sriastrad    ;;
771.1Sriastrad
781.1Sriastradesac
791.1Sriastrad
801.1Sriastrad# Run the given program, remember its exit status.
811.1Sriastrad"$@"; st=$?
821.1Sriastrad
831.1Sriastrad# If it succeeded, we are done.
841.1Sriastradtest $st -eq 0 && exit 0
851.1Sriastrad
861.1Sriastrad# Also exit now if we it failed (or wasn't found), and '--version' was
871.1Sriastrad# passed; such an option is passed most likely to detect whether the
881.1Sriastrad# program is present and works.
891.1Sriastradcase $2 in --version|--help) exit $st;; esac
901.1Sriastrad
911.1Sriastrad# Exit code 63 means version mismatch.  This often happens when the user
921.1Sriastrad# tries to use an ancient version of a tool on a file that requires a
931.1Sriastrad# minimum version.
941.1Sriastradif test $st -eq 63; then
951.1Sriastrad  msg="probably too old"
961.1Sriastradelif test $st -eq 127; then
971.1Sriastrad  # Program was missing.
981.1Sriastrad  msg="missing on your system"
991.1Sriastradelse
1001.1Sriastrad  # Program was found and executed, but failed.  Give up.
1011.1Sriastrad  exit $st
1021.1Sriastradfi
1031.1Sriastrad
1041.1Sriastradperl_URL=http://www.perl.org/
1051.1Sriastradflex_URL=http://flex.sourceforge.net/
1061.1Sriastradgnu_software_URL=http://www.gnu.org/software
1071.1Sriastrad
1081.1Sriastradprogram_details ()
1091.1Sriastrad{
1101.1Sriastrad  case $1 in
1111.1Sriastrad    aclocal|automake)
1121.1Sriastrad      echo "The '$1' program is part of the GNU Automake package:"
1131.1Sriastrad      echo "<$gnu_software_URL/automake>"
1141.1Sriastrad      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
1151.1Sriastrad      echo "<$gnu_software_URL/autoconf>"
1161.1Sriastrad      echo "<$gnu_software_URL/m4/>"
1171.1Sriastrad      echo "<$perl_URL>"
1181.1Sriastrad      ;;
1191.1Sriastrad    autoconf|autom4te|autoheader)
1201.1Sriastrad      echo "The '$1' program is part of the GNU Autoconf package:"
1211.1Sriastrad      echo "<$gnu_software_URL/autoconf/>"
1221.1Sriastrad      echo "It also requires GNU m4 and Perl in order to run:"
1231.1Sriastrad      echo "<$gnu_software_URL/m4/>"
1241.1Sriastrad      echo "<$perl_URL>"
1251.1Sriastrad      ;;
1261.1Sriastrad  esac
1271.1Sriastrad}
1281.1Sriastrad
1291.1Sriastradgive_advice ()
1301.1Sriastrad{
1311.1Sriastrad  # Normalize program name to check for.
1321.1Sriastrad  normalized_program=`echo "$1" | sed '
1331.1Sriastrad    s/^gnu-//; t
1341.1Sriastrad    s/^gnu//; t
1351.1Sriastrad    s/^g//; t'`
1361.1Sriastrad
1371.1Sriastrad  printf '%s\n' "'$1' is $msg."
1381.1Sriastrad
1391.1Sriastrad  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
1401.1Sriastrad  case $normalized_program in
1411.1Sriastrad    autoconf*)
1421.1Sriastrad      echo "You should only need it if you modified 'configure.ac',"
1431.1Sriastrad      echo "or m4 files included by it."
1441.1Sriastrad      program_details 'autoconf'
1451.1Sriastrad      ;;
1461.1Sriastrad    autoheader*)
1471.1Sriastrad      echo "You should only need it if you modified 'acconfig.h' or"
1481.1Sriastrad      echo "$configure_deps."
1491.1Sriastrad      program_details 'autoheader'
1501.1Sriastrad      ;;
1511.1Sriastrad    automake*)
1521.1Sriastrad      echo "You should only need it if you modified 'Makefile.am' or"
1531.1Sriastrad      echo "$configure_deps."
1541.1Sriastrad      program_details 'automake'
1551.1Sriastrad      ;;
1561.1Sriastrad    aclocal*)
1571.1Sriastrad      echo "You should only need it if you modified 'acinclude.m4' or"
1581.1Sriastrad      echo "$configure_deps."
1591.1Sriastrad      program_details 'aclocal'
1601.1Sriastrad      ;;
1611.1Sriastrad   autom4te*)
1621.1Sriastrad      echo "You might have modified some maintainer files that require"
1631.1Sriastrad      echo "the 'autom4te' program to be rebuilt."
1641.1Sriastrad      program_details 'autom4te'
1651.1Sriastrad      ;;
1661.1Sriastrad    bison*|yacc*)
1671.1Sriastrad      echo "You should only need it if you modified a '.y' file."
1681.1Sriastrad      echo "You may want to install the GNU Bison package:"
1691.1Sriastrad      echo "<$gnu_software_URL/bison/>"
1701.1Sriastrad      ;;
1711.1Sriastrad    lex*|flex*)
1721.1Sriastrad      echo "You should only need it if you modified a '.l' file."
1731.1Sriastrad      echo "You may want to install the Fast Lexical Analyzer package:"
1741.1Sriastrad      echo "<$flex_URL>"
1751.1Sriastrad      ;;
1761.1Sriastrad    help2man*)
1771.1Sriastrad      echo "You should only need it if you modified a dependency" \
1781.1Sriastrad           "of a man page."
1791.1Sriastrad      echo "You may want to install the GNU Help2man package:"
1801.1Sriastrad      echo "<$gnu_software_URL/help2man/>"
1811.1Sriastrad    ;;
1821.1Sriastrad    makeinfo*)
1831.1Sriastrad      echo "You should only need it if you modified a '.texi' file, or"
1841.1Sriastrad      echo "any other file indirectly affecting the aspect of the manual."
1851.1Sriastrad      echo "You might want to install the Texinfo package:"
1861.1Sriastrad      echo "<$gnu_software_URL/texinfo/>"
1871.1Sriastrad      echo "The spurious makeinfo call might also be the consequence of"
1881.1Sriastrad      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
1891.1Sriastrad      echo "want to install GNU make:"
1901.1Sriastrad      echo "<$gnu_software_URL/make/>"
1911.1Sriastrad      ;;
1921.1Sriastrad    *)
1931.1Sriastrad      echo "You might have modified some files without having the proper"
1941.1Sriastrad      echo "tools for further handling them.  Check the 'README' file, it"
1951.1Sriastrad      echo "often tells you about the needed prerequisites for installing"
1961.1Sriastrad      echo "this package.  You may also peek at any GNU archive site, in"
1971.1Sriastrad      echo "case some other package contains this missing '$1' program."
1981.1Sriastrad      ;;
1991.1Sriastrad  esac
2001.1Sriastrad}
2011.1Sriastrad
2021.1Sriastradgive_advice "$1" | sed -e '1s/^/WARNING: /' \
2031.1Sriastrad                       -e '2,$s/^/         /' >&2
2041.1Sriastrad
2051.1Sriastrad# Propagate the correct exit status (expected to be 127 for a program
2061.1Sriastrad# not found, 63 for a program that failed due to version mismatch).
2071.1Sriastradexit $st
2081.1Sriastrad
2091.1Sriastrad# Local variables:
2101.1Sriastrad# eval: (add-hook 'write-file-hooks 'time-stamp)
2111.1Sriastrad# time-stamp-start: "scriptversion="
2121.1Sriastrad# time-stamp-format: "%:y-%02m-%02d.%02H"
2131.1Sriastrad# time-stamp-time-zone: "UTC0"
2141.1Sriastrad# time-stamp-end: "; # UTC"
2151.1Sriastrad# End:
216