missing revision 67f05d30
167f05d30Smrg#! /bin/sh
267f05d30Smrg# Common stub for a few missing GNU programs while installing.
367f05d30Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
467f05d30Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
567f05d30Smrg
667f05d30Smrg# This program is free software; you can redistribute it and/or modify
767f05d30Smrg# it under the terms of the GNU General Public License as published by
867f05d30Smrg# the Free Software Foundation; either version 2, or (at your option)
967f05d30Smrg# any later version.
1067f05d30Smrg
1167f05d30Smrg# This program is distributed in the hope that it will be useful,
1267f05d30Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1367f05d30Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1467f05d30Smrg# GNU General Public License for more details.
1567f05d30Smrg
1667f05d30Smrg# You should have received a copy of the GNU General Public License
1767f05d30Smrg# along with this program; if not, write to the Free Software
1867f05d30Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1967f05d30Smrg# 02111-1307, USA.
2067f05d30Smrg
2167f05d30Smrg# As a special exception to the GNU General Public License, if you
2267f05d30Smrg# distribute this file as part of a program that contains a
2367f05d30Smrg# configuration script generated by Autoconf, you may include it under
2467f05d30Smrg# the same distribution terms that you use for the rest of that program.
2567f05d30Smrg
2667f05d30Smrgif test $# -eq 0; then
2767f05d30Smrg  echo 1>&2 "Try \`$0 --help' for more information"
2867f05d30Smrg  exit 1
2967f05d30Smrgfi
3067f05d30Smrg
3167f05d30Smrgrun=:
3267f05d30Smrg
3367f05d30Smrg# In the cases where this matters, `missing' is being run in the
3467f05d30Smrg# srcdir already.
3567f05d30Smrgif test -f configure.ac; then
3667f05d30Smrg  configure_ac=configure.ac
3767f05d30Smrgelse
3867f05d30Smrg  configure_ac=configure.in
3967f05d30Smrgfi
4067f05d30Smrg
4167f05d30Smrgcase "$1" in
4267f05d30Smrg--run)
4367f05d30Smrg  # Try to run requested program, and just exit if it succeeds.
4467f05d30Smrg  run=
4567f05d30Smrg  shift
4667f05d30Smrg  "$@" && exit 0
4767f05d30Smrg  ;;
4867f05d30Smrgesac
4967f05d30Smrg
5067f05d30Smrg# If it does not exist, or fails to run (possibly an outdated version),
5167f05d30Smrg# try to emulate it.
5267f05d30Smrgcase "$1" in
5367f05d30Smrg
5467f05d30Smrg  -h|--h|--he|--hel|--help)
5567f05d30Smrg    echo "\
5667f05d30Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
5767f05d30Smrg
5867f05d30SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
5967f05d30Smrgerror status if there is no known handling for PROGRAM.
6067f05d30Smrg
6167f05d30SmrgOptions:
6267f05d30Smrg  -h, --help      display this help and exit
6367f05d30Smrg  -v, --version   output version information and exit
6467f05d30Smrg  --run           try to run the given command, and emulate it if it fails
6567f05d30Smrg
6667f05d30SmrgSupported PROGRAM values:
6767f05d30Smrg  aclocal      touch file \`aclocal.m4'
6867f05d30Smrg  autoconf     touch file \`configure'
6967f05d30Smrg  autoheader   touch file \`config.h.in'
7067f05d30Smrg  automake     touch all \`Makefile.in' files
7167f05d30Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
7267f05d30Smrg  flex         create \`lex.yy.c', if possible, from existing .c
7367f05d30Smrg  help2man     touch the output file
7467f05d30Smrg  lex          create \`lex.yy.c', if possible, from existing .c
7567f05d30Smrg  makeinfo     touch the output file
7667f05d30Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
7767f05d30Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
7867f05d30Smrg    ;;
7967f05d30Smrg
8067f05d30Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
8167f05d30Smrg    echo "missing 0.4 - GNU automake"
8267f05d30Smrg    ;;
8367f05d30Smrg
8467f05d30Smrg  -*)
8567f05d30Smrg    echo 1>&2 "$0: Unknown \`$1' option"
8667f05d30Smrg    echo 1>&2 "Try \`$0 --help' for more information"
8767f05d30Smrg    exit 1
8867f05d30Smrg    ;;
8967f05d30Smrg
9067f05d30Smrg  aclocal*)
9167f05d30Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
9267f05d30Smrg       # We have it, but it failed.
9367f05d30Smrg       exit 1
9467f05d30Smrg    fi
9567f05d30Smrg
9667f05d30Smrg    echo 1>&2 "\
9767f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
9867f05d30Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
9967f05d30Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
10067f05d30Smrg         any GNU archive site."
10167f05d30Smrg    touch aclocal.m4
10267f05d30Smrg    ;;
10367f05d30Smrg
10467f05d30Smrg  autoconf)
10567f05d30Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
10667f05d30Smrg       # We have it, but it failed.
10767f05d30Smrg       exit 1
10867f05d30Smrg    fi
10967f05d30Smrg
11067f05d30Smrg    echo 1>&2 "\
11167f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
11267f05d30Smrg         you modified \`${configure_ac}'.  You might want to install the
11367f05d30Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
11467f05d30Smrg         archive site."
11567f05d30Smrg    touch configure
11667f05d30Smrg    ;;
11767f05d30Smrg
11867f05d30Smrg  autoheader)
11967f05d30Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12067f05d30Smrg       # We have it, but it failed.
12167f05d30Smrg       exit 1
12267f05d30Smrg    fi
12367f05d30Smrg
12467f05d30Smrg    echo 1>&2 "\
12567f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
12667f05d30Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
12767f05d30Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
12867f05d30Smrg         from any GNU archive site."
12967f05d30Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
13067f05d30Smrg    test -z "$files" && files="config.h"
13167f05d30Smrg    touch_files=
13267f05d30Smrg    for f in $files; do
13367f05d30Smrg      case "$f" in
13467f05d30Smrg      *:*) touch_files="$touch_files "`echo "$f" |
13567f05d30Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
13667f05d30Smrg      *) touch_files="$touch_files $f.in";;
13767f05d30Smrg      esac
13867f05d30Smrg    done
13967f05d30Smrg    touch $touch_files
14067f05d30Smrg    ;;
14167f05d30Smrg
14267f05d30Smrg  automake*)
14367f05d30Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
14467f05d30Smrg       # We have it, but it failed.
14567f05d30Smrg       exit 1
14667f05d30Smrg    fi
14767f05d30Smrg
14867f05d30Smrg    echo 1>&2 "\
14967f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
15067f05d30Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
15167f05d30Smrg         You might want to install the \`Automake' and \`Perl' packages.
15267f05d30Smrg         Grab them from any GNU archive site."
15367f05d30Smrg    find . -type f -name Makefile.am -print |
15467f05d30Smrg	   sed 's/\.am$/.in/' |
15567f05d30Smrg	   while read f; do touch "$f"; done
15667f05d30Smrg    ;;
15767f05d30Smrg
15867f05d30Smrg  autom4te)
15967f05d30Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
16067f05d30Smrg       # We have it, but it failed.
16167f05d30Smrg       exit 1
16267f05d30Smrg    fi
16367f05d30Smrg
16467f05d30Smrg    echo 1>&2 "\
16567f05d30SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
16667f05d30Smrg         system.  You might have modified some files without having the
16767f05d30Smrg         proper tools for further handling them.
16867f05d30Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
16967f05d30Smrg         archive site."
17067f05d30Smrg
17167f05d30Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
17267f05d30Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
17367f05d30Smrg    if test -f "$file"; then
17467f05d30Smrg	touch $file
17567f05d30Smrg    else
17667f05d30Smrg	test -z "$file" || exec >$file
17767f05d30Smrg	echo "#! /bin/sh"
17867f05d30Smrg	echo "# Created by GNU Automake missing as a replacement of"
17967f05d30Smrg	echo "#  $ $@"
18067f05d30Smrg	echo "exit 0"
18167f05d30Smrg	chmod +x $file
18267f05d30Smrg	exit 1
18367f05d30Smrg    fi
18467f05d30Smrg    ;;
18567f05d30Smrg
18667f05d30Smrg  bison|yacc)
18767f05d30Smrg    echo 1>&2 "\
18867f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
18967f05d30Smrg         you modified a \`.y' file.  You may need the \`Bison' package
19067f05d30Smrg         in order for those modifications to take effect.  You can get
19167f05d30Smrg         \`Bison' from any GNU archive site."
19267f05d30Smrg    rm -f y.tab.c y.tab.h
19367f05d30Smrg    if [ $# -ne 1 ]; then
19467f05d30Smrg        eval LASTARG="\${$#}"
19567f05d30Smrg	case "$LASTARG" in
19667f05d30Smrg	*.y)
19767f05d30Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
19867f05d30Smrg	    if [ -f "$SRCFILE" ]; then
19967f05d30Smrg	         cp "$SRCFILE" y.tab.c
20067f05d30Smrg	    fi
20167f05d30Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
20267f05d30Smrg	    if [ -f "$SRCFILE" ]; then
20367f05d30Smrg	         cp "$SRCFILE" y.tab.h
20467f05d30Smrg	    fi
20567f05d30Smrg	  ;;
20667f05d30Smrg	esac
20767f05d30Smrg    fi
20867f05d30Smrg    if [ ! -f y.tab.h ]; then
20967f05d30Smrg	echo >y.tab.h
21067f05d30Smrg    fi
21167f05d30Smrg    if [ ! -f y.tab.c ]; then
21267f05d30Smrg	echo 'main() { return 0; }' >y.tab.c
21367f05d30Smrg    fi
21467f05d30Smrg    ;;
21567f05d30Smrg
21667f05d30Smrg  lex|flex)
21767f05d30Smrg    echo 1>&2 "\
21867f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
21967f05d30Smrg         you modified a \`.l' file.  You may need the \`Flex' package
22067f05d30Smrg         in order for those modifications to take effect.  You can get
22167f05d30Smrg         \`Flex' from any GNU archive site."
22267f05d30Smrg    rm -f lex.yy.c
22367f05d30Smrg    if [ $# -ne 1 ]; then
22467f05d30Smrg        eval LASTARG="\${$#}"
22567f05d30Smrg	case "$LASTARG" in
22667f05d30Smrg	*.l)
22767f05d30Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
22867f05d30Smrg	    if [ -f "$SRCFILE" ]; then
22967f05d30Smrg	         cp "$SRCFILE" lex.yy.c
23067f05d30Smrg	    fi
23167f05d30Smrg	  ;;
23267f05d30Smrg	esac
23367f05d30Smrg    fi
23467f05d30Smrg    if [ ! -f lex.yy.c ]; then
23567f05d30Smrg	echo 'main() { return 0; }' >lex.yy.c
23667f05d30Smrg    fi
23767f05d30Smrg    ;;
23867f05d30Smrg
23967f05d30Smrg  help2man)
24067f05d30Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
24167f05d30Smrg       # We have it, but it failed.
24267f05d30Smrg       exit 1
24367f05d30Smrg    fi
24467f05d30Smrg
24567f05d30Smrg    echo 1>&2 "\
24667f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
24767f05d30Smrg	 you modified a dependency of a manual page.  You may need the
24867f05d30Smrg	 \`Help2man' package in order for those modifications to take
24967f05d30Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
25067f05d30Smrg
25167f05d30Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
25267f05d30Smrg    if test -z "$file"; then
25367f05d30Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
25467f05d30Smrg    fi
25567f05d30Smrg    if [ -f "$file" ]; then
25667f05d30Smrg	touch $file
25767f05d30Smrg    else
25867f05d30Smrg	test -z "$file" || exec >$file
25967f05d30Smrg	echo ".ab help2man is required to generate this page"
26067f05d30Smrg	exit 1
26167f05d30Smrg    fi
26267f05d30Smrg    ;;
26367f05d30Smrg
26467f05d30Smrg  makeinfo)
26567f05d30Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
26667f05d30Smrg       # We have makeinfo, but it failed.
26767f05d30Smrg       exit 1
26867f05d30Smrg    fi
26967f05d30Smrg
27067f05d30Smrg    echo 1>&2 "\
27167f05d30SmrgWARNING: \`$1' is missing on your system.  You should only need it if
27267f05d30Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
27367f05d30Smrg         indirectly affecting the aspect of the manual.  The spurious
27467f05d30Smrg         call might also be the consequence of using a buggy \`make' (AIX,
27567f05d30Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
27667f05d30Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
27767f05d30Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27867f05d30Smrg    if test -z "$file"; then
27967f05d30Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
28067f05d30Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
28167f05d30Smrg    fi
28267f05d30Smrg    touch $file
28367f05d30Smrg    ;;
28467f05d30Smrg
28567f05d30Smrg  tar)
28667f05d30Smrg    shift
28767f05d30Smrg    if test -n "$run"; then
28867f05d30Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
28967f05d30Smrg      exit 1
29067f05d30Smrg    fi
29167f05d30Smrg
29267f05d30Smrg    # We have already tried tar in the generic part.
29367f05d30Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
29467f05d30Smrg    # messages.
29567f05d30Smrg    if (gnutar --version > /dev/null 2>&1); then
29667f05d30Smrg       gnutar "$@" && exit 0
29767f05d30Smrg    fi
29867f05d30Smrg    if (gtar --version > /dev/null 2>&1); then
29967f05d30Smrg       gtar "$@" && exit 0
30067f05d30Smrg    fi
30167f05d30Smrg    firstarg="$1"
30267f05d30Smrg    if shift; then
30367f05d30Smrg	case "$firstarg" in
30467f05d30Smrg	*o*)
30567f05d30Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
30667f05d30Smrg	    tar "$firstarg" "$@" && exit 0
30767f05d30Smrg	    ;;
30867f05d30Smrg	esac
30967f05d30Smrg	case "$firstarg" in
31067f05d30Smrg	*h*)
31167f05d30Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
31267f05d30Smrg	    tar "$firstarg" "$@" && exit 0
31367f05d30Smrg	    ;;
31467f05d30Smrg	esac
31567f05d30Smrg    fi
31667f05d30Smrg
31767f05d30Smrg    echo 1>&2 "\
31867f05d30SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
31967f05d30Smrg         You may want to install GNU tar or Free paxutils, or check the
32067f05d30Smrg         command line arguments."
32167f05d30Smrg    exit 1
32267f05d30Smrg    ;;
32367f05d30Smrg
32467f05d30Smrg  *)
32567f05d30Smrg    echo 1>&2 "\
32667f05d30SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
32767f05d30Smrg         system.  You might have modified some files without having the
32867f05d30Smrg         proper tools for further handling them.  Check the \`README' file,
32967f05d30Smrg         it often tells you about the needed prerequisites for installing
33067f05d30Smrg         this package.  You may also peek at any GNU archive site, in case
33167f05d30Smrg         some other package would contain this missing \`$1' program."
33267f05d30Smrg    exit 1
33367f05d30Smrg    ;;
33467f05d30Smrgesac
33567f05d30Smrg
33667f05d30Smrgexit 0
337