missing revision 66fe65f6
166fe65f6Smrg#! /bin/sh
266fe65f6Smrg# Common stub for a few missing GNU programs while installing.
366fe65f6Smrg
466fe65f6Smrgscriptversion=2005-06-08.21
566fe65f6Smrg
666fe65f6Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
766fe65f6Smrg#   Free Software Foundation, Inc.
866fe65f6Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
966fe65f6Smrg
1066fe65f6Smrg# This program is free software; you can redistribute it and/or modify
1166fe65f6Smrg# it under the terms of the GNU General Public License as published by
1266fe65f6Smrg# the Free Software Foundation; either version 2, or (at your option)
1366fe65f6Smrg# any later version.
1466fe65f6Smrg
1566fe65f6Smrg# This program is distributed in the hope that it will be useful,
1666fe65f6Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1766fe65f6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1866fe65f6Smrg# GNU General Public License for more details.
1966fe65f6Smrg
2066fe65f6Smrg# You should have received a copy of the GNU General Public License
2166fe65f6Smrg# along with this program; if not, write to the Free Software
2266fe65f6Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2366fe65f6Smrg# 02110-1301, USA.
2466fe65f6Smrg
2566fe65f6Smrg# As a special exception to the GNU General Public License, if you
2666fe65f6Smrg# distribute this file as part of a program that contains a
2766fe65f6Smrg# configuration script generated by Autoconf, you may include it under
2866fe65f6Smrg# the same distribution terms that you use for the rest of that program.
2966fe65f6Smrg
3066fe65f6Smrgif test $# -eq 0; then
3166fe65f6Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3266fe65f6Smrg  exit 1
3366fe65f6Smrgfi
3466fe65f6Smrg
3566fe65f6Smrgrun=:
3666fe65f6Smrg
3766fe65f6Smrg# In the cases where this matters, `missing' is being run in the
3866fe65f6Smrg# srcdir already.
3966fe65f6Smrgif test -f configure.ac; then
4066fe65f6Smrg  configure_ac=configure.ac
4166fe65f6Smrgelse
4266fe65f6Smrg  configure_ac=configure.in
4366fe65f6Smrgfi
4466fe65f6Smrg
4566fe65f6Smrgmsg="missing on your system"
4666fe65f6Smrg
4766fe65f6Smrgcase "$1" in
4866fe65f6Smrg--run)
4966fe65f6Smrg  # Try to run requested program, and just exit if it succeeds.
5066fe65f6Smrg  run=
5166fe65f6Smrg  shift
5266fe65f6Smrg  "$@" && exit 0
5366fe65f6Smrg  # Exit code 63 means version mismatch.  This often happens
5466fe65f6Smrg  # when the user try to use an ancient version of a tool on
5566fe65f6Smrg  # a file that requires a minimum version.  In this case we
5666fe65f6Smrg  # we should proceed has if the program had been absent, or
5766fe65f6Smrg  # if --run hadn't been passed.
5866fe65f6Smrg  if test $? = 63; then
5966fe65f6Smrg    run=:
6066fe65f6Smrg    msg="probably too old"
6166fe65f6Smrg  fi
6266fe65f6Smrg  ;;
6366fe65f6Smrg
6466fe65f6Smrg  -h|--h|--he|--hel|--help)
6566fe65f6Smrg    echo "\
6666fe65f6Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6766fe65f6Smrg
6866fe65f6SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6966fe65f6Smrgerror status if there is no known handling for PROGRAM.
7066fe65f6Smrg
7166fe65f6SmrgOptions:
7266fe65f6Smrg  -h, --help      display this help and exit
7366fe65f6Smrg  -v, --version   output version information and exit
7466fe65f6Smrg  --run           try to run the given command, and emulate it if it fails
7566fe65f6Smrg
7666fe65f6SmrgSupported PROGRAM values:
7766fe65f6Smrg  aclocal      touch file \`aclocal.m4'
7866fe65f6Smrg  autoconf     touch file \`configure'
7966fe65f6Smrg  autoheader   touch file \`config.h.in'
8066fe65f6Smrg  automake     touch all \`Makefile.in' files
8166fe65f6Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8266fe65f6Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8366fe65f6Smrg  help2man     touch the output file
8466fe65f6Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8566fe65f6Smrg  makeinfo     touch the output file
8666fe65f6Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8766fe65f6Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8866fe65f6Smrg
8966fe65f6SmrgSend bug reports to <bug-automake@gnu.org>."
9066fe65f6Smrg    exit $?
9166fe65f6Smrg    ;;
9266fe65f6Smrg
9366fe65f6Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9466fe65f6Smrg    echo "missing $scriptversion (GNU Automake)"
9566fe65f6Smrg    exit $?
9666fe65f6Smrg    ;;
9766fe65f6Smrg
9866fe65f6Smrg  -*)
9966fe65f6Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10066fe65f6Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10166fe65f6Smrg    exit 1
10266fe65f6Smrg    ;;
10366fe65f6Smrg
10466fe65f6Smrgesac
10566fe65f6Smrg
10666fe65f6Smrg# Now exit if we have it, but it failed.  Also exit now if we
10766fe65f6Smrg# don't have it and --version was passed (most likely to detect
10866fe65f6Smrg# the program).
10966fe65f6Smrgcase "$1" in
11066fe65f6Smrg  lex|yacc)
11166fe65f6Smrg    # Not GNU programs, they don't have --version.
11266fe65f6Smrg    ;;
11366fe65f6Smrg
11466fe65f6Smrg  tar)
11566fe65f6Smrg    if test -n "$run"; then
11666fe65f6Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
11766fe65f6Smrg       exit 1
11866fe65f6Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
11966fe65f6Smrg       exit 1
12066fe65f6Smrg    fi
12166fe65f6Smrg    ;;
12266fe65f6Smrg
12366fe65f6Smrg  *)
12466fe65f6Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12566fe65f6Smrg       # We have it, but it failed.
12666fe65f6Smrg       exit 1
12766fe65f6Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12866fe65f6Smrg       # Could not run --version or --help.  This is probably someone
12966fe65f6Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13066fe65f6Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13166fe65f6Smrg       exit 1
13266fe65f6Smrg    fi
13366fe65f6Smrg    ;;
13466fe65f6Smrgesac
13566fe65f6Smrg
13666fe65f6Smrg# If it does not exist, or fails to run (possibly an outdated version),
13766fe65f6Smrg# try to emulate it.
13866fe65f6Smrgcase "$1" in
13966fe65f6Smrg  aclocal*)
14066fe65f6Smrg    echo 1>&2 "\
14166fe65f6SmrgWARNING: \`$1' is $msg.  You should only need it if
14266fe65f6Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14366fe65f6Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14466fe65f6Smrg         any GNU archive site."
14566fe65f6Smrg    touch aclocal.m4
14666fe65f6Smrg    ;;
14766fe65f6Smrg
14866fe65f6Smrg  autoconf)
14966fe65f6Smrg    echo 1>&2 "\
15066fe65f6SmrgWARNING: \`$1' is $msg.  You should only need it if
15166fe65f6Smrg         you modified \`${configure_ac}'.  You might want to install the
15266fe65f6Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15366fe65f6Smrg         archive site."
15466fe65f6Smrg    touch configure
15566fe65f6Smrg    ;;
15666fe65f6Smrg
15766fe65f6Smrg  autoheader)
15866fe65f6Smrg    echo 1>&2 "\
15966fe65f6SmrgWARNING: \`$1' is $msg.  You should only need it if
16066fe65f6Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16166fe65f6Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16266fe65f6Smrg         from any GNU archive site."
16366fe65f6Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16466fe65f6Smrg    test -z "$files" && files="config.h"
16566fe65f6Smrg    touch_files=
16666fe65f6Smrg    for f in $files; do
16766fe65f6Smrg      case "$f" in
16866fe65f6Smrg      *:*) touch_files="$touch_files "`echo "$f" |
16966fe65f6Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17066fe65f6Smrg      *) touch_files="$touch_files $f.in";;
17166fe65f6Smrg      esac
17266fe65f6Smrg    done
17366fe65f6Smrg    touch $touch_files
17466fe65f6Smrg    ;;
17566fe65f6Smrg
17666fe65f6Smrg  automake*)
17766fe65f6Smrg    echo 1>&2 "\
17866fe65f6SmrgWARNING: \`$1' is $msg.  You should only need it if
17966fe65f6Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18066fe65f6Smrg         You might want to install the \`Automake' and \`Perl' packages.
18166fe65f6Smrg         Grab them from any GNU archive site."
18266fe65f6Smrg    find . -type f -name Makefile.am -print |
18366fe65f6Smrg	   sed 's/\.am$/.in/' |
18466fe65f6Smrg	   while read f; do touch "$f"; done
18566fe65f6Smrg    ;;
18666fe65f6Smrg
18766fe65f6Smrg  autom4te)
18866fe65f6Smrg    echo 1>&2 "\
18966fe65f6SmrgWARNING: \`$1' is needed, but is $msg.
19066fe65f6Smrg         You might have modified some files without having the
19166fe65f6Smrg         proper tools for further handling them.
19266fe65f6Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19366fe65f6Smrg         archive site."
19466fe65f6Smrg
19566fe65f6Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
19666fe65f6Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
19766fe65f6Smrg    if test -f "$file"; then
19866fe65f6Smrg	touch $file
19966fe65f6Smrg    else
20066fe65f6Smrg	test -z "$file" || exec >$file
20166fe65f6Smrg	echo "#! /bin/sh"
20266fe65f6Smrg	echo "# Created by GNU Automake missing as a replacement of"
20366fe65f6Smrg	echo "#  $ $@"
20466fe65f6Smrg	echo "exit 0"
20566fe65f6Smrg	chmod +x $file
20666fe65f6Smrg	exit 1
20766fe65f6Smrg    fi
20866fe65f6Smrg    ;;
20966fe65f6Smrg
21066fe65f6Smrg  bison|yacc)
21166fe65f6Smrg    echo 1>&2 "\
21266fe65f6SmrgWARNING: \`$1' $msg.  You should only need it if
21366fe65f6Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21466fe65f6Smrg         in order for those modifications to take effect.  You can get
21566fe65f6Smrg         \`Bison' from any GNU archive site."
21666fe65f6Smrg    rm -f y.tab.c y.tab.h
21766fe65f6Smrg    if [ $# -ne 1 ]; then
21866fe65f6Smrg        eval LASTARG="\${$#}"
21966fe65f6Smrg	case "$LASTARG" in
22066fe65f6Smrg	*.y)
22166fe65f6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22266fe65f6Smrg	    if [ -f "$SRCFILE" ]; then
22366fe65f6Smrg	         cp "$SRCFILE" y.tab.c
22466fe65f6Smrg	    fi
22566fe65f6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22666fe65f6Smrg	    if [ -f "$SRCFILE" ]; then
22766fe65f6Smrg	         cp "$SRCFILE" y.tab.h
22866fe65f6Smrg	    fi
22966fe65f6Smrg	  ;;
23066fe65f6Smrg	esac
23166fe65f6Smrg    fi
23266fe65f6Smrg    if [ ! -f y.tab.h ]; then
23366fe65f6Smrg	echo >y.tab.h
23466fe65f6Smrg    fi
23566fe65f6Smrg    if [ ! -f y.tab.c ]; then
23666fe65f6Smrg	echo 'main() { return 0; }' >y.tab.c
23766fe65f6Smrg    fi
23866fe65f6Smrg    ;;
23966fe65f6Smrg
24066fe65f6Smrg  lex|flex)
24166fe65f6Smrg    echo 1>&2 "\
24266fe65f6SmrgWARNING: \`$1' is $msg.  You should only need it if
24366fe65f6Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24466fe65f6Smrg         in order for those modifications to take effect.  You can get
24566fe65f6Smrg         \`Flex' from any GNU archive site."
24666fe65f6Smrg    rm -f lex.yy.c
24766fe65f6Smrg    if [ $# -ne 1 ]; then
24866fe65f6Smrg        eval LASTARG="\${$#}"
24966fe65f6Smrg	case "$LASTARG" in
25066fe65f6Smrg	*.l)
25166fe65f6Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25266fe65f6Smrg	    if [ -f "$SRCFILE" ]; then
25366fe65f6Smrg	         cp "$SRCFILE" lex.yy.c
25466fe65f6Smrg	    fi
25566fe65f6Smrg	  ;;
25666fe65f6Smrg	esac
25766fe65f6Smrg    fi
25866fe65f6Smrg    if [ ! -f lex.yy.c ]; then
25966fe65f6Smrg	echo 'main() { return 0; }' >lex.yy.c
26066fe65f6Smrg    fi
26166fe65f6Smrg    ;;
26266fe65f6Smrg
26366fe65f6Smrg  help2man)
26466fe65f6Smrg    echo 1>&2 "\
26566fe65f6SmrgWARNING: \`$1' is $msg.  You should only need it if
26666fe65f6Smrg	 you modified a dependency of a manual page.  You may need the
26766fe65f6Smrg	 \`Help2man' package in order for those modifications to take
26866fe65f6Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
26966fe65f6Smrg
27066fe65f6Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27166fe65f6Smrg    if test -z "$file"; then
27266fe65f6Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27366fe65f6Smrg    fi
27466fe65f6Smrg    if [ -f "$file" ]; then
27566fe65f6Smrg	touch $file
27666fe65f6Smrg    else
27766fe65f6Smrg	test -z "$file" || exec >$file
27866fe65f6Smrg	echo ".ab help2man is required to generate this page"
27966fe65f6Smrg	exit 1
28066fe65f6Smrg    fi
28166fe65f6Smrg    ;;
28266fe65f6Smrg
28366fe65f6Smrg  makeinfo)
28466fe65f6Smrg    echo 1>&2 "\
28566fe65f6SmrgWARNING: \`$1' is $msg.  You should only need it if
28666fe65f6Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28766fe65f6Smrg         indirectly affecting the aspect of the manual.  The spurious
28866fe65f6Smrg         call might also be the consequence of using a buggy \`make' (AIX,
28966fe65f6Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29066fe65f6Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29166fe65f6Smrg    # The file to touch is that specified with -o ...
29266fe65f6Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29366fe65f6Smrg    if test -z "$file"; then
29466fe65f6Smrg      # ... or it is the one specified with @setfilename ...
29566fe65f6Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29666fe65f6Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
29766fe65f6Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
29866fe65f6Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29966fe65f6Smrg    fi
30066fe65f6Smrg    # If the file does not exist, the user really needs makeinfo;
30166fe65f6Smrg    # let's fail without touching anything.
30266fe65f6Smrg    test -f $file || exit 1
30366fe65f6Smrg    touch $file
30466fe65f6Smrg    ;;
30566fe65f6Smrg
30666fe65f6Smrg  tar)
30766fe65f6Smrg    shift
30866fe65f6Smrg
30966fe65f6Smrg    # We have already tried tar in the generic part.
31066fe65f6Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31166fe65f6Smrg    # messages.
31266fe65f6Smrg    if (gnutar --version > /dev/null 2>&1); then
31366fe65f6Smrg       gnutar "$@" && exit 0
31466fe65f6Smrg    fi
31566fe65f6Smrg    if (gtar --version > /dev/null 2>&1); then
31666fe65f6Smrg       gtar "$@" && exit 0
31766fe65f6Smrg    fi
31866fe65f6Smrg    firstarg="$1"
31966fe65f6Smrg    if shift; then
32066fe65f6Smrg	case "$firstarg" in
32166fe65f6Smrg	*o*)
32266fe65f6Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
32366fe65f6Smrg	    tar "$firstarg" "$@" && exit 0
32466fe65f6Smrg	    ;;
32566fe65f6Smrg	esac
32666fe65f6Smrg	case "$firstarg" in
32766fe65f6Smrg	*h*)
32866fe65f6Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
32966fe65f6Smrg	    tar "$firstarg" "$@" && exit 0
33066fe65f6Smrg	    ;;
33166fe65f6Smrg	esac
33266fe65f6Smrg    fi
33366fe65f6Smrg
33466fe65f6Smrg    echo 1>&2 "\
33566fe65f6SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
33666fe65f6Smrg         You may want to install GNU tar or Free paxutils, or check the
33766fe65f6Smrg         command line arguments."
33866fe65f6Smrg    exit 1
33966fe65f6Smrg    ;;
34066fe65f6Smrg
34166fe65f6Smrg  *)
34266fe65f6Smrg    echo 1>&2 "\
34366fe65f6SmrgWARNING: \`$1' is needed, and is $msg.
34466fe65f6Smrg         You might have modified some files without having the
34566fe65f6Smrg         proper tools for further handling them.  Check the \`README' file,
34666fe65f6Smrg         it often tells you about the needed prerequisites for installing
34766fe65f6Smrg         this package.  You may also peek at any GNU archive site, in case
34866fe65f6Smrg         some other package would contain this missing \`$1' program."
34966fe65f6Smrg    exit 1
35066fe65f6Smrg    ;;
35166fe65f6Smrgesac
35266fe65f6Smrg
35366fe65f6Smrgexit 0
35466fe65f6Smrg
35566fe65f6Smrg# Local variables:
35666fe65f6Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
35766fe65f6Smrg# time-stamp-start: "scriptversion="
35866fe65f6Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
35966fe65f6Smrg# time-stamp-end: "$"
36066fe65f6Smrg# End:
361