missing revision 97e8a2e8
197e8a2e8Smrg#! /bin/sh
297e8a2e8Smrg# Common stub for a few missing GNU programs while installing.
397e8a2e8Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
497e8a2e8Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
597e8a2e8Smrg
697e8a2e8Smrg# This program is free software; you can redistribute it and/or modify
797e8a2e8Smrg# it under the terms of the GNU General Public License as published by
897e8a2e8Smrg# the Free Software Foundation; either version 2, or (at your option)
997e8a2e8Smrg# any later version.
1097e8a2e8Smrg
1197e8a2e8Smrg# This program is distributed in the hope that it will be useful,
1297e8a2e8Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1397e8a2e8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1497e8a2e8Smrg# GNU General Public License for more details.
1597e8a2e8Smrg
1697e8a2e8Smrg# You should have received a copy of the GNU General Public License
1797e8a2e8Smrg# along with this program; if not, write to the Free Software
1897e8a2e8Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1997e8a2e8Smrg# 02111-1307, USA.
2097e8a2e8Smrg
2197e8a2e8Smrg# As a special exception to the GNU General Public License, if you
2297e8a2e8Smrg# distribute this file as part of a program that contains a
2397e8a2e8Smrg# configuration script generated by Autoconf, you may include it under
2497e8a2e8Smrg# the same distribution terms that you use for the rest of that program.
2597e8a2e8Smrg
2697e8a2e8Smrgif test $# -eq 0; then
2797e8a2e8Smrg  echo 1>&2 "Try \`$0 --help' for more information"
2897e8a2e8Smrg  exit 1
2997e8a2e8Smrgfi
3097e8a2e8Smrg
3197e8a2e8Smrgrun=:
3297e8a2e8Smrg
3397e8a2e8Smrg# In the cases where this matters, `missing' is being run in the
3497e8a2e8Smrg# srcdir already.
3597e8a2e8Smrgif test -f configure.ac; then
3697e8a2e8Smrg  configure_ac=configure.ac
3797e8a2e8Smrgelse
3897e8a2e8Smrg  configure_ac=configure.in
3997e8a2e8Smrgfi
4097e8a2e8Smrg
4197e8a2e8Smrgcase "$1" in
4297e8a2e8Smrg--run)
4397e8a2e8Smrg  # Try to run requested program, and just exit if it succeeds.
4497e8a2e8Smrg  run=
4597e8a2e8Smrg  shift
4697e8a2e8Smrg  "$@" && exit 0
4797e8a2e8Smrg  ;;
4897e8a2e8Smrgesac
4997e8a2e8Smrg
5097e8a2e8Smrg# If it does not exist, or fails to run (possibly an outdated version),
5197e8a2e8Smrg# try to emulate it.
5297e8a2e8Smrgcase "$1" in
5397e8a2e8Smrg
5497e8a2e8Smrg  -h|--h|--he|--hel|--help)
5597e8a2e8Smrg    echo "\
5697e8a2e8Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
5797e8a2e8Smrg
5897e8a2e8SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
5997e8a2e8Smrgerror status if there is no known handling for PROGRAM.
6097e8a2e8Smrg
6197e8a2e8SmrgOptions:
6297e8a2e8Smrg  -h, --help      display this help and exit
6397e8a2e8Smrg  -v, --version   output version information and exit
6497e8a2e8Smrg  --run           try to run the given command, and emulate it if it fails
6597e8a2e8Smrg
6697e8a2e8SmrgSupported PROGRAM values:
6797e8a2e8Smrg  aclocal      touch file \`aclocal.m4'
6897e8a2e8Smrg  autoconf     touch file \`configure'
6997e8a2e8Smrg  autoheader   touch file \`config.h.in'
7097e8a2e8Smrg  automake     touch all \`Makefile.in' files
7197e8a2e8Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
7297e8a2e8Smrg  flex         create \`lex.yy.c', if possible, from existing .c
7397e8a2e8Smrg  help2man     touch the output file
7497e8a2e8Smrg  lex          create \`lex.yy.c', if possible, from existing .c
7597e8a2e8Smrg  makeinfo     touch the output file
7697e8a2e8Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
7797e8a2e8Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
7897e8a2e8Smrg    ;;
7997e8a2e8Smrg
8097e8a2e8Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
8197e8a2e8Smrg    echo "missing 0.4 - GNU automake"
8297e8a2e8Smrg    ;;
8397e8a2e8Smrg
8497e8a2e8Smrg  -*)
8597e8a2e8Smrg    echo 1>&2 "$0: Unknown \`$1' option"
8697e8a2e8Smrg    echo 1>&2 "Try \`$0 --help' for more information"
8797e8a2e8Smrg    exit 1
8897e8a2e8Smrg    ;;
8997e8a2e8Smrg
9097e8a2e8Smrg  aclocal*)
9197e8a2e8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
9297e8a2e8Smrg       # We have it, but it failed.
9397e8a2e8Smrg       exit 1
9497e8a2e8Smrg    fi
9597e8a2e8Smrg
9697e8a2e8Smrg    echo 1>&2 "\
9797e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
9897e8a2e8Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
9997e8a2e8Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
10097e8a2e8Smrg         any GNU archive site."
10197e8a2e8Smrg    touch aclocal.m4
10297e8a2e8Smrg    ;;
10397e8a2e8Smrg
10497e8a2e8Smrg  autoconf)
10597e8a2e8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
10697e8a2e8Smrg       # We have it, but it failed.
10797e8a2e8Smrg       exit 1
10897e8a2e8Smrg    fi
10997e8a2e8Smrg
11097e8a2e8Smrg    echo 1>&2 "\
11197e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
11297e8a2e8Smrg         you modified \`${configure_ac}'.  You might want to install the
11397e8a2e8Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
11497e8a2e8Smrg         archive site."
11597e8a2e8Smrg    touch configure
11697e8a2e8Smrg    ;;
11797e8a2e8Smrg
11897e8a2e8Smrg  autoheader)
11997e8a2e8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12097e8a2e8Smrg       # We have it, but it failed.
12197e8a2e8Smrg       exit 1
12297e8a2e8Smrg    fi
12397e8a2e8Smrg
12497e8a2e8Smrg    echo 1>&2 "\
12597e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
12697e8a2e8Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
12797e8a2e8Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
12897e8a2e8Smrg         from any GNU archive site."
12997e8a2e8Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
13097e8a2e8Smrg    test -z "$files" && files="config.h"
13197e8a2e8Smrg    touch_files=
13297e8a2e8Smrg    for f in $files; do
13397e8a2e8Smrg      case "$f" in
13497e8a2e8Smrg      *:*) touch_files="$touch_files "`echo "$f" |
13597e8a2e8Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
13697e8a2e8Smrg      *) touch_files="$touch_files $f.in";;
13797e8a2e8Smrg      esac
13897e8a2e8Smrg    done
13997e8a2e8Smrg    touch $touch_files
14097e8a2e8Smrg    ;;
14197e8a2e8Smrg
14297e8a2e8Smrg  automake*)
14397e8a2e8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
14497e8a2e8Smrg       # We have it, but it failed.
14597e8a2e8Smrg       exit 1
14697e8a2e8Smrg    fi
14797e8a2e8Smrg
14897e8a2e8Smrg    echo 1>&2 "\
14997e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
15097e8a2e8Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
15197e8a2e8Smrg         You might want to install the \`Automake' and \`Perl' packages.
15297e8a2e8Smrg         Grab them from any GNU archive site."
15397e8a2e8Smrg    find . -type f -name Makefile.am -print |
15497e8a2e8Smrg	   sed 's/\.am$/.in/' |
15597e8a2e8Smrg	   while read f; do touch "$f"; done
15697e8a2e8Smrg    ;;
15797e8a2e8Smrg
15897e8a2e8Smrg  autom4te)
15997e8a2e8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
16097e8a2e8Smrg       # We have it, but it failed.
16197e8a2e8Smrg       exit 1
16297e8a2e8Smrg    fi
16397e8a2e8Smrg
16497e8a2e8Smrg    echo 1>&2 "\
16597e8a2e8SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
16697e8a2e8Smrg         system.  You might have modified some files without having the
16797e8a2e8Smrg         proper tools for further handling them.
16897e8a2e8Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
16997e8a2e8Smrg         archive site."
17097e8a2e8Smrg
17197e8a2e8Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
17297e8a2e8Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
17397e8a2e8Smrg    if test -f "$file"; then
17497e8a2e8Smrg	touch $file
17597e8a2e8Smrg    else
17697e8a2e8Smrg	test -z "$file" || exec >$file
17797e8a2e8Smrg	echo "#! /bin/sh"
17897e8a2e8Smrg	echo "# Created by GNU Automake missing as a replacement of"
17997e8a2e8Smrg	echo "#  $ $@"
18097e8a2e8Smrg	echo "exit 0"
18197e8a2e8Smrg	chmod +x $file
18297e8a2e8Smrg	exit 1
18397e8a2e8Smrg    fi
18497e8a2e8Smrg    ;;
18597e8a2e8Smrg
18697e8a2e8Smrg  bison|yacc)
18797e8a2e8Smrg    echo 1>&2 "\
18897e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
18997e8a2e8Smrg         you modified a \`.y' file.  You may need the \`Bison' package
19097e8a2e8Smrg         in order for those modifications to take effect.  You can get
19197e8a2e8Smrg         \`Bison' from any GNU archive site."
19297e8a2e8Smrg    rm -f y.tab.c y.tab.h
19397e8a2e8Smrg    if [ $# -ne 1 ]; then
19497e8a2e8Smrg        eval LASTARG="\${$#}"
19597e8a2e8Smrg	case "$LASTARG" in
19697e8a2e8Smrg	*.y)
19797e8a2e8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
19897e8a2e8Smrg	    if [ -f "$SRCFILE" ]; then
19997e8a2e8Smrg	         cp "$SRCFILE" y.tab.c
20097e8a2e8Smrg	    fi
20197e8a2e8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
20297e8a2e8Smrg	    if [ -f "$SRCFILE" ]; then
20397e8a2e8Smrg	         cp "$SRCFILE" y.tab.h
20497e8a2e8Smrg	    fi
20597e8a2e8Smrg	  ;;
20697e8a2e8Smrg	esac
20797e8a2e8Smrg    fi
20897e8a2e8Smrg    if [ ! -f y.tab.h ]; then
20997e8a2e8Smrg	echo >y.tab.h
21097e8a2e8Smrg    fi
21197e8a2e8Smrg    if [ ! -f y.tab.c ]; then
21297e8a2e8Smrg	echo 'main() { return 0; }' >y.tab.c
21397e8a2e8Smrg    fi
21497e8a2e8Smrg    ;;
21597e8a2e8Smrg
21697e8a2e8Smrg  lex|flex)
21797e8a2e8Smrg    echo 1>&2 "\
21897e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
21997e8a2e8Smrg         you modified a \`.l' file.  You may need the \`Flex' package
22097e8a2e8Smrg         in order for those modifications to take effect.  You can get
22197e8a2e8Smrg         \`Flex' from any GNU archive site."
22297e8a2e8Smrg    rm -f lex.yy.c
22397e8a2e8Smrg    if [ $# -ne 1 ]; then
22497e8a2e8Smrg        eval LASTARG="\${$#}"
22597e8a2e8Smrg	case "$LASTARG" in
22697e8a2e8Smrg	*.l)
22797e8a2e8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
22897e8a2e8Smrg	    if [ -f "$SRCFILE" ]; then
22997e8a2e8Smrg	         cp "$SRCFILE" lex.yy.c
23097e8a2e8Smrg	    fi
23197e8a2e8Smrg	  ;;
23297e8a2e8Smrg	esac
23397e8a2e8Smrg    fi
23497e8a2e8Smrg    if [ ! -f lex.yy.c ]; then
23597e8a2e8Smrg	echo 'main() { return 0; }' >lex.yy.c
23697e8a2e8Smrg    fi
23797e8a2e8Smrg    ;;
23897e8a2e8Smrg
23997e8a2e8Smrg  help2man)
24097e8a2e8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
24197e8a2e8Smrg       # We have it, but it failed.
24297e8a2e8Smrg       exit 1
24397e8a2e8Smrg    fi
24497e8a2e8Smrg
24597e8a2e8Smrg    echo 1>&2 "\
24697e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
24797e8a2e8Smrg	 you modified a dependency of a manual page.  You may need the
24897e8a2e8Smrg	 \`Help2man' package in order for those modifications to take
24997e8a2e8Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
25097e8a2e8Smrg
25197e8a2e8Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
25297e8a2e8Smrg    if test -z "$file"; then
25397e8a2e8Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
25497e8a2e8Smrg    fi
25597e8a2e8Smrg    if [ -f "$file" ]; then
25697e8a2e8Smrg	touch $file
25797e8a2e8Smrg    else
25897e8a2e8Smrg	test -z "$file" || exec >$file
25997e8a2e8Smrg	echo ".ab help2man is required to generate this page"
26097e8a2e8Smrg	exit 1
26197e8a2e8Smrg    fi
26297e8a2e8Smrg    ;;
26397e8a2e8Smrg
26497e8a2e8Smrg  makeinfo)
26597e8a2e8Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
26697e8a2e8Smrg       # We have makeinfo, but it failed.
26797e8a2e8Smrg       exit 1
26897e8a2e8Smrg    fi
26997e8a2e8Smrg
27097e8a2e8Smrg    echo 1>&2 "\
27197e8a2e8SmrgWARNING: \`$1' is missing on your system.  You should only need it if
27297e8a2e8Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
27397e8a2e8Smrg         indirectly affecting the aspect of the manual.  The spurious
27497e8a2e8Smrg         call might also be the consequence of using a buggy \`make' (AIX,
27597e8a2e8Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
27697e8a2e8Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
27797e8a2e8Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27897e8a2e8Smrg    if test -z "$file"; then
27997e8a2e8Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
28097e8a2e8Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
28197e8a2e8Smrg    fi
28297e8a2e8Smrg    touch $file
28397e8a2e8Smrg    ;;
28497e8a2e8Smrg
28597e8a2e8Smrg  tar)
28697e8a2e8Smrg    shift
28797e8a2e8Smrg    if test -n "$run"; then
28897e8a2e8Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
28997e8a2e8Smrg      exit 1
29097e8a2e8Smrg    fi
29197e8a2e8Smrg
29297e8a2e8Smrg    # We have already tried tar in the generic part.
29397e8a2e8Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
29497e8a2e8Smrg    # messages.
29597e8a2e8Smrg    if (gnutar --version > /dev/null 2>&1); then
29697e8a2e8Smrg       gnutar "$@" && exit 0
29797e8a2e8Smrg    fi
29897e8a2e8Smrg    if (gtar --version > /dev/null 2>&1); then
29997e8a2e8Smrg       gtar "$@" && exit 0
30097e8a2e8Smrg    fi
30197e8a2e8Smrg    firstarg="$1"
30297e8a2e8Smrg    if shift; then
30397e8a2e8Smrg	case "$firstarg" in
30497e8a2e8Smrg	*o*)
30597e8a2e8Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
30697e8a2e8Smrg	    tar "$firstarg" "$@" && exit 0
30797e8a2e8Smrg	    ;;
30897e8a2e8Smrg	esac
30997e8a2e8Smrg	case "$firstarg" in
31097e8a2e8Smrg	*h*)
31197e8a2e8Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
31297e8a2e8Smrg	    tar "$firstarg" "$@" && exit 0
31397e8a2e8Smrg	    ;;
31497e8a2e8Smrg	esac
31597e8a2e8Smrg    fi
31697e8a2e8Smrg
31797e8a2e8Smrg    echo 1>&2 "\
31897e8a2e8SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
31997e8a2e8Smrg         You may want to install GNU tar or Free paxutils, or check the
32097e8a2e8Smrg         command line arguments."
32197e8a2e8Smrg    exit 1
32297e8a2e8Smrg    ;;
32397e8a2e8Smrg
32497e8a2e8Smrg  *)
32597e8a2e8Smrg    echo 1>&2 "\
32697e8a2e8SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
32797e8a2e8Smrg         system.  You might have modified some files without having the
32897e8a2e8Smrg         proper tools for further handling them.  Check the \`README' file,
32997e8a2e8Smrg         it often tells you about the needed prerequisites for installing
33097e8a2e8Smrg         this package.  You may also peek at any GNU archive site, in case
33197e8a2e8Smrg         some other package would contain this missing \`$1' program."
33297e8a2e8Smrg    exit 1
33397e8a2e8Smrg    ;;
33497e8a2e8Smrgesac
33597e8a2e8Smrg
33697e8a2e8Smrgexit 0
337