missing revision 73143b9a
173143b9aSmrg#! /bin/sh
273143b9aSmrg# Common stub for a few missing GNU programs while installing.
373143b9aSmrg
473143b9aSmrgscriptversion=2006-05-10.23
573143b9aSmrg
673143b9aSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
773143b9aSmrg#   Free Software Foundation, Inc.
873143b9aSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
973143b9aSmrg
1073143b9aSmrg# This program is free software; you can redistribute it and/or modify
1173143b9aSmrg# it under the terms of the GNU General Public License as published by
1273143b9aSmrg# the Free Software Foundation; either version 2, or (at your option)
1373143b9aSmrg# any later version.
1473143b9aSmrg
1573143b9aSmrg# This program is distributed in the hope that it will be useful,
1673143b9aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1773143b9aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1873143b9aSmrg# GNU General Public License for more details.
1973143b9aSmrg
2073143b9aSmrg# You should have received a copy of the GNU General Public License
2173143b9aSmrg# along with this program; if not, write to the Free Software
2273143b9aSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2373143b9aSmrg# 02110-1301, USA.
2473143b9aSmrg
2573143b9aSmrg# As a special exception to the GNU General Public License, if you
2673143b9aSmrg# distribute this file as part of a program that contains a
2773143b9aSmrg# configuration script generated by Autoconf, you may include it under
2873143b9aSmrg# the same distribution terms that you use for the rest of that program.
2973143b9aSmrg
3073143b9aSmrgif test $# -eq 0; then
3173143b9aSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3273143b9aSmrg  exit 1
3373143b9aSmrgfi
3473143b9aSmrg
3573143b9aSmrgrun=:
3673143b9aSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3773143b9aSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3873143b9aSmrg
3973143b9aSmrg# In the cases where this matters, `missing' is being run in the
4073143b9aSmrg# srcdir already.
4173143b9aSmrgif test -f configure.ac; then
4273143b9aSmrg  configure_ac=configure.ac
4373143b9aSmrgelse
4473143b9aSmrg  configure_ac=configure.in
4573143b9aSmrgfi
4673143b9aSmrg
4773143b9aSmrgmsg="missing on your system"
4873143b9aSmrg
4973143b9aSmrgcase $1 in
5073143b9aSmrg--run)
5173143b9aSmrg  # Try to run requested program, and just exit if it succeeds.
5273143b9aSmrg  run=
5373143b9aSmrg  shift
5473143b9aSmrg  "$@" && exit 0
5573143b9aSmrg  # Exit code 63 means version mismatch.  This often happens
5673143b9aSmrg  # when the user try to use an ancient version of a tool on
5773143b9aSmrg  # a file that requires a minimum version.  In this case we
5873143b9aSmrg  # we should proceed has if the program had been absent, or
5973143b9aSmrg  # if --run hadn't been passed.
6073143b9aSmrg  if test $? = 63; then
6173143b9aSmrg    run=:
6273143b9aSmrg    msg="probably too old"
6373143b9aSmrg  fi
6473143b9aSmrg  ;;
6573143b9aSmrg
6673143b9aSmrg  -h|--h|--he|--hel|--help)
6773143b9aSmrg    echo "\
6873143b9aSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6973143b9aSmrg
7073143b9aSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7173143b9aSmrgerror status if there is no known handling for PROGRAM.
7273143b9aSmrg
7373143b9aSmrgOptions:
7473143b9aSmrg  -h, --help      display this help and exit
7573143b9aSmrg  -v, --version   output version information and exit
7673143b9aSmrg  --run           try to run the given command, and emulate it if it fails
7773143b9aSmrg
7873143b9aSmrgSupported PROGRAM values:
7973143b9aSmrg  aclocal      touch file \`aclocal.m4'
8073143b9aSmrg  autoconf     touch file \`configure'
8173143b9aSmrg  autoheader   touch file \`config.h.in'
8273143b9aSmrg  autom4te     touch the output file, or create a stub one
8373143b9aSmrg  automake     touch all \`Makefile.in' files
8473143b9aSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8573143b9aSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8673143b9aSmrg  help2man     touch the output file
8773143b9aSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8873143b9aSmrg  makeinfo     touch the output file
8973143b9aSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9073143b9aSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9173143b9aSmrg
9273143b9aSmrgSend bug reports to <bug-automake@gnu.org>."
9373143b9aSmrg    exit $?
9473143b9aSmrg    ;;
9573143b9aSmrg
9673143b9aSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9773143b9aSmrg    echo "missing $scriptversion (GNU Automake)"
9873143b9aSmrg    exit $?
9973143b9aSmrg    ;;
10073143b9aSmrg
10173143b9aSmrg  -*)
10273143b9aSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10373143b9aSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10473143b9aSmrg    exit 1
10573143b9aSmrg    ;;
10673143b9aSmrg
10773143b9aSmrgesac
10873143b9aSmrg
10973143b9aSmrg# Now exit if we have it, but it failed.  Also exit now if we
11073143b9aSmrg# don't have it and --version was passed (most likely to detect
11173143b9aSmrg# the program).
11273143b9aSmrgcase $1 in
11373143b9aSmrg  lex|yacc)
11473143b9aSmrg    # Not GNU programs, they don't have --version.
11573143b9aSmrg    ;;
11673143b9aSmrg
11773143b9aSmrg  tar)
11873143b9aSmrg    if test -n "$run"; then
11973143b9aSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
12073143b9aSmrg       exit 1
12173143b9aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12273143b9aSmrg       exit 1
12373143b9aSmrg    fi
12473143b9aSmrg    ;;
12573143b9aSmrg
12673143b9aSmrg  *)
12773143b9aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12873143b9aSmrg       # We have it, but it failed.
12973143b9aSmrg       exit 1
13073143b9aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13173143b9aSmrg       # Could not run --version or --help.  This is probably someone
13273143b9aSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13373143b9aSmrg       # $TOOL exists and not knowing $TOOL uses missing.
13473143b9aSmrg       exit 1
13573143b9aSmrg    fi
13673143b9aSmrg    ;;
13773143b9aSmrgesac
13873143b9aSmrg
13973143b9aSmrg# If it does not exist, or fails to run (possibly an outdated version),
14073143b9aSmrg# try to emulate it.
14173143b9aSmrgcase $1 in
14273143b9aSmrg  aclocal*)
14373143b9aSmrg    echo 1>&2 "\
14473143b9aSmrgWARNING: \`$1' is $msg.  You should only need it if
14573143b9aSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14673143b9aSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14773143b9aSmrg         any GNU archive site."
14873143b9aSmrg    touch aclocal.m4
14973143b9aSmrg    ;;
15073143b9aSmrg
15173143b9aSmrg  autoconf)
15273143b9aSmrg    echo 1>&2 "\
15373143b9aSmrgWARNING: \`$1' is $msg.  You should only need it if
15473143b9aSmrg         you modified \`${configure_ac}'.  You might want to install the
15573143b9aSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15673143b9aSmrg         archive site."
15773143b9aSmrg    touch configure
15873143b9aSmrg    ;;
15973143b9aSmrg
16073143b9aSmrg  autoheader)
16173143b9aSmrg    echo 1>&2 "\
16273143b9aSmrgWARNING: \`$1' is $msg.  You should only need it if
16373143b9aSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16473143b9aSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16573143b9aSmrg         from any GNU archive site."
16673143b9aSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16773143b9aSmrg    test -z "$files" && files="config.h"
16873143b9aSmrg    touch_files=
16973143b9aSmrg    for f in $files; do
17073143b9aSmrg      case $f in
17173143b9aSmrg      *:*) touch_files="$touch_files "`echo "$f" |
17273143b9aSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17373143b9aSmrg      *) touch_files="$touch_files $f.in";;
17473143b9aSmrg      esac
17573143b9aSmrg    done
17673143b9aSmrg    touch $touch_files
17773143b9aSmrg    ;;
17873143b9aSmrg
17973143b9aSmrg  automake*)
18073143b9aSmrg    echo 1>&2 "\
18173143b9aSmrgWARNING: \`$1' is $msg.  You should only need it if
18273143b9aSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18373143b9aSmrg         You might want to install the \`Automake' and \`Perl' packages.
18473143b9aSmrg         Grab them from any GNU archive site."
18573143b9aSmrg    find . -type f -name Makefile.am -print |
18673143b9aSmrg	   sed 's/\.am$/.in/' |
18773143b9aSmrg	   while read f; do touch "$f"; done
18873143b9aSmrg    ;;
18973143b9aSmrg
19073143b9aSmrg  autom4te)
19173143b9aSmrg    echo 1>&2 "\
19273143b9aSmrgWARNING: \`$1' is needed, but is $msg.
19373143b9aSmrg         You might have modified some files without having the
19473143b9aSmrg         proper tools for further handling them.
19573143b9aSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
19673143b9aSmrg         archive site."
19773143b9aSmrg
19873143b9aSmrg    file=`echo "$*" | sed -n "$sed_output"`
19973143b9aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20073143b9aSmrg    if test -f "$file"; then
20173143b9aSmrg	touch $file
20273143b9aSmrg    else
20373143b9aSmrg	test -z "$file" || exec >$file
20473143b9aSmrg	echo "#! /bin/sh"
20573143b9aSmrg	echo "# Created by GNU Automake missing as a replacement of"
20673143b9aSmrg	echo "#  $ $@"
20773143b9aSmrg	echo "exit 0"
20873143b9aSmrg	chmod +x $file
20973143b9aSmrg	exit 1
21073143b9aSmrg    fi
21173143b9aSmrg    ;;
21273143b9aSmrg
21373143b9aSmrg  bison|yacc)
21473143b9aSmrg    echo 1>&2 "\
21573143b9aSmrgWARNING: \`$1' $msg.  You should only need it if
21673143b9aSmrg         you modified a \`.y' file.  You may need the \`Bison' package
21773143b9aSmrg         in order for those modifications to take effect.  You can get
21873143b9aSmrg         \`Bison' from any GNU archive site."
21973143b9aSmrg    rm -f y.tab.c y.tab.h
22073143b9aSmrg    if test $# -ne 1; then
22173143b9aSmrg        eval LASTARG="\${$#}"
22273143b9aSmrg	case $LASTARG in
22373143b9aSmrg	*.y)
22473143b9aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22573143b9aSmrg	    if test -f "$SRCFILE"; then
22673143b9aSmrg	         cp "$SRCFILE" y.tab.c
22773143b9aSmrg	    fi
22873143b9aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22973143b9aSmrg	    if test -f "$SRCFILE"; then
23073143b9aSmrg	         cp "$SRCFILE" y.tab.h
23173143b9aSmrg	    fi
23273143b9aSmrg	  ;;
23373143b9aSmrg	esac
23473143b9aSmrg    fi
23573143b9aSmrg    if test ! -f y.tab.h; then
23673143b9aSmrg	echo >y.tab.h
23773143b9aSmrg    fi
23873143b9aSmrg    if test ! -f y.tab.c; then
23973143b9aSmrg	echo 'main() { return 0; }' >y.tab.c
24073143b9aSmrg    fi
24173143b9aSmrg    ;;
24273143b9aSmrg
24373143b9aSmrg  lex|flex)
24473143b9aSmrg    echo 1>&2 "\
24573143b9aSmrgWARNING: \`$1' is $msg.  You should only need it if
24673143b9aSmrg         you modified a \`.l' file.  You may need the \`Flex' package
24773143b9aSmrg         in order for those modifications to take effect.  You can get
24873143b9aSmrg         \`Flex' from any GNU archive site."
24973143b9aSmrg    rm -f lex.yy.c
25073143b9aSmrg    if test $# -ne 1; then
25173143b9aSmrg        eval LASTARG="\${$#}"
25273143b9aSmrg	case $LASTARG in
25373143b9aSmrg	*.l)
25473143b9aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25573143b9aSmrg	    if test -f "$SRCFILE"; then
25673143b9aSmrg	         cp "$SRCFILE" lex.yy.c
25773143b9aSmrg	    fi
25873143b9aSmrg	  ;;
25973143b9aSmrg	esac
26073143b9aSmrg    fi
26173143b9aSmrg    if test ! -f lex.yy.c; then
26273143b9aSmrg	echo 'main() { return 0; }' >lex.yy.c
26373143b9aSmrg    fi
26473143b9aSmrg    ;;
26573143b9aSmrg
26673143b9aSmrg  help2man)
26773143b9aSmrg    echo 1>&2 "\
26873143b9aSmrgWARNING: \`$1' is $msg.  You should only need it if
26973143b9aSmrg	 you modified a dependency of a manual page.  You may need the
27073143b9aSmrg	 \`Help2man' package in order for those modifications to take
27173143b9aSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
27273143b9aSmrg
27373143b9aSmrg    file=`echo "$*" | sed -n "$sed_output"`
27473143b9aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
27573143b9aSmrg    if test -f "$file"; then
27673143b9aSmrg	touch $file
27773143b9aSmrg    else
27873143b9aSmrg	test -z "$file" || exec >$file
27973143b9aSmrg	echo ".ab help2man is required to generate this page"
28073143b9aSmrg	exit 1
28173143b9aSmrg    fi
28273143b9aSmrg    ;;
28373143b9aSmrg
28473143b9aSmrg  makeinfo)
28573143b9aSmrg    echo 1>&2 "\
28673143b9aSmrgWARNING: \`$1' is $msg.  You should only need it if
28773143b9aSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28873143b9aSmrg         indirectly affecting the aspect of the manual.  The spurious
28973143b9aSmrg         call might also be the consequence of using a buggy \`make' (AIX,
29073143b9aSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29173143b9aSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
29273143b9aSmrg    # The file to touch is that specified with -o ...
29373143b9aSmrg    file=`echo "$*" | sed -n "$sed_output"`
29473143b9aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29573143b9aSmrg    if test -z "$file"; then
29673143b9aSmrg      # ... or it is the one specified with @setfilename ...
29773143b9aSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29873143b9aSmrg      file=`sed -n '
29973143b9aSmrg	/^@setfilename/{
30073143b9aSmrg	  s/.* \([^ ]*\) *$/\1/
30173143b9aSmrg	  p
30273143b9aSmrg	  q
30373143b9aSmrg	}' $infile`
30473143b9aSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30573143b9aSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30673143b9aSmrg    fi
30773143b9aSmrg    # If the file does not exist, the user really needs makeinfo;
30873143b9aSmrg    # let's fail without touching anything.
30973143b9aSmrg    test -f $file || exit 1
31073143b9aSmrg    touch $file
31173143b9aSmrg    ;;
31273143b9aSmrg
31373143b9aSmrg  tar)
31473143b9aSmrg    shift
31573143b9aSmrg
31673143b9aSmrg    # We have already tried tar in the generic part.
31773143b9aSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
31873143b9aSmrg    # messages.
31973143b9aSmrg    if (gnutar --version > /dev/null 2>&1); then
32073143b9aSmrg       gnutar "$@" && exit 0
32173143b9aSmrg    fi
32273143b9aSmrg    if (gtar --version > /dev/null 2>&1); then
32373143b9aSmrg       gtar "$@" && exit 0
32473143b9aSmrg    fi
32573143b9aSmrg    firstarg="$1"
32673143b9aSmrg    if shift; then
32773143b9aSmrg	case $firstarg in
32873143b9aSmrg	*o*)
32973143b9aSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
33073143b9aSmrg	    tar "$firstarg" "$@" && exit 0
33173143b9aSmrg	    ;;
33273143b9aSmrg	esac
33373143b9aSmrg	case $firstarg in
33473143b9aSmrg	*h*)
33573143b9aSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
33673143b9aSmrg	    tar "$firstarg" "$@" && exit 0
33773143b9aSmrg	    ;;
33873143b9aSmrg	esac
33973143b9aSmrg    fi
34073143b9aSmrg
34173143b9aSmrg    echo 1>&2 "\
34273143b9aSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34373143b9aSmrg         You may want to install GNU tar or Free paxutils, or check the
34473143b9aSmrg         command line arguments."
34573143b9aSmrg    exit 1
34673143b9aSmrg    ;;
34773143b9aSmrg
34873143b9aSmrg  *)
34973143b9aSmrg    echo 1>&2 "\
35073143b9aSmrgWARNING: \`$1' is needed, and is $msg.
35173143b9aSmrg         You might have modified some files without having the
35273143b9aSmrg         proper tools for further handling them.  Check the \`README' file,
35373143b9aSmrg         it often tells you about the needed prerequisites for installing
35473143b9aSmrg         this package.  You may also peek at any GNU archive site, in case
35573143b9aSmrg         some other package would contain this missing \`$1' program."
35673143b9aSmrg    exit 1
35773143b9aSmrg    ;;
35873143b9aSmrgesac
35973143b9aSmrg
36073143b9aSmrgexit 0
36173143b9aSmrg
36273143b9aSmrg# Local variables:
36373143b9aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36473143b9aSmrg# time-stamp-start: "scriptversion="
36573143b9aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36673143b9aSmrg# time-stamp-end: "$"
36773143b9aSmrg# End:
368