csomh / source-git / rpm

Forked from source-git/rpm 4 years ago
Clone
2ff057
#! /bin/sh
2ff057
# Common wrapper for a few potentially missing GNU programs.
2ff057
2ff057
scriptversion=2013-10-28.13; # UTC
2ff057
2ff057
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
2ff057
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
2ff057
2ff057
# This program is free software; you can redistribute it and/or modify
2ff057
# it under the terms of the GNU General Public License as published by
2ff057
# the Free Software Foundation; either version 2, or (at your option)
2ff057
# any later version.
2ff057
2ff057
# This program is distributed in the hope that it will be useful,
2ff057
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2ff057
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2ff057
# GNU General Public License for more details.
2ff057
2ff057
# You should have received a copy of the GNU General Public License
2ff057
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2ff057
2ff057
# As a special exception to the GNU General Public License, if you
2ff057
# distribute this file as part of a program that contains a
2ff057
# configuration script generated by Autoconf, you may include it under
2ff057
# the same distribution terms that you use for the rest of that program.
2ff057
2ff057
if test $# -eq 0; then
2ff057
  echo 1>&2 "Try '$0 --help' for more information"
2ff057
  exit 1
2ff057
fi
2ff057
2ff057
case $1 in
2ff057
2ff057
  --is-lightweight)
2ff057
    # Used by our autoconf macros to check whether the available missing
2ff057
    # script is modern enough.
2ff057
    exit 0
2ff057
    ;;
2ff057
2ff057
  --run)
2ff057
    # Back-compat with the calling convention used by older automake.
2ff057
    shift
2ff057
    ;;
2ff057
2ff057
  -h|--h|--he|--hel|--help)
2ff057
    echo "\
2ff057
$0 [OPTION]... PROGRAM [ARGUMENT]...
2ff057
2ff057
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
2ff057
to PROGRAM being missing or too old.
2ff057
2ff057
Options:
2ff057
  -h, --help      display this help and exit
2ff057
  -v, --version   output version information and exit
2ff057
2ff057
Supported PROGRAM values:
2ff057
  aclocal   autoconf  autoheader   autom4te  automake  makeinfo
2ff057
  bison     yacc      flex         lex       help2man
2ff057
2ff057
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
2ff057
'g' are ignored when checking the name.
2ff057
2ff057
Send bug reports to <bug-automake@gnu.org>."
2ff057
    exit $?
2ff057
    ;;
2ff057
2ff057
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
2ff057
    echo "missing $scriptversion (GNU Automake)"
2ff057
    exit $?
2ff057
    ;;
2ff057
2ff057
  -*)
2ff057
    echo 1>&2 "$0: unknown '$1' option"
2ff057
    echo 1>&2 "Try '$0 --help' for more information"
2ff057
    exit 1
2ff057
    ;;
2ff057
2ff057
esac
2ff057
2ff057
# Run the given program, remember its exit status.
2ff057
"$@"; st=$?
2ff057
2ff057
# If it succeeded, we are done.
2ff057
test $st -eq 0 && exit 0
2ff057
2ff057
# Also exit now if we it failed (or wasn't found), and '--version' was
2ff057
# passed; such an option is passed most likely to detect whether the
2ff057
# program is present and works.
2ff057
case $2 in --version|--help) exit $st;; esac
2ff057
2ff057
# Exit code 63 means version mismatch.  This often happens when the user
2ff057
# tries to use an ancient version of a tool on a file that requires a
2ff057
# minimum version.
2ff057
if test $st -eq 63; then
2ff057
  msg="probably too old"
2ff057
elif test $st -eq 127; then
2ff057
  # Program was missing.
2ff057
  msg="missing on your system"
2ff057
else
2ff057
  # Program was found and executed, but failed.  Give up.
2ff057
  exit $st
2ff057
fi
2ff057
2ff057
perl_URL=http://www.perl.org/
2ff057
flex_URL=http://flex.sourceforge.net/
2ff057
gnu_software_URL=http://www.gnu.org/software
2ff057
2ff057
program_details ()
2ff057
{
2ff057
  case $1 in
2ff057
    aclocal|automake)
2ff057
      echo "The '$1' program is part of the GNU Automake package:"
2ff057
      echo "<$gnu_software_URL/automake>"
2ff057
      echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
2ff057
      echo "<$gnu_software_URL/autoconf>"
2ff057
      echo "<$gnu_software_URL/m4/>"
2ff057
      echo "<$perl_URL>"
2ff057
      ;;
2ff057
    autoconf|autom4te|autoheader)
2ff057
      echo "The '$1' program is part of the GNU Autoconf package:"
2ff057
      echo "<$gnu_software_URL/autoconf/>"
2ff057
      echo "It also requires GNU m4 and Perl in order to run:"
2ff057
      echo "<$gnu_software_URL/m4/>"
2ff057
      echo "<$perl_URL>"
2ff057
      ;;
2ff057
  esac
2ff057
}
2ff057
2ff057
give_advice ()
2ff057
{
2ff057
  # Normalize program name to check for.
2ff057
  normalized_program=`echo "$1" | sed '
2ff057
    s/^gnu-//; t
2ff057
    s/^gnu//; t
2ff057
    s/^g//; t'`
2ff057
2ff057
  printf '%s\n' "'$1' is $msg."
2ff057
2ff057
  configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
2ff057
  case $normalized_program in
2ff057
    autoconf*)
2ff057
      echo "You should only need it if you modified 'configure.ac',"
2ff057
      echo "or m4 files included by it."
2ff057
      program_details 'autoconf'
2ff057
      ;;
2ff057
    autoheader*)
2ff057
      echo "You should only need it if you modified 'acconfig.h' or"
2ff057
      echo "$configure_deps."
2ff057
      program_details 'autoheader'
2ff057
      ;;
2ff057
    automake*)
2ff057
      echo "You should only need it if you modified 'Makefile.am' or"
2ff057
      echo "$configure_deps."
2ff057
      program_details 'automake'
2ff057
      ;;
2ff057
    aclocal*)
2ff057
      echo "You should only need it if you modified 'acinclude.m4' or"
2ff057
      echo "$configure_deps."
2ff057
      program_details 'aclocal'
2ff057
      ;;
2ff057
   autom4te*)
2ff057
      echo "You might have modified some maintainer files that require"
2ff057
      echo "the 'autom4te' program to be rebuilt."
2ff057
      program_details 'autom4te'
2ff057
      ;;
2ff057
    bison*|yacc*)
2ff057
      echo "You should only need it if you modified a '.y' file."
2ff057
      echo "You may want to install the GNU Bison package:"
2ff057
      echo "<$gnu_software_URL/bison/>"
2ff057
      ;;
2ff057
    lex*|flex*)
2ff057
      echo "You should only need it if you modified a '.l' file."
2ff057
      echo "You may want to install the Fast Lexical Analyzer package:"
2ff057
      echo "<$flex_URL>"
2ff057
      ;;
2ff057
    help2man*)
2ff057
      echo "You should only need it if you modified a dependency" \
2ff057
           "of a man page."
2ff057
      echo "You may want to install the GNU Help2man package:"
2ff057
      echo "<$gnu_software_URL/help2man/>"
2ff057
    ;;
2ff057
    makeinfo*)
2ff057
      echo "You should only need it if you modified a '.texi' file, or"
2ff057
      echo "any other file indirectly affecting the aspect of the manual."
2ff057
      echo "You might want to install the Texinfo package:"
2ff057
      echo "<$gnu_software_URL/texinfo/>"
2ff057
      echo "The spurious makeinfo call might also be the consequence of"
2ff057
      echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
2ff057
      echo "want to install GNU make:"
2ff057
      echo "<$gnu_software_URL/make/>"
2ff057
      ;;
2ff057
    *)
2ff057
      echo "You might have modified some files without having the proper"
2ff057
      echo "tools for further handling them.  Check the 'README' file, it"
2ff057
      echo "often tells you about the needed prerequisites for installing"
2ff057
      echo "this package.  You may also peek at any GNU archive site, in"
2ff057
      echo "case some other package contains this missing '$1' program."
2ff057
      ;;
2ff057
  esac
2ff057
}
2ff057
2ff057
give_advice "$1" | sed -e '1s/^/WARNING: /' \
2ff057
                       -e '2,$s/^/         /' >&2
2ff057
2ff057
# Propagate the correct exit status (expected to be 127 for a program
2ff057
# not found, 63 for a program that failed due to version mismatch).
2ff057
exit $st
2ff057
2ff057
# Local variables:
2ff057
# eval: (add-hook 'write-file-hooks 'time-stamp)
2ff057
# time-stamp-start: "scriptversion="
2ff057
# time-stamp-format: "%:y-%02m-%02d.%02H"
2ff057
# time-stamp-time-zone: "UTC"
2ff057
# time-stamp-end: "; # UTC"
2ff057
# End: