missing revision 17a48c7c
117a48c7cSmrg#! /bin/sh
217a48c7cSmrg# Common stub for a few missing GNU programs while installing.
317a48c7cSmrg
417a48c7cSmrgscriptversion=2005-06-08.21
517a48c7cSmrg
617a48c7cSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
717a48c7cSmrg#   Free Software Foundation, Inc.
817a48c7cSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
917a48c7cSmrg
1017a48c7cSmrg# This program is free software; you can redistribute it and/or modify
1117a48c7cSmrg# it under the terms of the GNU General Public License as published by
1217a48c7cSmrg# the Free Software Foundation; either version 2, or (at your option)
1317a48c7cSmrg# any later version.
1417a48c7cSmrg
1517a48c7cSmrg# This program is distributed in the hope that it will be useful,
1617a48c7cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1717a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1817a48c7cSmrg# GNU General Public License for more details.
1917a48c7cSmrg
2017a48c7cSmrg# You should have received a copy of the GNU General Public License
2117a48c7cSmrg# along with this program; if not, write to the Free Software
2217a48c7cSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2317a48c7cSmrg# 02110-1301, USA.
2417a48c7cSmrg
2517a48c7cSmrg# As a special exception to the GNU General Public License, if you
2617a48c7cSmrg# distribute this file as part of a program that contains a
2717a48c7cSmrg# configuration script generated by Autoconf, you may include it under
2817a48c7cSmrg# the same distribution terms that you use for the rest of that program.
2917a48c7cSmrg
3017a48c7cSmrgif test $# -eq 0; then
3117a48c7cSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3217a48c7cSmrg  exit 1
3317a48c7cSmrgfi
3417a48c7cSmrg
3517a48c7cSmrgrun=:
3617a48c7cSmrg
3717a48c7cSmrg# In the cases where this matters, `missing' is being run in the
3817a48c7cSmrg# srcdir already.
3917a48c7cSmrgif test -f configure.ac; then
4017a48c7cSmrg  configure_ac=configure.ac
4117a48c7cSmrgelse
4217a48c7cSmrg  configure_ac=configure.in
4317a48c7cSmrgfi
4417a48c7cSmrg
4517a48c7cSmrgmsg="missing on your system"
4617a48c7cSmrg
4717a48c7cSmrgcase "$1" in
4817a48c7cSmrg--run)
4917a48c7cSmrg  # Try to run requested program, and just exit if it succeeds.
5017a48c7cSmrg  run=
5117a48c7cSmrg  shift
5217a48c7cSmrg  "$@" && exit 0
5317a48c7cSmrg  # Exit code 63 means version mismatch.  This often happens
5417a48c7cSmrg  # when the user try to use an ancient version of a tool on
5517a48c7cSmrg  # a file that requires a minimum version.  In this case we
5617a48c7cSmrg  # we should proceed has if the program had been absent, or
5717a48c7cSmrg  # if --run hadn't been passed.
5817a48c7cSmrg  if test $? = 63; then
5917a48c7cSmrg    run=:
6017a48c7cSmrg    msg="probably too old"
6117a48c7cSmrg  fi
6217a48c7cSmrg  ;;
6317a48c7cSmrg
6417a48c7cSmrg  -h|--h|--he|--hel|--help)
6517a48c7cSmrg    echo "\
6617a48c7cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6717a48c7cSmrg
6817a48c7cSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6917a48c7cSmrgerror status if there is no known handling for PROGRAM.
7017a48c7cSmrg
7117a48c7cSmrgOptions:
7217a48c7cSmrg  -h, --help      display this help and exit
7317a48c7cSmrg  -v, --version   output version information and exit
7417a48c7cSmrg  --run           try to run the given command, and emulate it if it fails
7517a48c7cSmrg
7617a48c7cSmrgSupported PROGRAM values:
7717a48c7cSmrg  aclocal      touch file \`aclocal.m4'
7817a48c7cSmrg  autoconf     touch file \`configure'
7917a48c7cSmrg  autoheader   touch file \`config.h.in'
8017a48c7cSmrg  automake     touch all \`Makefile.in' files
8117a48c7cSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8217a48c7cSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8317a48c7cSmrg  help2man     touch the output file
8417a48c7cSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8517a48c7cSmrg  makeinfo     touch the output file
8617a48c7cSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8717a48c7cSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8817a48c7cSmrg
8917a48c7cSmrgSend bug reports to <bug-automake@gnu.org>."
9017a48c7cSmrg    exit $?
9117a48c7cSmrg    ;;
9217a48c7cSmrg
9317a48c7cSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9417a48c7cSmrg    echo "missing $scriptversion (GNU Automake)"
9517a48c7cSmrg    exit $?
9617a48c7cSmrg    ;;
9717a48c7cSmrg
9817a48c7cSmrg  -*)
9917a48c7cSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10017a48c7cSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10117a48c7cSmrg    exit 1
10217a48c7cSmrg    ;;
10317a48c7cSmrg
10417a48c7cSmrgesac
10517a48c7cSmrg
10617a48c7cSmrg# Now exit if we have it, but it failed.  Also exit now if we
10717a48c7cSmrg# don't have it and --version was passed (most likely to detect
10817a48c7cSmrg# the program).
10917a48c7cSmrgcase "$1" in
11017a48c7cSmrg  lex|yacc)
11117a48c7cSmrg    # Not GNU programs, they don't have --version.
11217a48c7cSmrg    ;;
11317a48c7cSmrg
11417a48c7cSmrg  tar)
11517a48c7cSmrg    if test -n "$run"; then
11617a48c7cSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
11717a48c7cSmrg       exit 1
11817a48c7cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
11917a48c7cSmrg       exit 1
12017a48c7cSmrg    fi
12117a48c7cSmrg    ;;
12217a48c7cSmrg
12317a48c7cSmrg  *)
12417a48c7cSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12517a48c7cSmrg       # We have it, but it failed.
12617a48c7cSmrg       exit 1
12717a48c7cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12817a48c7cSmrg       # Could not run --version or --help.  This is probably someone
12917a48c7cSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13017a48c7cSmrg       # $TOOL exists and not knowing $TOOL uses missing.
13117a48c7cSmrg       exit 1
13217a48c7cSmrg    fi
13317a48c7cSmrg    ;;
13417a48c7cSmrgesac
13517a48c7cSmrg
13617a48c7cSmrg# If it does not exist, or fails to run (possibly an outdated version),
13717a48c7cSmrg# try to emulate it.
13817a48c7cSmrgcase "$1" in
13917a48c7cSmrg  aclocal*)
14017a48c7cSmrg    echo 1>&2 "\
14117a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
14217a48c7cSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14317a48c7cSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14417a48c7cSmrg         any GNU archive site."
14517a48c7cSmrg    touch aclocal.m4
14617a48c7cSmrg    ;;
14717a48c7cSmrg
14817a48c7cSmrg  autoconf)
14917a48c7cSmrg    echo 1>&2 "\
15017a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
15117a48c7cSmrg         you modified \`${configure_ac}'.  You might want to install the
15217a48c7cSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15317a48c7cSmrg         archive site."
15417a48c7cSmrg    touch configure
15517a48c7cSmrg    ;;
15617a48c7cSmrg
15717a48c7cSmrg  autoheader)
15817a48c7cSmrg    echo 1>&2 "\
15917a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
16017a48c7cSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16117a48c7cSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16217a48c7cSmrg         from any GNU archive site."
16317a48c7cSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16417a48c7cSmrg    test -z "$files" && files="config.h"
16517a48c7cSmrg    touch_files=
16617a48c7cSmrg    for f in $files; do
16717a48c7cSmrg      case "$f" in
16817a48c7cSmrg      *:*) touch_files="$touch_files "`echo "$f" |
16917a48c7cSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17017a48c7cSmrg      *) touch_files="$touch_files $f.in";;
17117a48c7cSmrg      esac
17217a48c7cSmrg    done
17317a48c7cSmrg    touch $touch_files
17417a48c7cSmrg    ;;
17517a48c7cSmrg
17617a48c7cSmrg  automake*)
17717a48c7cSmrg    echo 1>&2 "\
17817a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
17917a48c7cSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18017a48c7cSmrg         You might want to install the \`Automake' and \`Perl' packages.
18117a48c7cSmrg         Grab them from any GNU archive site."
18217a48c7cSmrg    find . -type f -name Makefile.am -print |
18317a48c7cSmrg	   sed 's/\.am$/.in/' |
18417a48c7cSmrg	   while read f; do touch "$f"; done
18517a48c7cSmrg    ;;
18617a48c7cSmrg
18717a48c7cSmrg  autom4te)
18817a48c7cSmrg    echo 1>&2 "\
18917a48c7cSmrgWARNING: \`$1' is needed, but is $msg.
19017a48c7cSmrg         You might have modified some files without having the
19117a48c7cSmrg         proper tools for further handling them.
19217a48c7cSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
19317a48c7cSmrg         archive site."
19417a48c7cSmrg
19517a48c7cSmrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
19617a48c7cSmrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
19717a48c7cSmrg    if test -f "$file"; then
19817a48c7cSmrg	touch $file
19917a48c7cSmrg    else
20017a48c7cSmrg	test -z "$file" || exec >$file
20117a48c7cSmrg	echo "#! /bin/sh"
20217a48c7cSmrg	echo "# Created by GNU Automake missing as a replacement of"
20317a48c7cSmrg	echo "#  $ $@"
20417a48c7cSmrg	echo "exit 0"
20517a48c7cSmrg	chmod +x $file
20617a48c7cSmrg	exit 1
20717a48c7cSmrg    fi
20817a48c7cSmrg    ;;
20917a48c7cSmrg
21017a48c7cSmrg  bison|yacc)
21117a48c7cSmrg    echo 1>&2 "\
21217a48c7cSmrgWARNING: \`$1' $msg.  You should only need it if
21317a48c7cSmrg         you modified a \`.y' file.  You may need the \`Bison' package
21417a48c7cSmrg         in order for those modifications to take effect.  You can get
21517a48c7cSmrg         \`Bison' from any GNU archive site."
21617a48c7cSmrg    rm -f y.tab.c y.tab.h
21717a48c7cSmrg    if [ $# -ne 1 ]; then
21817a48c7cSmrg        eval LASTARG="\${$#}"
21917a48c7cSmrg	case "$LASTARG" in
22017a48c7cSmrg	*.y)
22117a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22217a48c7cSmrg	    if [ -f "$SRCFILE" ]; then
22317a48c7cSmrg	         cp "$SRCFILE" y.tab.c
22417a48c7cSmrg	    fi
22517a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22617a48c7cSmrg	    if [ -f "$SRCFILE" ]; then
22717a48c7cSmrg	         cp "$SRCFILE" y.tab.h
22817a48c7cSmrg	    fi
22917a48c7cSmrg	  ;;
23017a48c7cSmrg	esac
23117a48c7cSmrg    fi
23217a48c7cSmrg    if [ ! -f y.tab.h ]; then
23317a48c7cSmrg	echo >y.tab.h
23417a48c7cSmrg    fi
23517a48c7cSmrg    if [ ! -f y.tab.c ]; then
23617a48c7cSmrg	echo 'main() { return 0; }' >y.tab.c
23717a48c7cSmrg    fi
23817a48c7cSmrg    ;;
23917a48c7cSmrg
24017a48c7cSmrg  lex|flex)
24117a48c7cSmrg    echo 1>&2 "\
24217a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
24317a48c7cSmrg         you modified a \`.l' file.  You may need the \`Flex' package
24417a48c7cSmrg         in order for those modifications to take effect.  You can get
24517a48c7cSmrg         \`Flex' from any GNU archive site."
24617a48c7cSmrg    rm -f lex.yy.c
24717a48c7cSmrg    if [ $# -ne 1 ]; then
24817a48c7cSmrg        eval LASTARG="\${$#}"
24917a48c7cSmrg	case "$LASTARG" in
25017a48c7cSmrg	*.l)
25117a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25217a48c7cSmrg	    if [ -f "$SRCFILE" ]; then
25317a48c7cSmrg	         cp "$SRCFILE" lex.yy.c
25417a48c7cSmrg	    fi
25517a48c7cSmrg	  ;;
25617a48c7cSmrg	esac
25717a48c7cSmrg    fi
25817a48c7cSmrg    if [ ! -f lex.yy.c ]; then
25917a48c7cSmrg	echo 'main() { return 0; }' >lex.yy.c
26017a48c7cSmrg    fi
26117a48c7cSmrg    ;;
26217a48c7cSmrg
26317a48c7cSmrg  help2man)
26417a48c7cSmrg    echo 1>&2 "\
26517a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
26617a48c7cSmrg	 you modified a dependency of a manual page.  You may need the
26717a48c7cSmrg	 \`Help2man' package in order for those modifications to take
26817a48c7cSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
26917a48c7cSmrg
27017a48c7cSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27117a48c7cSmrg    if test -z "$file"; then
27217a48c7cSmrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27317a48c7cSmrg    fi
27417a48c7cSmrg    if [ -f "$file" ]; then
27517a48c7cSmrg	touch $file
27617a48c7cSmrg    else
27717a48c7cSmrg	test -z "$file" || exec >$file
27817a48c7cSmrg	echo ".ab help2man is required to generate this page"
27917a48c7cSmrg	exit 1
28017a48c7cSmrg    fi
28117a48c7cSmrg    ;;
28217a48c7cSmrg
28317a48c7cSmrg  makeinfo)
28417a48c7cSmrg    echo 1>&2 "\
28517a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
28617a48c7cSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28717a48c7cSmrg         indirectly affecting the aspect of the manual.  The spurious
28817a48c7cSmrg         call might also be the consequence of using a buggy \`make' (AIX,
28917a48c7cSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29017a48c7cSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
29117a48c7cSmrg    # The file to touch is that specified with -o ...
29217a48c7cSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29317a48c7cSmrg    if test -z "$file"; then
29417a48c7cSmrg      # ... or it is the one specified with @setfilename ...
29517a48c7cSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29617a48c7cSmrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
29717a48c7cSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
29817a48c7cSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29917a48c7cSmrg    fi
30017a48c7cSmrg    # If the file does not exist, the user really needs makeinfo;
30117a48c7cSmrg    # let's fail without touching anything.
30217a48c7cSmrg    test -f $file || exit 1
30317a48c7cSmrg    touch $file
30417a48c7cSmrg    ;;
30517a48c7cSmrg
30617a48c7cSmrg  tar)
30717a48c7cSmrg    shift
30817a48c7cSmrg
30917a48c7cSmrg    # We have already tried tar in the generic part.
31017a48c7cSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
31117a48c7cSmrg    # messages.
31217a48c7cSmrg    if (gnutar --version > /dev/null 2>&1); then
31317a48c7cSmrg       gnutar "$@" && exit 0
31417a48c7cSmrg    fi
31517a48c7cSmrg    if (gtar --version > /dev/null 2>&1); then
31617a48c7cSmrg       gtar "$@" && exit 0
31717a48c7cSmrg    fi
31817a48c7cSmrg    firstarg="$1"
31917a48c7cSmrg    if shift; then
32017a48c7cSmrg	case "$firstarg" in
32117a48c7cSmrg	*o*)
32217a48c7cSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
32317a48c7cSmrg	    tar "$firstarg" "$@" && exit 0
32417a48c7cSmrg	    ;;
32517a48c7cSmrg	esac
32617a48c7cSmrg	case "$firstarg" in
32717a48c7cSmrg	*h*)
32817a48c7cSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
32917a48c7cSmrg	    tar "$firstarg" "$@" && exit 0
33017a48c7cSmrg	    ;;
33117a48c7cSmrg	esac
33217a48c7cSmrg    fi
33317a48c7cSmrg
33417a48c7cSmrg    echo 1>&2 "\
33517a48c7cSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
33617a48c7cSmrg         You may want to install GNU tar or Free paxutils, or check the
33717a48c7cSmrg         command line arguments."
33817a48c7cSmrg    exit 1
33917a48c7cSmrg    ;;
34017a48c7cSmrg
34117a48c7cSmrg  *)
34217a48c7cSmrg    echo 1>&2 "\
34317a48c7cSmrgWARNING: \`$1' is needed, and is $msg.
34417a48c7cSmrg         You might have modified some files without having the
34517a48c7cSmrg         proper tools for further handling them.  Check the \`README' file,
34617a48c7cSmrg         it often tells you about the needed prerequisites for installing
34717a48c7cSmrg         this package.  You may also peek at any GNU archive site, in case
34817a48c7cSmrg         some other package would contain this missing \`$1' program."
34917a48c7cSmrg    exit 1
35017a48c7cSmrg    ;;
35117a48c7cSmrgesac
35217a48c7cSmrg
35317a48c7cSmrgexit 0
35417a48c7cSmrg
35517a48c7cSmrg# Local variables:
35617a48c7cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
35717a48c7cSmrg# time-stamp-start: "scriptversion="
35817a48c7cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
35917a48c7cSmrg# time-stamp-end: "$"
36017a48c7cSmrg# End:
361