Blame missing

Packit a38265
#! /bin/sh
Packit a38265
# Common stub for a few missing GNU programs while installing.
Packit a38265
Packit a38265
scriptversion=2009-04-28.21; # UTC
Packit a38265
Packit a38265
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
Packit a38265
# 2008, 2009 Free Software Foundation, Inc.
Packit a38265
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
Packit a38265
Packit a38265
# This program is free software; you can redistribute it and/or modify
Packit a38265
# it under the terms of the GNU General Public License as published by
Packit a38265
# the Free Software Foundation; either version 2, or (at your option)
Packit a38265
# any later version.
Packit a38265
Packit a38265
# This program is distributed in the hope that it will be useful,
Packit a38265
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a38265
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit a38265
# GNU General Public License for more details.
Packit a38265
Packit a38265
# You should have received a copy of the GNU General Public License
Packit a38265
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit a38265
Packit a38265
# As a special exception to the GNU General Public License, if you
Packit a38265
# distribute this file as part of a program that contains a
Packit a38265
# configuration script generated by Autoconf, you may include it under
Packit a38265
# the same distribution terms that you use for the rest of that program.
Packit a38265
Packit a38265
if test $# -eq 0; then
Packit a38265
  echo 1>&2 "Try \`$0 --help' for more information"
Packit a38265
  exit 1
Packit a38265
fi
Packit a38265
Packit a38265
run=:
Packit a38265
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
Packit a38265
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
Packit a38265
Packit a38265
# In the cases where this matters, `missing' is being run in the
Packit a38265
# srcdir already.
Packit a38265
if test -f configure.ac; then
Packit a38265
  configure_ac=configure.ac
Packit a38265
else
Packit a38265
  configure_ac=configure.in
Packit a38265
fi
Packit a38265
Packit a38265
msg="missing on your system"
Packit a38265
Packit a38265
case $1 in
Packit a38265
--run)
Packit a38265
  # Try to run requested program, and just exit if it succeeds.
Packit a38265
  run=
Packit a38265
  shift
Packit a38265
  "$@" && exit 0
Packit a38265
  # Exit code 63 means version mismatch.  This often happens
Packit a38265
  # when the user try to use an ancient version of a tool on
Packit a38265
  # a file that requires a minimum version.  In this case we
Packit a38265
  # we should proceed has if the program had been absent, or
Packit a38265
  # if --run hadn't been passed.
Packit a38265
  if test $? = 63; then
Packit a38265
    run=:
Packit a38265
    msg="probably too old"
Packit a38265
  fi
Packit a38265
  ;;
Packit a38265
Packit a38265
  -h|--h|--he|--hel|--help)
Packit a38265
    echo "\
Packit a38265
$0 [OPTION]... PROGRAM [ARGUMENT]...
Packit a38265
Packit a38265
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
Packit a38265
error status if there is no known handling for PROGRAM.
Packit a38265
Packit a38265
Options:
Packit a38265
  -h, --help      display this help and exit
Packit a38265
  -v, --version   output version information and exit
Packit a38265
  --run           try to run the given command, and emulate it if it fails
Packit a38265
Packit a38265
Supported PROGRAM values:
Packit a38265
  aclocal      touch file \`aclocal.m4'
Packit a38265
  autoconf     touch file \`configure'
Packit a38265
  autoheader   touch file \`config.h.in'
Packit a38265
  autom4te     touch the output file, or create a stub one
Packit a38265
  automake     touch all \`Makefile.in' files
Packit a38265
  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
Packit a38265
  flex         create \`lex.yy.c', if possible, from existing .c
Packit a38265
  help2man     touch the output file
Packit a38265
  lex          create \`lex.yy.c', if possible, from existing .c
Packit a38265
  makeinfo     touch the output file
Packit a38265
  tar          try tar, gnutar, gtar, then tar without non-portable flags
Packit a38265
  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
Packit a38265
Packit a38265
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
Packit a38265
\`g' are ignored when checking the name.
Packit a38265
Packit a38265
Send bug reports to <bug-automake@gnu.org>."
Packit a38265
    exit $?
Packit a38265
    ;;
Packit a38265
Packit a38265
  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
Packit a38265
    echo "missing $scriptversion (GNU Automake)"
Packit a38265
    exit $?
Packit a38265
    ;;
Packit a38265
Packit a38265
  -*)
Packit a38265
    echo 1>&2 "$0: Unknown \`$1' option"
Packit a38265
    echo 1>&2 "Try \`$0 --help' for more information"
Packit a38265
    exit 1
Packit a38265
    ;;
Packit a38265
Packit a38265
esac
Packit a38265
Packit a38265
# normalize program name to check for.
Packit a38265
program=`echo "$1" | sed '
Packit a38265
  s/^gnu-//; t
Packit a38265
  s/^gnu//; t
Packit a38265
  s/^g//; t'`
Packit a38265
Packit a38265
# Now exit if we have it, but it failed.  Also exit now if we
Packit a38265
# don't have it and --version was passed (most likely to detect
Packit a38265
# the program).  This is about non-GNU programs, so use $1 not
Packit a38265
# $program.
Packit a38265
case $1 in
Packit a38265
  lex*|yacc*)
Packit a38265
    # Not GNU programs, they don't have --version.
Packit a38265
    ;;
Packit a38265
Packit a38265
  tar*)
Packit a38265
    if test -n "$run"; then
Packit a38265
       echo 1>&2 "ERROR: \`tar' requires --run"
Packit a38265
       exit 1
Packit a38265
    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
Packit a38265
       exit 1
Packit a38265
    fi
Packit a38265
    ;;
Packit a38265
Packit a38265
  *)
Packit a38265
    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
Packit a38265
       # We have it, but it failed.
Packit a38265
       exit 1
Packit a38265
    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
Packit a38265
       # Could not run --version or --help.  This is probably someone
Packit a38265
       # running `$TOOL --version' or `$TOOL --help' to check whether
Packit a38265
       # $TOOL exists and not knowing $TOOL uses missing.
Packit a38265
       exit 1
Packit a38265
    fi
Packit a38265
    ;;
Packit a38265
esac
Packit a38265
Packit a38265
# If it does not exist, or fails to run (possibly an outdated version),
Packit a38265
# try to emulate it.
Packit a38265
case $program in
Packit a38265
  aclocal*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is $msg.  You should only need it if
Packit a38265
         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
Packit a38265
         to install the \`Automake' and \`Perl' packages.  Grab them from
Packit a38265
         any GNU archive site."
Packit a38265
    touch aclocal.m4
Packit a38265
    ;;
Packit a38265
Packit a38265
  autoconf*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is $msg.  You should only need it if
Packit a38265
         you modified \`${configure_ac}'.  You might want to install the
Packit a38265
         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
Packit a38265
         archive site."
Packit a38265
    touch configure
Packit a38265
    ;;
Packit a38265
Packit a38265
  autoheader*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is $msg.  You should only need it if
Packit a38265
         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
Packit a38265
         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
Packit a38265
         from any GNU archive site."
Packit a38265
    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
Packit a38265
    test -z "$files" && files="config.h"
Packit a38265
    touch_files=
Packit a38265
    for f in $files; do
Packit a38265
      case $f in
Packit a38265
      *:*) touch_files="$touch_files "`echo "$f" |
Packit a38265
				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
Packit a38265
      *) touch_files="$touch_files $f.in";;
Packit a38265
      esac
Packit a38265
    done
Packit a38265
    touch $touch_files
Packit a38265
    ;;
Packit a38265
Packit a38265
  automake*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is $msg.  You should only need it if
Packit a38265
         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
Packit a38265
         You might want to install the \`Automake' and \`Perl' packages.
Packit a38265
         Grab them from any GNU archive site."
Packit a38265
    find . -type f -name Makefile.am -print |
Packit a38265
	   sed 's/\.am$/.in/' |
Packit a38265
	   while read f; do touch "$f"; done
Packit a38265
    ;;
Packit a38265
Packit a38265
  autom4te*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is needed, but is $msg.
Packit a38265
         You might have modified some files without having the
Packit a38265
         proper tools for further handling them.
Packit a38265
         You can get \`$1' as part of \`Autoconf' from any GNU
Packit a38265
         archive site."
Packit a38265
Packit a38265
    file=`echo "$*" | sed -n "$sed_output"`
Packit a38265
    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
Packit a38265
    if test -f "$file"; then
Packit a38265
	touch $file
Packit a38265
    else
Packit a38265
	test -z "$file" || exec >$file
Packit a38265
	echo "#! /bin/sh"
Packit a38265
	echo "# Created by GNU Automake missing as a replacement of"
Packit a38265
	echo "#  $ $@"
Packit a38265
	echo "exit 0"
Packit a38265
	chmod +x $file
Packit a38265
	exit 1
Packit a38265
    fi
Packit a38265
    ;;
Packit a38265
Packit a38265
  bison*|yacc*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' $msg.  You should only need it if
Packit a38265
         you modified a \`.y' file.  You may need the \`Bison' package
Packit a38265
         in order for those modifications to take effect.  You can get
Packit a38265
         \`Bison' from any GNU archive site."
Packit a38265
    rm -f y.tab.c y.tab.h
Packit a38265
    if test $# -ne 1; then
Packit a38265
        eval LASTARG="\${$#}"
Packit a38265
	case $LASTARG in
Packit a38265
	*.y)
Packit a38265
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
Packit a38265
	    if test -f "$SRCFILE"; then
Packit a38265
	         cp "$SRCFILE" y.tab.c
Packit a38265
	    fi
Packit a38265
	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
Packit a38265
	    if test -f "$SRCFILE"; then
Packit a38265
	         cp "$SRCFILE" y.tab.h
Packit a38265
	    fi
Packit a38265
	  ;;
Packit a38265
	esac
Packit a38265
    fi
Packit a38265
    if test ! -f y.tab.h; then
Packit a38265
	echo >y.tab.h
Packit a38265
    fi
Packit a38265
    if test ! -f y.tab.c; then
Packit a38265
	echo 'main() { return 0; }' >y.tab.c
Packit a38265
    fi
Packit a38265
    ;;
Packit a38265
Packit a38265
  lex*|flex*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is $msg.  You should only need it if
Packit a38265
         you modified a \`.l' file.  You may need the \`Flex' package
Packit a38265
         in order for those modifications to take effect.  You can get
Packit a38265
         \`Flex' from any GNU archive site."
Packit a38265
    rm -f lex.yy.c
Packit a38265
    if test $# -ne 1; then
Packit a38265
        eval LASTARG="\${$#}"
Packit a38265
	case $LASTARG in
Packit a38265
	*.l)
Packit a38265
	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
Packit a38265
	    if test -f "$SRCFILE"; then
Packit a38265
	         cp "$SRCFILE" lex.yy.c
Packit a38265
	    fi
Packit a38265
	  ;;
Packit a38265
	esac
Packit a38265
    fi
Packit a38265
    if test ! -f lex.yy.c; then
Packit a38265
	echo 'main() { return 0; }' >lex.yy.c
Packit a38265
    fi
Packit a38265
    ;;
Packit a38265
Packit a38265
  help2man*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is $msg.  You should only need it if
Packit a38265
	 you modified a dependency of a manual page.  You may need the
Packit a38265
	 \`Help2man' package in order for those modifications to take
Packit a38265
	 effect.  You can get \`Help2man' from any GNU archive site."
Packit a38265
Packit a38265
    file=`echo "$*" | sed -n "$sed_output"`
Packit a38265
    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
Packit a38265
    if test -f "$file"; then
Packit a38265
	touch $file
Packit a38265
    else
Packit a38265
	test -z "$file" || exec >$file
Packit a38265
	echo ".ab help2man is required to generate this page"
Packit a38265
	exit $?
Packit a38265
    fi
Packit a38265
    ;;
Packit a38265
Packit a38265
  makeinfo*)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is $msg.  You should only need it if
Packit a38265
         you modified a \`.texi' or \`.texinfo' file, or any other file
Packit a38265
         indirectly affecting the aspect of the manual.  The spurious
Packit a38265
         call might also be the consequence of using a buggy \`make' (AIX,
Packit a38265
         DU, IRIX).  You might want to install the \`Texinfo' package or
Packit a38265
         the \`GNU make' package.  Grab either from any GNU archive site."
Packit a38265
    # The file to touch is that specified with -o ...
Packit a38265
    file=`echo "$*" | sed -n "$sed_output"`
Packit a38265
    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
Packit a38265
    if test -z "$file"; then
Packit a38265
      # ... or it is the one specified with @setfilename ...
Packit a38265
      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
Packit a38265
      file=`sed -n '
Packit a38265
	/^@setfilename/{
Packit a38265
	  s/.* \([^ ]*\) *$/\1/
Packit a38265
	  p
Packit a38265
	  q
Packit a38265
	}' $infile`
Packit a38265
      # ... or it is derived from the source name (dir/f.texi becomes f.info)
Packit a38265
      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
Packit a38265
    fi
Packit a38265
    # If the file does not exist, the user really needs makeinfo;
Packit a38265
    # let's fail without touching anything.
Packit a38265
    test -f $file || exit 1
Packit a38265
    touch $file
Packit a38265
    ;;
Packit a38265
Packit a38265
  tar*)
Packit a38265
    shift
Packit a38265
Packit a38265
    # We have already tried tar in the generic part.
Packit a38265
    # Look for gnutar/gtar before invocation to avoid ugly error
Packit a38265
    # messages.
Packit a38265
    if (gnutar --version > /dev/null 2>&1;; then
Packit a38265
       gnutar "$@" && exit 0
Packit a38265
    fi
Packit a38265
    if (gtar --version > /dev/null 2>&1;; then
Packit a38265
       gtar "$@" && exit 0
Packit a38265
    fi
Packit a38265
    firstarg="$1"
Packit a38265
    if shift; then
Packit a38265
	case $firstarg in
Packit a38265
	*o*)
Packit a38265
	    firstarg=`echo "$firstarg" | sed s/o//`
Packit a38265
	    tar "$firstarg" "$@" && exit 0
Packit a38265
	    ;;
Packit a38265
	esac
Packit a38265
	case $firstarg in
Packit a38265
	*h*)
Packit a38265
	    firstarg=`echo "$firstarg" | sed s/h//`
Packit a38265
	    tar "$firstarg" "$@" && exit 0
Packit a38265
	    ;;
Packit a38265
	esac
Packit a38265
    fi
Packit a38265
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: I can't seem to be able to run \`tar' with the given arguments.
Packit a38265
         You may want to install GNU tar or Free paxutils, or check the
Packit a38265
         command line arguments."
Packit a38265
    exit 1
Packit a38265
    ;;
Packit a38265
Packit a38265
  *)
Packit a38265
    echo 1>&2 "\
Packit a38265
WARNING: \`$1' is needed, and is $msg.
Packit a38265
         You might have modified some files without having the
Packit a38265
         proper tools for further handling them.  Check the \`README' file,
Packit a38265
         it often tells you about the needed prerequisites for installing
Packit a38265
         this package.  You may also peek at any GNU archive site, in case
Packit a38265
         some other package would contain this missing \`$1' program."
Packit a38265
    exit 1
Packit a38265
    ;;
Packit a38265
esac
Packit a38265
Packit a38265
exit 0
Packit a38265
Packit a38265
# Local variables:
Packit a38265
# eval: (add-hook 'write-file-hooks 'time-stamp)
Packit a38265
# time-stamp-start: "scriptversion="
Packit a38265
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit a38265
# time-stamp-time-zone: "UTC"
Packit a38265
# time-stamp-end: "; # UTC"
Packit a38265
# End: