153e90a53Smrg#! /bin/sh
253e90a53Smrg# Common stub for a few missing GNU programs while installing.
353e90a53Smrg
453e90a53Smrgscriptversion=2005-06-08.21
553e90a53Smrg
653e90a53Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
753e90a53Smrg#   Free Software Foundation, Inc.
853e90a53Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
953e90a53Smrg
1053e90a53Smrg# This program is free software; you can redistribute it and/or modify
1153e90a53Smrg# it under the terms of the GNU General Public License as published by
1253e90a53Smrg# the Free Software Foundation; either version 2, or (at your option)
1353e90a53Smrg# any later version.
1453e90a53Smrg
1553e90a53Smrg# This program is distributed in the hope that it will be useful,
1653e90a53Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1753e90a53Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1853e90a53Smrg# GNU General Public License for more details.
1953e90a53Smrg
2053e90a53Smrg# You should have received a copy of the GNU General Public License
2153e90a53Smrg# along with this program; if not, write to the Free Software
2253e90a53Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2353e90a53Smrg# 02110-1301, USA.
2453e90a53Smrg
2553e90a53Smrg# As a special exception to the GNU General Public License, if you
2653e90a53Smrg# distribute this file as part of a program that contains a
2753e90a53Smrg# configuration script generated by Autoconf, you may include it under
2853e90a53Smrg# the same distribution terms that you use for the rest of that program.
2953e90a53Smrg
3053e90a53Smrgif test $# -eq 0; then
3153e90a53Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3253e90a53Smrg  exit 1
3353e90a53Smrgfi
3453e90a53Smrg
3553e90a53Smrgrun=:
3653e90a53Smrg
3753e90a53Smrg# In the cases where this matters, `missing' is being run in the
3853e90a53Smrg# srcdir already.
3953e90a53Smrgif test -f configure.ac; then
4053e90a53Smrg  configure_ac=configure.ac
4153e90a53Smrgelse
4253e90a53Smrg  configure_ac=configure.in
4353e90a53Smrgfi
4453e90a53Smrg
4553e90a53Smrgmsg="missing on your system"
4653e90a53Smrg
4753e90a53Smrgcase "$1" in
4853e90a53Smrg--run)
4953e90a53Smrg  # Try to run requested program, and just exit if it succeeds.
5053e90a53Smrg  run=
5153e90a53Smrg  shift
5253e90a53Smrg  "$@" && exit 0
5353e90a53Smrg  # Exit code 63 means version mismatch.  This often happens
5453e90a53Smrg  # when the user try to use an ancient version of a tool on
5553e90a53Smrg  # a file that requires a minimum version.  In this case we
5653e90a53Smrg  # we should proceed has if the program had been absent, or
5753e90a53Smrg  # if --run hadn't been passed.
5853e90a53Smrg  if test $? = 63; then
5953e90a53Smrg    run=:
6053e90a53Smrg    msg="probably too old"
6153e90a53Smrg  fi
6253e90a53Smrg  ;;
6353e90a53Smrg
6453e90a53Smrg  -h|--h|--he|--hel|--help)
6553e90a53Smrg    echo "\
6653e90a53Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6753e90a53Smrg
6853e90a53SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6953e90a53Smrgerror status if there is no known handling for PROGRAM.
7053e90a53Smrg
7153e90a53SmrgOptions:
7253e90a53Smrg  -h, --help      display this help and exit
7353e90a53Smrg  -v, --version   output version information and exit
7453e90a53Smrg  --run           try to run the given command, and emulate it if it fails
7553e90a53Smrg
7653e90a53SmrgSupported PROGRAM values:
7753e90a53Smrg  aclocal      touch file \`aclocal.m4'
7853e90a53Smrg  autoconf     touch file \`configure'
7953e90a53Smrg  autoheader   touch file \`config.h.in'
8053e90a53Smrg  automake     touch all \`Makefile.in' files
8153e90a53Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8253e90a53Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8353e90a53Smrg  help2man     touch the output file
8453e90a53Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8553e90a53Smrg  makeinfo     touch the output file
8653e90a53Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8753e90a53Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8853e90a53Smrg
8953e90a53SmrgSend bug reports to <bug-automake@gnu.org>."
9053e90a53Smrg    exit $?
9153e90a53Smrg    ;;
9253e90a53Smrg
9353e90a53Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9453e90a53Smrg    echo "missing $scriptversion (GNU Automake)"
9553e90a53Smrg    exit $?
9653e90a53Smrg    ;;
9753e90a53Smrg
9853e90a53Smrg  -*)
9953e90a53Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10053e90a53Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10153e90a53Smrg    exit 1
10253e90a53Smrg    ;;
10353e90a53Smrg
10453e90a53Smrgesac
10553e90a53Smrg
10653e90a53Smrg# Now exit if we have it, but it failed.  Also exit now if we
10753e90a53Smrg# don't have it and --version was passed (most likely to detect
10853e90a53Smrg# the program).
10953e90a53Smrgcase "$1" in
11053e90a53Smrg  lex|yacc)
11153e90a53Smrg    # Not GNU programs, they don't have --version.
11253e90a53Smrg    ;;
11353e90a53Smrg
11453e90a53Smrg  tar)
11553e90a53Smrg    if test -n "$run"; then
11653e90a53Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
11753e90a53Smrg       exit 1
11853e90a53Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
11953e90a53Smrg       exit 1
12053e90a53Smrg    fi
12153e90a53Smrg    ;;
12253e90a53Smrg
12353e90a53Smrg  *)
12453e90a53Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12553e90a53Smrg       # We have it, but it failed.
12653e90a53Smrg       exit 1
12753e90a53Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12853e90a53Smrg       # Could not run --version or --help.  This is probably someone
12953e90a53Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13053e90a53Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13153e90a53Smrg       exit 1
13253e90a53Smrg    fi
13353e90a53Smrg    ;;
13453e90a53Smrgesac
13553e90a53Smrg
13653e90a53Smrg# If it does not exist, or fails to run (possibly an outdated version),
13753e90a53Smrg# try to emulate it.
13853e90a53Smrgcase "$1" in
13953e90a53Smrg  aclocal*)
14053e90a53Smrg    echo 1>&2 "\
14153e90a53SmrgWARNING: \`$1' is $msg.  You should only need it if
14253e90a53Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14353e90a53Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14453e90a53Smrg         any GNU archive site."
14553e90a53Smrg    touch aclocal.m4
14653e90a53Smrg    ;;
14753e90a53Smrg
14853e90a53Smrg  autoconf)
14953e90a53Smrg    echo 1>&2 "\
15053e90a53SmrgWARNING: \`$1' is $msg.  You should only need it if
15153e90a53Smrg         you modified \`${configure_ac}'.  You might want to install the
15253e90a53Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15353e90a53Smrg         archive site."
15453e90a53Smrg    touch configure
15553e90a53Smrg    ;;
15653e90a53Smrg
15753e90a53Smrg  autoheader)
15853e90a53Smrg    echo 1>&2 "\
15953e90a53SmrgWARNING: \`$1' is $msg.  You should only need it if
16053e90a53Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16153e90a53Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16253e90a53Smrg         from any GNU archive site."
16353e90a53Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16453e90a53Smrg    test -z "$files" && files="config.h"
16553e90a53Smrg    touch_files=
16653e90a53Smrg    for f in $files; do
16753e90a53Smrg      case "$f" in
16853e90a53Smrg      *:*) touch_files="$touch_files "`echo "$f" |
16953e90a53Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17053e90a53Smrg      *) touch_files="$touch_files $f.in";;
17153e90a53Smrg      esac
17253e90a53Smrg    done
17353e90a53Smrg    touch $touch_files
17453e90a53Smrg    ;;
17553e90a53Smrg
17653e90a53Smrg  automake*)
17753e90a53Smrg    echo 1>&2 "\
17853e90a53SmrgWARNING: \`$1' is $msg.  You should only need it if
17953e90a53Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18053e90a53Smrg         You might want to install the \`Automake' and \`Perl' packages.
18153e90a53Smrg         Grab them from any GNU archive site."
18253e90a53Smrg    find . -type f -name Makefile.am -print |
18353e90a53Smrg	   sed 's/\.am$/.in/' |
18453e90a53Smrg	   while read f; do touch "$f"; done
18553e90a53Smrg    ;;
18653e90a53Smrg
18753e90a53Smrg  autom4te)
18853e90a53Smrg    echo 1>&2 "\
18953e90a53SmrgWARNING: \`$1' is needed, but is $msg.
19053e90a53Smrg         You might have modified some files without having the
19153e90a53Smrg         proper tools for further handling them.
19253e90a53Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19353e90a53Smrg         archive site."
19453e90a53Smrg
19553e90a53Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
19653e90a53Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
19753e90a53Smrg    if test -f "$file"; then
19853e90a53Smrg	touch $file
19953e90a53Smrg    else
20053e90a53Smrg	test -z "$file" || exec >$file
20153e90a53Smrg	echo "#! /bin/sh"
20253e90a53Smrg	echo "# Created by GNU Automake missing as a replacement of"
20353e90a53Smrg	echo "#  $ $@"
20453e90a53Smrg	echo "exit 0"
20553e90a53Smrg	chmod +x $file
20653e90a53Smrg	exit 1
20753e90a53Smrg    fi
20853e90a53Smrg    ;;
20953e90a53Smrg
21053e90a53Smrg  bison|yacc)
21153e90a53Smrg    echo 1>&2 "\
21253e90a53SmrgWARNING: \`$1' $msg.  You should only need it if
21353e90a53Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21453e90a53Smrg         in order for those modifications to take effect.  You can get
21553e90a53Smrg         \`Bison' from any GNU archive site."
21653e90a53Smrg    rm -f y.tab.c y.tab.h
21753e90a53Smrg    if [ $# -ne 1 ]; then
21853e90a53Smrg        eval LASTARG="\${$#}"
21953e90a53Smrg	case "$LASTARG" in
22053e90a53Smrg	*.y)
22153e90a53Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22253e90a53Smrg	    if [ -f "$SRCFILE" ]; then
22353e90a53Smrg	         cp "$SRCFILE" y.tab.c
22453e90a53Smrg	    fi
22553e90a53Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22653e90a53Smrg	    if [ -f "$SRCFILE" ]; then
22753e90a53Smrg	         cp "$SRCFILE" y.tab.h
22853e90a53Smrg	    fi
22953e90a53Smrg	  ;;
23053e90a53Smrg	esac
23153e90a53Smrg    fi
23253e90a53Smrg    if [ ! -f y.tab.h ]; then
23353e90a53Smrg	echo >y.tab.h
23453e90a53Smrg    fi
23553e90a53Smrg    if [ ! -f y.tab.c ]; then
23653e90a53Smrg	echo 'main() { return 0; }' >y.tab.c
23753e90a53Smrg    fi
23853e90a53Smrg    ;;
23953e90a53Smrg
24053e90a53Smrg  lex|flex)
24153e90a53Smrg    echo 1>&2 "\
24253e90a53SmrgWARNING: \`$1' is $msg.  You should only need it if
24353e90a53Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24453e90a53Smrg         in order for those modifications to take effect.  You can get
24553e90a53Smrg         \`Flex' from any GNU archive site."
24653e90a53Smrg    rm -f lex.yy.c
24753e90a53Smrg    if [ $# -ne 1 ]; then
24853e90a53Smrg        eval LASTARG="\${$#}"
24953e90a53Smrg	case "$LASTARG" in
25053e90a53Smrg	*.l)
25153e90a53Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25253e90a53Smrg	    if [ -f "$SRCFILE" ]; then
25353e90a53Smrg	         cp "$SRCFILE" lex.yy.c
25453e90a53Smrg	    fi
25553e90a53Smrg	  ;;
25653e90a53Smrg	esac
25753e90a53Smrg    fi
25853e90a53Smrg    if [ ! -f lex.yy.c ]; then
25953e90a53Smrg	echo 'main() { return 0; }' >lex.yy.c
26053e90a53Smrg    fi
26153e90a53Smrg    ;;
26253e90a53Smrg
26353e90a53Smrg  help2man)
26453e90a53Smrg    echo 1>&2 "\
26553e90a53SmrgWARNING: \`$1' is $msg.  You should only need it if
26653e90a53Smrg	 you modified a dependency of a manual page.  You may need the
26753e90a53Smrg	 \`Help2man' package in order for those modifications to take
26853e90a53Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
26953e90a53Smrg
27053e90a53Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27153e90a53Smrg    if test -z "$file"; then
27253e90a53Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27353e90a53Smrg    fi
27453e90a53Smrg    if [ -f "$file" ]; then
27553e90a53Smrg	touch $file
27653e90a53Smrg    else
27753e90a53Smrg	test -z "$file" || exec >$file
27853e90a53Smrg	echo ".ab help2man is required to generate this page"
27953e90a53Smrg	exit 1
28053e90a53Smrg    fi
28153e90a53Smrg    ;;
28253e90a53Smrg
28353e90a53Smrg  makeinfo)
28453e90a53Smrg    echo 1>&2 "\
28553e90a53SmrgWARNING: \`$1' is $msg.  You should only need it if
28653e90a53Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28753e90a53Smrg         indirectly affecting the aspect of the manual.  The spurious
28853e90a53Smrg         call might also be the consequence of using a buggy \`make' (AIX,
28953e90a53Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29053e90a53Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29153e90a53Smrg    # The file to touch is that specified with -o ...
29253e90a53Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29353e90a53Smrg    if test -z "$file"; then
29453e90a53Smrg      # ... or it is the one specified with @setfilename ...
29553e90a53Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29653e90a53Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
29753e90a53Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
29853e90a53Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29953e90a53Smrg    fi
30053e90a53Smrg    # If the file does not exist, the user really needs makeinfo;
30153e90a53Smrg    # let's fail without touching anything.
30253e90a53Smrg    test -f $file || exit 1
30353e90a53Smrg    touch $file
30453e90a53Smrg    ;;
30553e90a53Smrg
30653e90a53Smrg  tar)
30753e90a53Smrg    shift
30853e90a53Smrg
30953e90a53Smrg    # We have already tried tar in the generic part.
31053e90a53Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31153e90a53Smrg    # messages.
31253e90a53Smrg    if (gnutar --version > /dev/null 2>&1); then
31353e90a53Smrg       gnutar "$@" && exit 0
31453e90a53Smrg    fi
31553e90a53Smrg    if (gtar --version > /dev/null 2>&1); then
31653e90a53Smrg       gtar "$@" && exit 0
31753e90a53Smrg    fi
31853e90a53Smrg    firstarg="$1"
31953e90a53Smrg    if shift; then
32053e90a53Smrg	case "$firstarg" in
32153e90a53Smrg	*o*)
32253e90a53Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
32353e90a53Smrg	    tar "$firstarg" "$@" && exit 0
32453e90a53Smrg	    ;;
32553e90a53Smrg	esac
32653e90a53Smrg	case "$firstarg" in
32753e90a53Smrg	*h*)
32853e90a53Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
32953e90a53Smrg	    tar "$firstarg" "$@" && exit 0
33053e90a53Smrg	    ;;
33153e90a53Smrg	esac
33253e90a53Smrg    fi
33353e90a53Smrg
33453e90a53Smrg    echo 1>&2 "\
33553e90a53SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
33653e90a53Smrg         You may want to install GNU tar or Free paxutils, or check the
33753e90a53Smrg         command line arguments."
33853e90a53Smrg    exit 1
33953e90a53Smrg    ;;
34053e90a53Smrg
34153e90a53Smrg  *)
34253e90a53Smrg    echo 1>&2 "\
34353e90a53SmrgWARNING: \`$1' is needed, and is $msg.
34453e90a53Smrg         You might have modified some files without having the
34553e90a53Smrg         proper tools for further handling them.  Check the \`README' file,
34653e90a53Smrg         it often tells you about the needed prerequisites for installing
34753e90a53Smrg         this package.  You may also peek at any GNU archive site, in case
34853e90a53Smrg         some other package would contain this missing \`$1' program."
34953e90a53Smrg    exit 1
35053e90a53Smrg    ;;
35153e90a53Smrgesac
35253e90a53Smrg
35353e90a53Smrgexit 0
35453e90a53Smrg
35553e90a53Smrg# Local variables:
35653e90a53Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
35753e90a53Smrg# time-stamp-start: "scriptversion="
35853e90a53Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
35953e90a53Smrg# time-stamp-end: "$"
36053e90a53Smrg# End:
361