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