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