missing revision 23a0898a
123a0898aSmrg#! /bin/sh
223a0898aSmrg# Common stub for a few missing GNU programs while installing.
323a0898aSmrg
423a0898aSmrgscriptversion=2006-05-10.23
523a0898aSmrg
623a0898aSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
723a0898aSmrg#   Free Software Foundation, Inc.
823a0898aSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
923a0898aSmrg
1023a0898aSmrg# This program is free software; you can redistribute it and/or modify
1123a0898aSmrg# it under the terms of the GNU General Public License as published by
1223a0898aSmrg# the Free Software Foundation; either version 2, or (at your option)
1323a0898aSmrg# any later version.
1423a0898aSmrg
1523a0898aSmrg# This program is distributed in the hope that it will be useful,
1623a0898aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1723a0898aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1823a0898aSmrg# GNU General Public License for more details.
1923a0898aSmrg
2023a0898aSmrg# You should have received a copy of the GNU General Public License
2123a0898aSmrg# along with this program; if not, write to the Free Software
2223a0898aSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2323a0898aSmrg# 02110-1301, USA.
2423a0898aSmrg
2523a0898aSmrg# As a special exception to the GNU General Public License, if you
2623a0898aSmrg# distribute this file as part of a program that contains a
2723a0898aSmrg# configuration script generated by Autoconf, you may include it under
2823a0898aSmrg# the same distribution terms that you use for the rest of that program.
2923a0898aSmrg
3023a0898aSmrgif test $# -eq 0; then
3123a0898aSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3223a0898aSmrg  exit 1
3323a0898aSmrgfi
3423a0898aSmrg
3523a0898aSmrgrun=:
3623a0898aSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3723a0898aSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3823a0898aSmrg
3923a0898aSmrg# In the cases where this matters, `missing' is being run in the
4023a0898aSmrg# srcdir already.
4123a0898aSmrgif test -f configure.ac; then
4223a0898aSmrg  configure_ac=configure.ac
4323a0898aSmrgelse
4423a0898aSmrg  configure_ac=configure.in
4523a0898aSmrgfi
4623a0898aSmrg
4723a0898aSmrgmsg="missing on your system"
4823a0898aSmrg
4923a0898aSmrgcase $1 in
5023a0898aSmrg--run)
5123a0898aSmrg  # Try to run requested program, and just exit if it succeeds.
5223a0898aSmrg  run=
5323a0898aSmrg  shift
5423a0898aSmrg  "$@" && exit 0
5523a0898aSmrg  # Exit code 63 means version mismatch.  This often happens
5623a0898aSmrg  # when the user try to use an ancient version of a tool on
5723a0898aSmrg  # a file that requires a minimum version.  In this case we
5823a0898aSmrg  # we should proceed has if the program had been absent, or
5923a0898aSmrg  # if --run hadn't been passed.
6023a0898aSmrg  if test $? = 63; then
6123a0898aSmrg    run=:
6223a0898aSmrg    msg="probably too old"
6323a0898aSmrg  fi
6423a0898aSmrg  ;;
6523a0898aSmrg
6623a0898aSmrg  -h|--h|--he|--hel|--help)
6723a0898aSmrg    echo "\
6823a0898aSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6923a0898aSmrg
7023a0898aSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7123a0898aSmrgerror status if there is no known handling for PROGRAM.
7223a0898aSmrg
7323a0898aSmrgOptions:
7423a0898aSmrg  -h, --help      display this help and exit
7523a0898aSmrg  -v, --version   output version information and exit
7623a0898aSmrg  --run           try to run the given command, and emulate it if it fails
7723a0898aSmrg
7823a0898aSmrgSupported PROGRAM values:
7923a0898aSmrg  aclocal      touch file \`aclocal.m4'
8023a0898aSmrg  autoconf     touch file \`configure'
8123a0898aSmrg  autoheader   touch file \`config.h.in'
8223a0898aSmrg  autom4te     touch the output file, or create a stub one
8323a0898aSmrg  automake     touch all \`Makefile.in' files
8423a0898aSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8523a0898aSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8623a0898aSmrg  help2man     touch the output file
8723a0898aSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8823a0898aSmrg  makeinfo     touch the output file
8923a0898aSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9023a0898aSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9123a0898aSmrg
9223a0898aSmrgSend bug reports to <bug-automake@gnu.org>."
9323a0898aSmrg    exit $?
9423a0898aSmrg    ;;
9523a0898aSmrg
9623a0898aSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9723a0898aSmrg    echo "missing $scriptversion (GNU Automake)"
9823a0898aSmrg    exit $?
9923a0898aSmrg    ;;
10023a0898aSmrg
10123a0898aSmrg  -*)
10223a0898aSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10323a0898aSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10423a0898aSmrg    exit 1
10523a0898aSmrg    ;;
10623a0898aSmrg
10723a0898aSmrgesac
10823a0898aSmrg
10923a0898aSmrg# Now exit if we have it, but it failed.  Also exit now if we
11023a0898aSmrg# don't have it and --version was passed (most likely to detect
11123a0898aSmrg# the program).
11223a0898aSmrgcase $1 in
11323a0898aSmrg  lex|yacc)
11423a0898aSmrg    # Not GNU programs, they don't have --version.
11523a0898aSmrg    ;;
11623a0898aSmrg
11723a0898aSmrg  tar)
11823a0898aSmrg    if test -n "$run"; then
11923a0898aSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
12023a0898aSmrg       exit 1
12123a0898aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12223a0898aSmrg       exit 1
12323a0898aSmrg    fi
12423a0898aSmrg    ;;
12523a0898aSmrg
12623a0898aSmrg  *)
12723a0898aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12823a0898aSmrg       # We have it, but it failed.
12923a0898aSmrg       exit 1
13023a0898aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13123a0898aSmrg       # Could not run --version or --help.  This is probably someone
13223a0898aSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13323a0898aSmrg       # $TOOL exists and not knowing $TOOL uses missing.
13423a0898aSmrg       exit 1
13523a0898aSmrg    fi
13623a0898aSmrg    ;;
13723a0898aSmrgesac
13823a0898aSmrg
13923a0898aSmrg# If it does not exist, or fails to run (possibly an outdated version),
14023a0898aSmrg# try to emulate it.
14123a0898aSmrgcase $1 in
14223a0898aSmrg  aclocal*)
14323a0898aSmrg    echo 1>&2 "\
14423a0898aSmrgWARNING: \`$1' is $msg.  You should only need it if
14523a0898aSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14623a0898aSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14723a0898aSmrg         any GNU archive site."
14823a0898aSmrg    touch aclocal.m4
14923a0898aSmrg    ;;
15023a0898aSmrg
15123a0898aSmrg  autoconf)
15223a0898aSmrg    echo 1>&2 "\
15323a0898aSmrgWARNING: \`$1' is $msg.  You should only need it if
15423a0898aSmrg         you modified \`${configure_ac}'.  You might want to install the
15523a0898aSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15623a0898aSmrg         archive site."
15723a0898aSmrg    touch configure
15823a0898aSmrg    ;;
15923a0898aSmrg
16023a0898aSmrg  autoheader)
16123a0898aSmrg    echo 1>&2 "\
16223a0898aSmrgWARNING: \`$1' is $msg.  You should only need it if
16323a0898aSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16423a0898aSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16523a0898aSmrg         from any GNU archive site."
16623a0898aSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16723a0898aSmrg    test -z "$files" && files="config.h"
16823a0898aSmrg    touch_files=
16923a0898aSmrg    for f in $files; do
17023a0898aSmrg      case $f in
17123a0898aSmrg      *:*) touch_files="$touch_files "`echo "$f" |
17223a0898aSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17323a0898aSmrg      *) touch_files="$touch_files $f.in";;
17423a0898aSmrg      esac
17523a0898aSmrg    done
17623a0898aSmrg    touch $touch_files
17723a0898aSmrg    ;;
17823a0898aSmrg
17923a0898aSmrg  automake*)
18023a0898aSmrg    echo 1>&2 "\
18123a0898aSmrgWARNING: \`$1' is $msg.  You should only need it if
18223a0898aSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18323a0898aSmrg         You might want to install the \`Automake' and \`Perl' packages.
18423a0898aSmrg         Grab them from any GNU archive site."
18523a0898aSmrg    find . -type f -name Makefile.am -print |
18623a0898aSmrg	   sed 's/\.am$/.in/' |
18723a0898aSmrg	   while read f; do touch "$f"; done
18823a0898aSmrg    ;;
18923a0898aSmrg
19023a0898aSmrg  autom4te)
19123a0898aSmrg    echo 1>&2 "\
19223a0898aSmrgWARNING: \`$1' is needed, but is $msg.
19323a0898aSmrg         You might have modified some files without having the
19423a0898aSmrg         proper tools for further handling them.
19523a0898aSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
19623a0898aSmrg         archive site."
19723a0898aSmrg
19823a0898aSmrg    file=`echo "$*" | sed -n "$sed_output"`
19923a0898aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20023a0898aSmrg    if test -f "$file"; then
20123a0898aSmrg	touch $file
20223a0898aSmrg    else
20323a0898aSmrg	test -z "$file" || exec >$file
20423a0898aSmrg	echo "#! /bin/sh"
20523a0898aSmrg	echo "# Created by GNU Automake missing as a replacement of"
20623a0898aSmrg	echo "#  $ $@"
20723a0898aSmrg	echo "exit 0"
20823a0898aSmrg	chmod +x $file
20923a0898aSmrg	exit 1
21023a0898aSmrg    fi
21123a0898aSmrg    ;;
21223a0898aSmrg
21323a0898aSmrg  bison|yacc)
21423a0898aSmrg    echo 1>&2 "\
21523a0898aSmrgWARNING: \`$1' $msg.  You should only need it if
21623a0898aSmrg         you modified a \`.y' file.  You may need the \`Bison' package
21723a0898aSmrg         in order for those modifications to take effect.  You can get
21823a0898aSmrg         \`Bison' from any GNU archive site."
21923a0898aSmrg    rm -f y.tab.c y.tab.h
22023a0898aSmrg    if test $# -ne 1; then
22123a0898aSmrg        eval LASTARG="\${$#}"
22223a0898aSmrg	case $LASTARG in
22323a0898aSmrg	*.y)
22423a0898aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22523a0898aSmrg	    if test -f "$SRCFILE"; then
22623a0898aSmrg	         cp "$SRCFILE" y.tab.c
22723a0898aSmrg	    fi
22823a0898aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22923a0898aSmrg	    if test -f "$SRCFILE"; then
23023a0898aSmrg	         cp "$SRCFILE" y.tab.h
23123a0898aSmrg	    fi
23223a0898aSmrg	  ;;
23323a0898aSmrg	esac
23423a0898aSmrg    fi
23523a0898aSmrg    if test ! -f y.tab.h; then
23623a0898aSmrg	echo >y.tab.h
23723a0898aSmrg    fi
23823a0898aSmrg    if test ! -f y.tab.c; then
23923a0898aSmrg	echo 'main() { return 0; }' >y.tab.c
24023a0898aSmrg    fi
24123a0898aSmrg    ;;
24223a0898aSmrg
24323a0898aSmrg  lex|flex)
24423a0898aSmrg    echo 1>&2 "\
24523a0898aSmrgWARNING: \`$1' is $msg.  You should only need it if
24623a0898aSmrg         you modified a \`.l' file.  You may need the \`Flex' package
24723a0898aSmrg         in order for those modifications to take effect.  You can get
24823a0898aSmrg         \`Flex' from any GNU archive site."
24923a0898aSmrg    rm -f lex.yy.c
25023a0898aSmrg    if test $# -ne 1; then
25123a0898aSmrg        eval LASTARG="\${$#}"
25223a0898aSmrg	case $LASTARG in
25323a0898aSmrg	*.l)
25423a0898aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25523a0898aSmrg	    if test -f "$SRCFILE"; then
25623a0898aSmrg	         cp "$SRCFILE" lex.yy.c
25723a0898aSmrg	    fi
25823a0898aSmrg	  ;;
25923a0898aSmrg	esac
26023a0898aSmrg    fi
26123a0898aSmrg    if test ! -f lex.yy.c; then
26223a0898aSmrg	echo 'main() { return 0; }' >lex.yy.c
26323a0898aSmrg    fi
26423a0898aSmrg    ;;
26523a0898aSmrg
26623a0898aSmrg  help2man)
26723a0898aSmrg    echo 1>&2 "\
26823a0898aSmrgWARNING: \`$1' is $msg.  You should only need it if
26923a0898aSmrg	 you modified a dependency of a manual page.  You may need the
27023a0898aSmrg	 \`Help2man' package in order for those modifications to take
27123a0898aSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
27223a0898aSmrg
27323a0898aSmrg    file=`echo "$*" | sed -n "$sed_output"`
27423a0898aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
27523a0898aSmrg    if test -f "$file"; then
27623a0898aSmrg	touch $file
27723a0898aSmrg    else
27823a0898aSmrg	test -z "$file" || exec >$file
27923a0898aSmrg	echo ".ab help2man is required to generate this page"
28023a0898aSmrg	exit 1
28123a0898aSmrg    fi
28223a0898aSmrg    ;;
28323a0898aSmrg
28423a0898aSmrg  makeinfo)
28523a0898aSmrg    echo 1>&2 "\
28623a0898aSmrgWARNING: \`$1' is $msg.  You should only need it if
28723a0898aSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28823a0898aSmrg         indirectly affecting the aspect of the manual.  The spurious
28923a0898aSmrg         call might also be the consequence of using a buggy \`make' (AIX,
29023a0898aSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29123a0898aSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
29223a0898aSmrg    # The file to touch is that specified with -o ...
29323a0898aSmrg    file=`echo "$*" | sed -n "$sed_output"`
29423a0898aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29523a0898aSmrg    if test -z "$file"; then
29623a0898aSmrg      # ... or it is the one specified with @setfilename ...
29723a0898aSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29823a0898aSmrg      file=`sed -n '
29923a0898aSmrg	/^@setfilename/{
30023a0898aSmrg	  s/.* \([^ ]*\) *$/\1/
30123a0898aSmrg	  p
30223a0898aSmrg	  q
30323a0898aSmrg	}' $infile`
30423a0898aSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30523a0898aSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30623a0898aSmrg    fi
30723a0898aSmrg    # If the file does not exist, the user really needs makeinfo;
30823a0898aSmrg    # let's fail without touching anything.
30923a0898aSmrg    test -f $file || exit 1
31023a0898aSmrg    touch $file
31123a0898aSmrg    ;;
31223a0898aSmrg
31323a0898aSmrg  tar)
31423a0898aSmrg    shift
31523a0898aSmrg
31623a0898aSmrg    # We have already tried tar in the generic part.
31723a0898aSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
31823a0898aSmrg    # messages.
31923a0898aSmrg    if (gnutar --version > /dev/null 2>&1); then
32023a0898aSmrg       gnutar "$@" && exit 0
32123a0898aSmrg    fi
32223a0898aSmrg    if (gtar --version > /dev/null 2>&1); then
32323a0898aSmrg       gtar "$@" && exit 0
32423a0898aSmrg    fi
32523a0898aSmrg    firstarg="$1"
32623a0898aSmrg    if shift; then
32723a0898aSmrg	case $firstarg in
32823a0898aSmrg	*o*)
32923a0898aSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
33023a0898aSmrg	    tar "$firstarg" "$@" && exit 0
33123a0898aSmrg	    ;;
33223a0898aSmrg	esac
33323a0898aSmrg	case $firstarg in
33423a0898aSmrg	*h*)
33523a0898aSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
33623a0898aSmrg	    tar "$firstarg" "$@" && exit 0
33723a0898aSmrg	    ;;
33823a0898aSmrg	esac
33923a0898aSmrg    fi
34023a0898aSmrg
34123a0898aSmrg    echo 1>&2 "\
34223a0898aSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34323a0898aSmrg         You may want to install GNU tar or Free paxutils, or check the
34423a0898aSmrg         command line arguments."
34523a0898aSmrg    exit 1
34623a0898aSmrg    ;;
34723a0898aSmrg
34823a0898aSmrg  *)
34923a0898aSmrg    echo 1>&2 "\
35023a0898aSmrgWARNING: \`$1' is needed, and is $msg.
35123a0898aSmrg         You might have modified some files without having the
35223a0898aSmrg         proper tools for further handling them.  Check the \`README' file,
35323a0898aSmrg         it often tells you about the needed prerequisites for installing
35423a0898aSmrg         this package.  You may also peek at any GNU archive site, in case
35523a0898aSmrg         some other package would contain this missing \`$1' program."
35623a0898aSmrg    exit 1
35723a0898aSmrg    ;;
35823a0898aSmrgesac
35923a0898aSmrg
36023a0898aSmrgexit 0
36123a0898aSmrg
36223a0898aSmrg# Local variables:
36323a0898aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36423a0898aSmrg# time-stamp-start: "scriptversion="
36523a0898aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36623a0898aSmrg# time-stamp-end: "$"
36723a0898aSmrg# End:
368