missing revision 92bb16f8
192bb16f8Smrg#! /bin/sh
292bb16f8Smrg# Common stub for a few missing GNU programs while installing.
392bb16f8Smrg
492bb16f8Smrgscriptversion=2005-06-08.21
592bb16f8Smrg
692bb16f8Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
792bb16f8Smrg#   Free Software Foundation, Inc.
892bb16f8Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
992bb16f8Smrg
1092bb16f8Smrg# This program is free software; you can redistribute it and/or modify
1192bb16f8Smrg# it under the terms of the GNU General Public License as published by
1292bb16f8Smrg# the Free Software Foundation; either version 2, or (at your option)
1392bb16f8Smrg# any later version.
1492bb16f8Smrg
1592bb16f8Smrg# This program is distributed in the hope that it will be useful,
1692bb16f8Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1792bb16f8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1892bb16f8Smrg# GNU General Public License for more details.
1992bb16f8Smrg
2092bb16f8Smrg# You should have received a copy of the GNU General Public License
2192bb16f8Smrg# along with this program; if not, write to the Free Software
2292bb16f8Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2392bb16f8Smrg# 02110-1301, USA.
2492bb16f8Smrg
2592bb16f8Smrg# As a special exception to the GNU General Public License, if you
2692bb16f8Smrg# distribute this file as part of a program that contains a
2792bb16f8Smrg# configuration script generated by Autoconf, you may include it under
2892bb16f8Smrg# the same distribution terms that you use for the rest of that program.
2992bb16f8Smrg
3092bb16f8Smrgif test $# -eq 0; then
3192bb16f8Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3292bb16f8Smrg  exit 1
3392bb16f8Smrgfi
3492bb16f8Smrg
3592bb16f8Smrgrun=:
3692bb16f8Smrg
3792bb16f8Smrg# In the cases where this matters, `missing' is being run in the
3892bb16f8Smrg# srcdir already.
3992bb16f8Smrgif test -f configure.ac; then
4092bb16f8Smrg  configure_ac=configure.ac
4192bb16f8Smrgelse
4292bb16f8Smrg  configure_ac=configure.in
4392bb16f8Smrgfi
4492bb16f8Smrg
4592bb16f8Smrgmsg="missing on your system"
4692bb16f8Smrg
4792bb16f8Smrgcase "$1" in
4892bb16f8Smrg--run)
4992bb16f8Smrg  # Try to run requested program, and just exit if it succeeds.
5092bb16f8Smrg  run=
5192bb16f8Smrg  shift
5292bb16f8Smrg  "$@" && exit 0
5392bb16f8Smrg  # Exit code 63 means version mismatch.  This often happens
5492bb16f8Smrg  # when the user try to use an ancient version of a tool on
5592bb16f8Smrg  # a file that requires a minimum version.  In this case we
5692bb16f8Smrg  # we should proceed has if the program had been absent, or
5792bb16f8Smrg  # if --run hadn't been passed.
5892bb16f8Smrg  if test $? = 63; then
5992bb16f8Smrg    run=:
6092bb16f8Smrg    msg="probably too old"
6192bb16f8Smrg  fi
6292bb16f8Smrg  ;;
6392bb16f8Smrg
6492bb16f8Smrg  -h|--h|--he|--hel|--help)
6592bb16f8Smrg    echo "\
6692bb16f8Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6792bb16f8Smrg
6892bb16f8SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6992bb16f8Smrgerror status if there is no known handling for PROGRAM.
7092bb16f8Smrg
7192bb16f8SmrgOptions:
7292bb16f8Smrg  -h, --help      display this help and exit
7392bb16f8Smrg  -v, --version   output version information and exit
7492bb16f8Smrg  --run           try to run the given command, and emulate it if it fails
7592bb16f8Smrg
7692bb16f8SmrgSupported PROGRAM values:
7792bb16f8Smrg  aclocal      touch file \`aclocal.m4'
7892bb16f8Smrg  autoconf     touch file \`configure'
7992bb16f8Smrg  autoheader   touch file \`config.h.in'
8092bb16f8Smrg  automake     touch all \`Makefile.in' files
8192bb16f8Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8292bb16f8Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8392bb16f8Smrg  help2man     touch the output file
8492bb16f8Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8592bb16f8Smrg  makeinfo     touch the output file
8692bb16f8Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8792bb16f8Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8892bb16f8Smrg
8992bb16f8SmrgSend bug reports to <bug-automake@gnu.org>."
9092bb16f8Smrg    exit $?
9192bb16f8Smrg    ;;
9292bb16f8Smrg
9392bb16f8Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9492bb16f8Smrg    echo "missing $scriptversion (GNU Automake)"
9592bb16f8Smrg    exit $?
9692bb16f8Smrg    ;;
9792bb16f8Smrg
9892bb16f8Smrg  -*)
9992bb16f8Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10092bb16f8Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10192bb16f8Smrg    exit 1
10292bb16f8Smrg    ;;
10392bb16f8Smrg
10492bb16f8Smrgesac
10592bb16f8Smrg
10692bb16f8Smrg# Now exit if we have it, but it failed.  Also exit now if we
10792bb16f8Smrg# don't have it and --version was passed (most likely to detect
10892bb16f8Smrg# the program).
10992bb16f8Smrgcase "$1" in
11092bb16f8Smrg  lex|yacc)
11192bb16f8Smrg    # Not GNU programs, they don't have --version.
11292bb16f8Smrg    ;;
11392bb16f8Smrg
11492bb16f8Smrg  tar)
11592bb16f8Smrg    if test -n "$run"; then
11692bb16f8Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
11792bb16f8Smrg       exit 1
11892bb16f8Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
11992bb16f8Smrg       exit 1
12092bb16f8Smrg    fi
12192bb16f8Smrg    ;;
12292bb16f8Smrg
12392bb16f8Smrg  *)
12492bb16f8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12592bb16f8Smrg       # We have it, but it failed.
12692bb16f8Smrg       exit 1
12792bb16f8Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12892bb16f8Smrg       # Could not run --version or --help.  This is probably someone
12992bb16f8Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13092bb16f8Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13192bb16f8Smrg       exit 1
13292bb16f8Smrg    fi
13392bb16f8Smrg    ;;
13492bb16f8Smrgesac
13592bb16f8Smrg
13692bb16f8Smrg# If it does not exist, or fails to run (possibly an outdated version),
13792bb16f8Smrg# try to emulate it.
13892bb16f8Smrgcase "$1" in
13992bb16f8Smrg  aclocal*)
14092bb16f8Smrg    echo 1>&2 "\
14192bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
14292bb16f8Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14392bb16f8Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14492bb16f8Smrg         any GNU archive site."
14592bb16f8Smrg    touch aclocal.m4
14692bb16f8Smrg    ;;
14792bb16f8Smrg
14892bb16f8Smrg  autoconf)
14992bb16f8Smrg    echo 1>&2 "\
15092bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
15192bb16f8Smrg         you modified \`${configure_ac}'.  You might want to install the
15292bb16f8Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15392bb16f8Smrg         archive site."
15492bb16f8Smrg    touch configure
15592bb16f8Smrg    ;;
15692bb16f8Smrg
15792bb16f8Smrg  autoheader)
15892bb16f8Smrg    echo 1>&2 "\
15992bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
16092bb16f8Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16192bb16f8Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16292bb16f8Smrg         from any GNU archive site."
16392bb16f8Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16492bb16f8Smrg    test -z "$files" && files="config.h"
16592bb16f8Smrg    touch_files=
16692bb16f8Smrg    for f in $files; do
16792bb16f8Smrg      case "$f" in
16892bb16f8Smrg      *:*) touch_files="$touch_files "`echo "$f" |
16992bb16f8Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17092bb16f8Smrg      *) touch_files="$touch_files $f.in";;
17192bb16f8Smrg      esac
17292bb16f8Smrg    done
17392bb16f8Smrg    touch $touch_files
17492bb16f8Smrg    ;;
17592bb16f8Smrg
17692bb16f8Smrg  automake*)
17792bb16f8Smrg    echo 1>&2 "\
17892bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
17992bb16f8Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18092bb16f8Smrg         You might want to install the \`Automake' and \`Perl' packages.
18192bb16f8Smrg         Grab them from any GNU archive site."
18292bb16f8Smrg    find . -type f -name Makefile.am -print |
18392bb16f8Smrg	   sed 's/\.am$/.in/' |
18492bb16f8Smrg	   while read f; do touch "$f"; done
18592bb16f8Smrg    ;;
18692bb16f8Smrg
18792bb16f8Smrg  autom4te)
18892bb16f8Smrg    echo 1>&2 "\
18992bb16f8SmrgWARNING: \`$1' is needed, but is $msg.
19092bb16f8Smrg         You might have modified some files without having the
19192bb16f8Smrg         proper tools for further handling them.
19292bb16f8Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19392bb16f8Smrg         archive site."
19492bb16f8Smrg
19592bb16f8Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
19692bb16f8Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
19792bb16f8Smrg    if test -f "$file"; then
19892bb16f8Smrg	touch $file
19992bb16f8Smrg    else
20092bb16f8Smrg	test -z "$file" || exec >$file
20192bb16f8Smrg	echo "#! /bin/sh"
20292bb16f8Smrg	echo "# Created by GNU Automake missing as a replacement of"
20392bb16f8Smrg	echo "#  $ $@"
20492bb16f8Smrg	echo "exit 0"
20592bb16f8Smrg	chmod +x $file
20692bb16f8Smrg	exit 1
20792bb16f8Smrg    fi
20892bb16f8Smrg    ;;
20992bb16f8Smrg
21092bb16f8Smrg  bison|yacc)
21192bb16f8Smrg    echo 1>&2 "\
21292bb16f8SmrgWARNING: \`$1' $msg.  You should only need it if
21392bb16f8Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21492bb16f8Smrg         in order for those modifications to take effect.  You can get
21592bb16f8Smrg         \`Bison' from any GNU archive site."
21692bb16f8Smrg    rm -f y.tab.c y.tab.h
21792bb16f8Smrg    if [ $# -ne 1 ]; then
21892bb16f8Smrg        eval LASTARG="\${$#}"
21992bb16f8Smrg	case "$LASTARG" in
22092bb16f8Smrg	*.y)
22192bb16f8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22292bb16f8Smrg	    if [ -f "$SRCFILE" ]; then
22392bb16f8Smrg	         cp "$SRCFILE" y.tab.c
22492bb16f8Smrg	    fi
22592bb16f8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22692bb16f8Smrg	    if [ -f "$SRCFILE" ]; then
22792bb16f8Smrg	         cp "$SRCFILE" y.tab.h
22892bb16f8Smrg	    fi
22992bb16f8Smrg	  ;;
23092bb16f8Smrg	esac
23192bb16f8Smrg    fi
23292bb16f8Smrg    if [ ! -f y.tab.h ]; then
23392bb16f8Smrg	echo >y.tab.h
23492bb16f8Smrg    fi
23592bb16f8Smrg    if [ ! -f y.tab.c ]; then
23692bb16f8Smrg	echo 'main() { return 0; }' >y.tab.c
23792bb16f8Smrg    fi
23892bb16f8Smrg    ;;
23992bb16f8Smrg
24092bb16f8Smrg  lex|flex)
24192bb16f8Smrg    echo 1>&2 "\
24292bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
24392bb16f8Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24492bb16f8Smrg         in order for those modifications to take effect.  You can get
24592bb16f8Smrg         \`Flex' from any GNU archive site."
24692bb16f8Smrg    rm -f lex.yy.c
24792bb16f8Smrg    if [ $# -ne 1 ]; then
24892bb16f8Smrg        eval LASTARG="\${$#}"
24992bb16f8Smrg	case "$LASTARG" in
25092bb16f8Smrg	*.l)
25192bb16f8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25292bb16f8Smrg	    if [ -f "$SRCFILE" ]; then
25392bb16f8Smrg	         cp "$SRCFILE" lex.yy.c
25492bb16f8Smrg	    fi
25592bb16f8Smrg	  ;;
25692bb16f8Smrg	esac
25792bb16f8Smrg    fi
25892bb16f8Smrg    if [ ! -f lex.yy.c ]; then
25992bb16f8Smrg	echo 'main() { return 0; }' >lex.yy.c
26092bb16f8Smrg    fi
26192bb16f8Smrg    ;;
26292bb16f8Smrg
26392bb16f8Smrg  help2man)
26492bb16f8Smrg    echo 1>&2 "\
26592bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
26692bb16f8Smrg	 you modified a dependency of a manual page.  You may need the
26792bb16f8Smrg	 \`Help2man' package in order for those modifications to take
26892bb16f8Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
26992bb16f8Smrg
27092bb16f8Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27192bb16f8Smrg    if test -z "$file"; then
27292bb16f8Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27392bb16f8Smrg    fi
27492bb16f8Smrg    if [ -f "$file" ]; then
27592bb16f8Smrg	touch $file
27692bb16f8Smrg    else
27792bb16f8Smrg	test -z "$file" || exec >$file
27892bb16f8Smrg	echo ".ab help2man is required to generate this page"
27992bb16f8Smrg	exit 1
28092bb16f8Smrg    fi
28192bb16f8Smrg    ;;
28292bb16f8Smrg
28392bb16f8Smrg  makeinfo)
28492bb16f8Smrg    echo 1>&2 "\
28592bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
28692bb16f8Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28792bb16f8Smrg         indirectly affecting the aspect of the manual.  The spurious
28892bb16f8Smrg         call might also be the consequence of using a buggy \`make' (AIX,
28992bb16f8Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29092bb16f8Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29192bb16f8Smrg    # The file to touch is that specified with -o ...
29292bb16f8Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29392bb16f8Smrg    if test -z "$file"; then
29492bb16f8Smrg      # ... or it is the one specified with @setfilename ...
29592bb16f8Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29692bb16f8Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
29792bb16f8Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
29892bb16f8Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29992bb16f8Smrg    fi
30092bb16f8Smrg    # If the file does not exist, the user really needs makeinfo;
30192bb16f8Smrg    # let's fail without touching anything.
30292bb16f8Smrg    test -f $file || exit 1
30392bb16f8Smrg    touch $file
30492bb16f8Smrg    ;;
30592bb16f8Smrg
30692bb16f8Smrg  tar)
30792bb16f8Smrg    shift
30892bb16f8Smrg
30992bb16f8Smrg    # We have already tried tar in the generic part.
31092bb16f8Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31192bb16f8Smrg    # messages.
31292bb16f8Smrg    if (gnutar --version > /dev/null 2>&1); then
31392bb16f8Smrg       gnutar "$@" && exit 0
31492bb16f8Smrg    fi
31592bb16f8Smrg    if (gtar --version > /dev/null 2>&1); then
31692bb16f8Smrg       gtar "$@" && exit 0
31792bb16f8Smrg    fi
31892bb16f8Smrg    firstarg="$1"
31992bb16f8Smrg    if shift; then
32092bb16f8Smrg	case "$firstarg" in
32192bb16f8Smrg	*o*)
32292bb16f8Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
32392bb16f8Smrg	    tar "$firstarg" "$@" && exit 0
32492bb16f8Smrg	    ;;
32592bb16f8Smrg	esac
32692bb16f8Smrg	case "$firstarg" in
32792bb16f8Smrg	*h*)
32892bb16f8Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
32992bb16f8Smrg	    tar "$firstarg" "$@" && exit 0
33092bb16f8Smrg	    ;;
33192bb16f8Smrg	esac
33292bb16f8Smrg    fi
33392bb16f8Smrg
33492bb16f8Smrg    echo 1>&2 "\
33592bb16f8SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
33692bb16f8Smrg         You may want to install GNU tar or Free paxutils, or check the
33792bb16f8Smrg         command line arguments."
33892bb16f8Smrg    exit 1
33992bb16f8Smrg    ;;
34092bb16f8Smrg
34192bb16f8Smrg  *)
34292bb16f8Smrg    echo 1>&2 "\
34392bb16f8SmrgWARNING: \`$1' is needed, and is $msg.
34492bb16f8Smrg         You might have modified some files without having the
34592bb16f8Smrg         proper tools for further handling them.  Check the \`README' file,
34692bb16f8Smrg         it often tells you about the needed prerequisites for installing
34792bb16f8Smrg         this package.  You may also peek at any GNU archive site, in case
34892bb16f8Smrg         some other package would contain this missing \`$1' program."
34992bb16f8Smrg    exit 1
35092bb16f8Smrg    ;;
35192bb16f8Smrgesac
35292bb16f8Smrg
35392bb16f8Smrgexit 0
35492bb16f8Smrg
35592bb16f8Smrg# Local variables:
35692bb16f8Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
35792bb16f8Smrg# time-stamp-start: "scriptversion="
35892bb16f8Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
35992bb16f8Smrg# time-stamp-end: "$"
36092bb16f8Smrg# End:
361