missing revision 52f9793f
152f9793fSmrg#! /bin/sh
252f9793fSmrg# Common stub for a few missing GNU programs while installing.
352f9793fSmrg
452f9793fSmrgscriptversion=2005-06-08.21
552f9793fSmrg
652f9793fSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
752f9793fSmrg#   Free Software Foundation, Inc.
852f9793fSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
952f9793fSmrg
1052f9793fSmrg# This program is free software; you can redistribute it and/or modify
1152f9793fSmrg# it under the terms of the GNU General Public License as published by
1252f9793fSmrg# the Free Software Foundation; either version 2, or (at your option)
1352f9793fSmrg# any later version.
1452f9793fSmrg
1552f9793fSmrg# This program is distributed in the hope that it will be useful,
1652f9793fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1752f9793fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1852f9793fSmrg# GNU General Public License for more details.
1952f9793fSmrg
2052f9793fSmrg# You should have received a copy of the GNU General Public License
2152f9793fSmrg# along with this program; if not, write to the Free Software
2252f9793fSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2352f9793fSmrg# 02110-1301, USA.
2452f9793fSmrg
2552f9793fSmrg# As a special exception to the GNU General Public License, if you
2652f9793fSmrg# distribute this file as part of a program that contains a
2752f9793fSmrg# configuration script generated by Autoconf, you may include it under
2852f9793fSmrg# the same distribution terms that you use for the rest of that program.
2952f9793fSmrg
3052f9793fSmrgif test $# -eq 0; then
3152f9793fSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3252f9793fSmrg  exit 1
3352f9793fSmrgfi
3452f9793fSmrg
3552f9793fSmrgrun=:
3652f9793fSmrg
3752f9793fSmrg# In the cases where this matters, `missing' is being run in the
3852f9793fSmrg# srcdir already.
3952f9793fSmrgif test -f configure.ac; then
4052f9793fSmrg  configure_ac=configure.ac
4152f9793fSmrgelse
4252f9793fSmrg  configure_ac=configure.in
4352f9793fSmrgfi
4452f9793fSmrg
4552f9793fSmrgmsg="missing on your system"
4652f9793fSmrg
4752f9793fSmrgcase "$1" in
4852f9793fSmrg--run)
4952f9793fSmrg  # Try to run requested program, and just exit if it succeeds.
5052f9793fSmrg  run=
5152f9793fSmrg  shift
5252f9793fSmrg  "$@" && exit 0
5352f9793fSmrg  # Exit code 63 means version mismatch.  This often happens
5452f9793fSmrg  # when the user try to use an ancient version of a tool on
5552f9793fSmrg  # a file that requires a minimum version.  In this case we
5652f9793fSmrg  # we should proceed has if the program had been absent, or
5752f9793fSmrg  # if --run hadn't been passed.
5852f9793fSmrg  if test $? = 63; then
5952f9793fSmrg    run=:
6052f9793fSmrg    msg="probably too old"
6152f9793fSmrg  fi
6252f9793fSmrg  ;;
6352f9793fSmrg
6452f9793fSmrg  -h|--h|--he|--hel|--help)
6552f9793fSmrg    echo "\
6652f9793fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6752f9793fSmrg
6852f9793fSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6952f9793fSmrgerror status if there is no known handling for PROGRAM.
7052f9793fSmrg
7152f9793fSmrgOptions:
7252f9793fSmrg  -h, --help      display this help and exit
7352f9793fSmrg  -v, --version   output version information and exit
7452f9793fSmrg  --run           try to run the given command, and emulate it if it fails
7552f9793fSmrg
7652f9793fSmrgSupported PROGRAM values:
7752f9793fSmrg  aclocal      touch file \`aclocal.m4'
7852f9793fSmrg  autoconf     touch file \`configure'
7952f9793fSmrg  autoheader   touch file \`config.h.in'
8052f9793fSmrg  automake     touch all \`Makefile.in' files
8152f9793fSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8252f9793fSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8352f9793fSmrg  help2man     touch the output file
8452f9793fSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8552f9793fSmrg  makeinfo     touch the output file
8652f9793fSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8752f9793fSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8852f9793fSmrg
8952f9793fSmrgSend bug reports to <bug-automake@gnu.org>."
9052f9793fSmrg    exit $?
9152f9793fSmrg    ;;
9252f9793fSmrg
9352f9793fSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9452f9793fSmrg    echo "missing $scriptversion (GNU Automake)"
9552f9793fSmrg    exit $?
9652f9793fSmrg    ;;
9752f9793fSmrg
9852f9793fSmrg  -*)
9952f9793fSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10052f9793fSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10152f9793fSmrg    exit 1
10252f9793fSmrg    ;;
10352f9793fSmrg
10452f9793fSmrgesac
10552f9793fSmrg
10652f9793fSmrg# Now exit if we have it, but it failed.  Also exit now if we
10752f9793fSmrg# don't have it and --version was passed (most likely to detect
10852f9793fSmrg# the program).
10952f9793fSmrgcase "$1" in
11052f9793fSmrg  lex|yacc)
11152f9793fSmrg    # Not GNU programs, they don't have --version.
11252f9793fSmrg    ;;
11352f9793fSmrg
11452f9793fSmrg  tar)
11552f9793fSmrg    if test -n "$run"; then
11652f9793fSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
11752f9793fSmrg       exit 1
11852f9793fSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
11952f9793fSmrg       exit 1
12052f9793fSmrg    fi
12152f9793fSmrg    ;;
12252f9793fSmrg
12352f9793fSmrg  *)
12452f9793fSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12552f9793fSmrg       # We have it, but it failed.
12652f9793fSmrg       exit 1
12752f9793fSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12852f9793fSmrg       # Could not run --version or --help.  This is probably someone
12952f9793fSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13052f9793fSmrg       # $TOOL exists and not knowing $TOOL uses missing.
13152f9793fSmrg       exit 1
13252f9793fSmrg    fi
13352f9793fSmrg    ;;
13452f9793fSmrgesac
13552f9793fSmrg
13652f9793fSmrg# If it does not exist, or fails to run (possibly an outdated version),
13752f9793fSmrg# try to emulate it.
13852f9793fSmrgcase "$1" in
13952f9793fSmrg  aclocal*)
14052f9793fSmrg    echo 1>&2 "\
14152f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
14252f9793fSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14352f9793fSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14452f9793fSmrg         any GNU archive site."
14552f9793fSmrg    touch aclocal.m4
14652f9793fSmrg    ;;
14752f9793fSmrg
14852f9793fSmrg  autoconf)
14952f9793fSmrg    echo 1>&2 "\
15052f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
15152f9793fSmrg         you modified \`${configure_ac}'.  You might want to install the
15252f9793fSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15352f9793fSmrg         archive site."
15452f9793fSmrg    touch configure
15552f9793fSmrg    ;;
15652f9793fSmrg
15752f9793fSmrg  autoheader)
15852f9793fSmrg    echo 1>&2 "\
15952f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
16052f9793fSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16152f9793fSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16252f9793fSmrg         from any GNU archive site."
16352f9793fSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16452f9793fSmrg    test -z "$files" && files="config.h"
16552f9793fSmrg    touch_files=
16652f9793fSmrg    for f in $files; do
16752f9793fSmrg      case "$f" in
16852f9793fSmrg      *:*) touch_files="$touch_files "`echo "$f" |
16952f9793fSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17052f9793fSmrg      *) touch_files="$touch_files $f.in";;
17152f9793fSmrg      esac
17252f9793fSmrg    done
17352f9793fSmrg    touch $touch_files
17452f9793fSmrg    ;;
17552f9793fSmrg
17652f9793fSmrg  automake*)
17752f9793fSmrg    echo 1>&2 "\
17852f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
17952f9793fSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18052f9793fSmrg         You might want to install the \`Automake' and \`Perl' packages.
18152f9793fSmrg         Grab them from any GNU archive site."
18252f9793fSmrg    find . -type f -name Makefile.am -print |
18352f9793fSmrg	   sed 's/\.am$/.in/' |
18452f9793fSmrg	   while read f; do touch "$f"; done
18552f9793fSmrg    ;;
18652f9793fSmrg
18752f9793fSmrg  autom4te)
18852f9793fSmrg    echo 1>&2 "\
18952f9793fSmrgWARNING: \`$1' is needed, but is $msg.
19052f9793fSmrg         You might have modified some files without having the
19152f9793fSmrg         proper tools for further handling them.
19252f9793fSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
19352f9793fSmrg         archive site."
19452f9793fSmrg
19552f9793fSmrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
19652f9793fSmrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
19752f9793fSmrg    if test -f "$file"; then
19852f9793fSmrg	touch $file
19952f9793fSmrg    else
20052f9793fSmrg	test -z "$file" || exec >$file
20152f9793fSmrg	echo "#! /bin/sh"
20252f9793fSmrg	echo "# Created by GNU Automake missing as a replacement of"
20352f9793fSmrg	echo "#  $ $@"
20452f9793fSmrg	echo "exit 0"
20552f9793fSmrg	chmod +x $file
20652f9793fSmrg	exit 1
20752f9793fSmrg    fi
20852f9793fSmrg    ;;
20952f9793fSmrg
21052f9793fSmrg  bison|yacc)
21152f9793fSmrg    echo 1>&2 "\
21252f9793fSmrgWARNING: \`$1' $msg.  You should only need it if
21352f9793fSmrg         you modified a \`.y' file.  You may need the \`Bison' package
21452f9793fSmrg         in order for those modifications to take effect.  You can get
21552f9793fSmrg         \`Bison' from any GNU archive site."
21652f9793fSmrg    rm -f y.tab.c y.tab.h
21752f9793fSmrg    if [ $# -ne 1 ]; then
21852f9793fSmrg        eval LASTARG="\${$#}"
21952f9793fSmrg	case "$LASTARG" in
22052f9793fSmrg	*.y)
22152f9793fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22252f9793fSmrg	    if [ -f "$SRCFILE" ]; then
22352f9793fSmrg	         cp "$SRCFILE" y.tab.c
22452f9793fSmrg	    fi
22552f9793fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22652f9793fSmrg	    if [ -f "$SRCFILE" ]; then
22752f9793fSmrg	         cp "$SRCFILE" y.tab.h
22852f9793fSmrg	    fi
22952f9793fSmrg	  ;;
23052f9793fSmrg	esac
23152f9793fSmrg    fi
23252f9793fSmrg    if [ ! -f y.tab.h ]; then
23352f9793fSmrg	echo >y.tab.h
23452f9793fSmrg    fi
23552f9793fSmrg    if [ ! -f y.tab.c ]; then
23652f9793fSmrg	echo 'main() { return 0; }' >y.tab.c
23752f9793fSmrg    fi
23852f9793fSmrg    ;;
23952f9793fSmrg
24052f9793fSmrg  lex|flex)
24152f9793fSmrg    echo 1>&2 "\
24252f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
24352f9793fSmrg         you modified a \`.l' file.  You may need the \`Flex' package
24452f9793fSmrg         in order for those modifications to take effect.  You can get
24552f9793fSmrg         \`Flex' from any GNU archive site."
24652f9793fSmrg    rm -f lex.yy.c
24752f9793fSmrg    if [ $# -ne 1 ]; then
24852f9793fSmrg        eval LASTARG="\${$#}"
24952f9793fSmrg	case "$LASTARG" in
25052f9793fSmrg	*.l)
25152f9793fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25252f9793fSmrg	    if [ -f "$SRCFILE" ]; then
25352f9793fSmrg	         cp "$SRCFILE" lex.yy.c
25452f9793fSmrg	    fi
25552f9793fSmrg	  ;;
25652f9793fSmrg	esac
25752f9793fSmrg    fi
25852f9793fSmrg    if [ ! -f lex.yy.c ]; then
25952f9793fSmrg	echo 'main() { return 0; }' >lex.yy.c
26052f9793fSmrg    fi
26152f9793fSmrg    ;;
26252f9793fSmrg
26352f9793fSmrg  help2man)
26452f9793fSmrg    echo 1>&2 "\
26552f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
26652f9793fSmrg	 you modified a dependency of a manual page.  You may need the
26752f9793fSmrg	 \`Help2man' package in order for those modifications to take
26852f9793fSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
26952f9793fSmrg
27052f9793fSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27152f9793fSmrg    if test -z "$file"; then
27252f9793fSmrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27352f9793fSmrg    fi
27452f9793fSmrg    if [ -f "$file" ]; then
27552f9793fSmrg	touch $file
27652f9793fSmrg    else
27752f9793fSmrg	test -z "$file" || exec >$file
27852f9793fSmrg	echo ".ab help2man is required to generate this page"
27952f9793fSmrg	exit 1
28052f9793fSmrg    fi
28152f9793fSmrg    ;;
28252f9793fSmrg
28352f9793fSmrg  makeinfo)
28452f9793fSmrg    echo 1>&2 "\
28552f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
28652f9793fSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28752f9793fSmrg         indirectly affecting the aspect of the manual.  The spurious
28852f9793fSmrg         call might also be the consequence of using a buggy \`make' (AIX,
28952f9793fSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29052f9793fSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
29152f9793fSmrg    # The file to touch is that specified with -o ...
29252f9793fSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29352f9793fSmrg    if test -z "$file"; then
29452f9793fSmrg      # ... or it is the one specified with @setfilename ...
29552f9793fSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29652f9793fSmrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
29752f9793fSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
29852f9793fSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29952f9793fSmrg    fi
30052f9793fSmrg    # If the file does not exist, the user really needs makeinfo;
30152f9793fSmrg    # let's fail without touching anything.
30252f9793fSmrg    test -f $file || exit 1
30352f9793fSmrg    touch $file
30452f9793fSmrg    ;;
30552f9793fSmrg
30652f9793fSmrg  tar)
30752f9793fSmrg    shift
30852f9793fSmrg
30952f9793fSmrg    # We have already tried tar in the generic part.
31052f9793fSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
31152f9793fSmrg    # messages.
31252f9793fSmrg    if (gnutar --version > /dev/null 2>&1); then
31352f9793fSmrg       gnutar "$@" && exit 0
31452f9793fSmrg    fi
31552f9793fSmrg    if (gtar --version > /dev/null 2>&1); then
31652f9793fSmrg       gtar "$@" && exit 0
31752f9793fSmrg    fi
31852f9793fSmrg    firstarg="$1"
31952f9793fSmrg    if shift; then
32052f9793fSmrg	case "$firstarg" in
32152f9793fSmrg	*o*)
32252f9793fSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
32352f9793fSmrg	    tar "$firstarg" "$@" && exit 0
32452f9793fSmrg	    ;;
32552f9793fSmrg	esac
32652f9793fSmrg	case "$firstarg" in
32752f9793fSmrg	*h*)
32852f9793fSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
32952f9793fSmrg	    tar "$firstarg" "$@" && exit 0
33052f9793fSmrg	    ;;
33152f9793fSmrg	esac
33252f9793fSmrg    fi
33352f9793fSmrg
33452f9793fSmrg    echo 1>&2 "\
33552f9793fSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
33652f9793fSmrg         You may want to install GNU tar or Free paxutils, or check the
33752f9793fSmrg         command line arguments."
33852f9793fSmrg    exit 1
33952f9793fSmrg    ;;
34052f9793fSmrg
34152f9793fSmrg  *)
34252f9793fSmrg    echo 1>&2 "\
34352f9793fSmrgWARNING: \`$1' is needed, and is $msg.
34452f9793fSmrg         You might have modified some files without having the
34552f9793fSmrg         proper tools for further handling them.  Check the \`README' file,
34652f9793fSmrg         it often tells you about the needed prerequisites for installing
34752f9793fSmrg         this package.  You may also peek at any GNU archive site, in case
34852f9793fSmrg         some other package would contain this missing \`$1' program."
34952f9793fSmrg    exit 1
35052f9793fSmrg    ;;
35152f9793fSmrgesac
35252f9793fSmrg
35352f9793fSmrgexit 0
35452f9793fSmrg
35552f9793fSmrg# Local variables:
35652f9793fSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
35752f9793fSmrg# time-stamp-start: "scriptversion="
35852f9793fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
35952f9793fSmrg# time-stamp-end: "$"
36052f9793fSmrg# End:
361