missing revision 7965d9ac
150806d53Smrg#! /bin/sh
250806d53Smrg# Common stub for a few missing GNU programs while installing.
350806d53Smrg
47965d9acSmrgscriptversion=2006-05-10.23
550806d53Smrg
67965d9acSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
750806d53Smrg#   Free Software Foundation, Inc.
850806d53Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
950806d53Smrg
1050806d53Smrg# This program is free software; you can redistribute it and/or modify
1150806d53Smrg# it under the terms of the GNU General Public License as published by
1250806d53Smrg# the Free Software Foundation; either version 2, or (at your option)
1350806d53Smrg# any later version.
1450806d53Smrg
1550806d53Smrg# This program is distributed in the hope that it will be useful,
1650806d53Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1750806d53Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1850806d53Smrg# GNU General Public License for more details.
1950806d53Smrg
2050806d53Smrg# You should have received a copy of the GNU General Public License
2150806d53Smrg# along with this program; if not, write to the Free Software
2250806d53Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2350806d53Smrg# 02110-1301, USA.
2450806d53Smrg
2550806d53Smrg# As a special exception to the GNU General Public License, if you
2650806d53Smrg# distribute this file as part of a program that contains a
2750806d53Smrg# configuration script generated by Autoconf, you may include it under
2850806d53Smrg# the same distribution terms that you use for the rest of that program.
2950806d53Smrg
3050806d53Smrgif test $# -eq 0; then
3150806d53Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3250806d53Smrg  exit 1
3350806d53Smrgfi
3450806d53Smrg
3550806d53Smrgrun=:
367965d9acSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
377965d9acSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3850806d53Smrg
3950806d53Smrg# In the cases where this matters, `missing' is being run in the
4050806d53Smrg# srcdir already.
4150806d53Smrgif test -f configure.ac; then
4250806d53Smrg  configure_ac=configure.ac
4350806d53Smrgelse
4450806d53Smrg  configure_ac=configure.in
4550806d53Smrgfi
4650806d53Smrg
4750806d53Smrgmsg="missing on your system"
4850806d53Smrg
497965d9acSmrgcase $1 in
5050806d53Smrg--run)
5150806d53Smrg  # Try to run requested program, and just exit if it succeeds.
5250806d53Smrg  run=
5350806d53Smrg  shift
5450806d53Smrg  "$@" && exit 0
5550806d53Smrg  # Exit code 63 means version mismatch.  This often happens
5650806d53Smrg  # when the user try to use an ancient version of a tool on
5750806d53Smrg  # a file that requires a minimum version.  In this case we
5850806d53Smrg  # we should proceed has if the program had been absent, or
5950806d53Smrg  # if --run hadn't been passed.
6050806d53Smrg  if test $? = 63; then
6150806d53Smrg    run=:
6250806d53Smrg    msg="probably too old"
6350806d53Smrg  fi
6450806d53Smrg  ;;
6550806d53Smrg
6650806d53Smrg  -h|--h|--he|--hel|--help)
6750806d53Smrg    echo "\
6850806d53Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6950806d53Smrg
7050806d53SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7150806d53Smrgerror status if there is no known handling for PROGRAM.
7250806d53Smrg
7350806d53SmrgOptions:
7450806d53Smrg  -h, --help      display this help and exit
7550806d53Smrg  -v, --version   output version information and exit
7650806d53Smrg  --run           try to run the given command, and emulate it if it fails
7750806d53Smrg
7850806d53SmrgSupported PROGRAM values:
7950806d53Smrg  aclocal      touch file \`aclocal.m4'
8050806d53Smrg  autoconf     touch file \`configure'
8150806d53Smrg  autoheader   touch file \`config.h.in'
827965d9acSmrg  autom4te     touch the output file, or create a stub one
8350806d53Smrg  automake     touch all \`Makefile.in' files
8450806d53Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8550806d53Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8650806d53Smrg  help2man     touch the output file
8750806d53Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8850806d53Smrg  makeinfo     touch the output file
8950806d53Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9050806d53Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9150806d53Smrg
9250806d53SmrgSend bug reports to <bug-automake@gnu.org>."
9350806d53Smrg    exit $?
9450806d53Smrg    ;;
9550806d53Smrg
9650806d53Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9750806d53Smrg    echo "missing $scriptversion (GNU Automake)"
9850806d53Smrg    exit $?
9950806d53Smrg    ;;
10050806d53Smrg
10150806d53Smrg  -*)
10250806d53Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10350806d53Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10450806d53Smrg    exit 1
10550806d53Smrg    ;;
10650806d53Smrg
10750806d53Smrgesac
10850806d53Smrg
10950806d53Smrg# Now exit if we have it, but it failed.  Also exit now if we
11050806d53Smrg# don't have it and --version was passed (most likely to detect
11150806d53Smrg# the program).
1127965d9acSmrgcase $1 in
11350806d53Smrg  lex|yacc)
11450806d53Smrg    # Not GNU programs, they don't have --version.
11550806d53Smrg    ;;
11650806d53Smrg
11750806d53Smrg  tar)
11850806d53Smrg    if test -n "$run"; then
11950806d53Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12050806d53Smrg       exit 1
12150806d53Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12250806d53Smrg       exit 1
12350806d53Smrg    fi
12450806d53Smrg    ;;
12550806d53Smrg
12650806d53Smrg  *)
12750806d53Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12850806d53Smrg       # We have it, but it failed.
12950806d53Smrg       exit 1
13050806d53Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13150806d53Smrg       # Could not run --version or --help.  This is probably someone
13250806d53Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13350806d53Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13450806d53Smrg       exit 1
13550806d53Smrg    fi
13650806d53Smrg    ;;
13750806d53Smrgesac
13850806d53Smrg
13950806d53Smrg# If it does not exist, or fails to run (possibly an outdated version),
14050806d53Smrg# try to emulate it.
1417965d9acSmrgcase $1 in
14250806d53Smrg  aclocal*)
14350806d53Smrg    echo 1>&2 "\
14450806d53SmrgWARNING: \`$1' is $msg.  You should only need it if
14550806d53Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14650806d53Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14750806d53Smrg         any GNU archive site."
14850806d53Smrg    touch aclocal.m4
14950806d53Smrg    ;;
15050806d53Smrg
15150806d53Smrg  autoconf)
15250806d53Smrg    echo 1>&2 "\
15350806d53SmrgWARNING: \`$1' is $msg.  You should only need it if
15450806d53Smrg         you modified \`${configure_ac}'.  You might want to install the
15550806d53Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15650806d53Smrg         archive site."
15750806d53Smrg    touch configure
15850806d53Smrg    ;;
15950806d53Smrg
16050806d53Smrg  autoheader)
16150806d53Smrg    echo 1>&2 "\
16250806d53SmrgWARNING: \`$1' is $msg.  You should only need it if
16350806d53Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16450806d53Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16550806d53Smrg         from any GNU archive site."
16650806d53Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16750806d53Smrg    test -z "$files" && files="config.h"
16850806d53Smrg    touch_files=
16950806d53Smrg    for f in $files; do
1707965d9acSmrg      case $f in
17150806d53Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17250806d53Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17350806d53Smrg      *) touch_files="$touch_files $f.in";;
17450806d53Smrg      esac
17550806d53Smrg    done
17650806d53Smrg    touch $touch_files
17750806d53Smrg    ;;
17850806d53Smrg
17950806d53Smrg  automake*)
18050806d53Smrg    echo 1>&2 "\
18150806d53SmrgWARNING: \`$1' is $msg.  You should only need it if
18250806d53Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18350806d53Smrg         You might want to install the \`Automake' and \`Perl' packages.
18450806d53Smrg         Grab them from any GNU archive site."
18550806d53Smrg    find . -type f -name Makefile.am -print |
18650806d53Smrg	   sed 's/\.am$/.in/' |
18750806d53Smrg	   while read f; do touch "$f"; done
18850806d53Smrg    ;;
18950806d53Smrg
19050806d53Smrg  autom4te)
19150806d53Smrg    echo 1>&2 "\
19250806d53SmrgWARNING: \`$1' is needed, but is $msg.
19350806d53Smrg         You might have modified some files without having the
19450806d53Smrg         proper tools for further handling them.
19550806d53Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19650806d53Smrg         archive site."
19750806d53Smrg
1987965d9acSmrg    file=`echo "$*" | sed -n "$sed_output"`
1997965d9acSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20050806d53Smrg    if test -f "$file"; then
20150806d53Smrg	touch $file
20250806d53Smrg    else
20350806d53Smrg	test -z "$file" || exec >$file
20450806d53Smrg	echo "#! /bin/sh"
20550806d53Smrg	echo "# Created by GNU Automake missing as a replacement of"
20650806d53Smrg	echo "#  $ $@"
20750806d53Smrg	echo "exit 0"
20850806d53Smrg	chmod +x $file
20950806d53Smrg	exit 1
21050806d53Smrg    fi
21150806d53Smrg    ;;
21250806d53Smrg
21350806d53Smrg  bison|yacc)
21450806d53Smrg    echo 1>&2 "\
21550806d53SmrgWARNING: \`$1' $msg.  You should only need it if
21650806d53Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21750806d53Smrg         in order for those modifications to take effect.  You can get
21850806d53Smrg         \`Bison' from any GNU archive site."
21950806d53Smrg    rm -f y.tab.c y.tab.h
2207965d9acSmrg    if test $# -ne 1; then
22150806d53Smrg        eval LASTARG="\${$#}"
2227965d9acSmrg	case $LASTARG in
22350806d53Smrg	*.y)
22450806d53Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2257965d9acSmrg	    if test -f "$SRCFILE"; then
22650806d53Smrg	         cp "$SRCFILE" y.tab.c
22750806d53Smrg	    fi
22850806d53Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2297965d9acSmrg	    if test -f "$SRCFILE"; then
23050806d53Smrg	         cp "$SRCFILE" y.tab.h
23150806d53Smrg	    fi
23250806d53Smrg	  ;;
23350806d53Smrg	esac
23450806d53Smrg    fi
2357965d9acSmrg    if test ! -f y.tab.h; then
23650806d53Smrg	echo >y.tab.h
23750806d53Smrg    fi
2387965d9acSmrg    if test ! -f y.tab.c; then
23950806d53Smrg	echo 'main() { return 0; }' >y.tab.c
24050806d53Smrg    fi
24150806d53Smrg    ;;
24250806d53Smrg
24350806d53Smrg  lex|flex)
24450806d53Smrg    echo 1>&2 "\
24550806d53SmrgWARNING: \`$1' is $msg.  You should only need it if
24650806d53Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24750806d53Smrg         in order for those modifications to take effect.  You can get
24850806d53Smrg         \`Flex' from any GNU archive site."
24950806d53Smrg    rm -f lex.yy.c
2507965d9acSmrg    if test $# -ne 1; then
25150806d53Smrg        eval LASTARG="\${$#}"
2527965d9acSmrg	case $LASTARG in
25350806d53Smrg	*.l)
25450806d53Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2557965d9acSmrg	    if test -f "$SRCFILE"; then
25650806d53Smrg	         cp "$SRCFILE" lex.yy.c
25750806d53Smrg	    fi
25850806d53Smrg	  ;;
25950806d53Smrg	esac
26050806d53Smrg    fi
2617965d9acSmrg    if test ! -f lex.yy.c; then
26250806d53Smrg	echo 'main() { return 0; }' >lex.yy.c
26350806d53Smrg    fi
26450806d53Smrg    ;;
26550806d53Smrg
26650806d53Smrg  help2man)
26750806d53Smrg    echo 1>&2 "\
26850806d53SmrgWARNING: \`$1' is $msg.  You should only need it if
26950806d53Smrg	 you modified a dependency of a manual page.  You may need the
27050806d53Smrg	 \`Help2man' package in order for those modifications to take
27150806d53Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27250806d53Smrg
2737965d9acSmrg    file=`echo "$*" | sed -n "$sed_output"`
2747965d9acSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2757965d9acSmrg    if test -f "$file"; then
27650806d53Smrg	touch $file
27750806d53Smrg    else
27850806d53Smrg	test -z "$file" || exec >$file
27950806d53Smrg	echo ".ab help2man is required to generate this page"
28050806d53Smrg	exit 1
28150806d53Smrg    fi
28250806d53Smrg    ;;
28350806d53Smrg
28450806d53Smrg  makeinfo)
28550806d53Smrg    echo 1>&2 "\
28650806d53SmrgWARNING: \`$1' is $msg.  You should only need it if
28750806d53Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28850806d53Smrg         indirectly affecting the aspect of the manual.  The spurious
28950806d53Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29050806d53Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29150806d53Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29250806d53Smrg    # The file to touch is that specified with -o ...
2937965d9acSmrg    file=`echo "$*" | sed -n "$sed_output"`
2947965d9acSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29550806d53Smrg    if test -z "$file"; then
29650806d53Smrg      # ... or it is the one specified with @setfilename ...
29750806d53Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2987965d9acSmrg      file=`sed -n '
2997965d9acSmrg	/^@setfilename/{
3007965d9acSmrg	  s/.* \([^ ]*\) *$/\1/
3017965d9acSmrg	  p
3027965d9acSmrg	  q
3037965d9acSmrg	}' $infile`
30450806d53Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30550806d53Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30650806d53Smrg    fi
30750806d53Smrg    # If the file does not exist, the user really needs makeinfo;
30850806d53Smrg    # let's fail without touching anything.
30950806d53Smrg    test -f $file || exit 1
31050806d53Smrg    touch $file
31150806d53Smrg    ;;
31250806d53Smrg
31350806d53Smrg  tar)
31450806d53Smrg    shift
31550806d53Smrg
31650806d53Smrg    # We have already tried tar in the generic part.
31750806d53Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31850806d53Smrg    # messages.
31950806d53Smrg    if (gnutar --version > /dev/null 2>&1); then
32050806d53Smrg       gnutar "$@" && exit 0
32150806d53Smrg    fi
32250806d53Smrg    if (gtar --version > /dev/null 2>&1); then
32350806d53Smrg       gtar "$@" && exit 0
32450806d53Smrg    fi
32550806d53Smrg    firstarg="$1"
32650806d53Smrg    if shift; then
3277965d9acSmrg	case $firstarg in
32850806d53Smrg	*o*)
32950806d53Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33050806d53Smrg	    tar "$firstarg" "$@" && exit 0
33150806d53Smrg	    ;;
33250806d53Smrg	esac
3337965d9acSmrg	case $firstarg in
33450806d53Smrg	*h*)
33550806d53Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33650806d53Smrg	    tar "$firstarg" "$@" && exit 0
33750806d53Smrg	    ;;
33850806d53Smrg	esac
33950806d53Smrg    fi
34050806d53Smrg
34150806d53Smrg    echo 1>&2 "\
34250806d53SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34350806d53Smrg         You may want to install GNU tar or Free paxutils, or check the
34450806d53Smrg         command line arguments."
34550806d53Smrg    exit 1
34650806d53Smrg    ;;
34750806d53Smrg
34850806d53Smrg  *)
34950806d53Smrg    echo 1>&2 "\
35050806d53SmrgWARNING: \`$1' is needed, and is $msg.
35150806d53Smrg         You might have modified some files without having the
35250806d53Smrg         proper tools for further handling them.  Check the \`README' file,
35350806d53Smrg         it often tells you about the needed prerequisites for installing
35450806d53Smrg         this package.  You may also peek at any GNU archive site, in case
35550806d53Smrg         some other package would contain this missing \`$1' program."
35650806d53Smrg    exit 1
35750806d53Smrg    ;;
35850806d53Smrgesac
35950806d53Smrg
36050806d53Smrgexit 0
36150806d53Smrg
36250806d53Smrg# Local variables:
36350806d53Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36450806d53Smrg# time-stamp-start: "scriptversion="
36550806d53Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36650806d53Smrg# time-stamp-end: "$"
36750806d53Smrg# End:
368