missing revision 8e0ed500
117a48c7cSmrg#! /bin/sh
217a48c7cSmrg# Common stub for a few missing GNU programs while installing.
317a48c7cSmrg
48e0ed500Smrgscriptversion=2006-05-10.23
517a48c7cSmrg
68e0ed500Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
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=:
368e0ed500Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
378e0ed500Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3817a48c7cSmrg
3917a48c7cSmrg# In the cases where this matters, `missing' is being run in the
4017a48c7cSmrg# srcdir already.
4117a48c7cSmrgif test -f configure.ac; then
4217a48c7cSmrg  configure_ac=configure.ac
4317a48c7cSmrgelse
4417a48c7cSmrg  configure_ac=configure.in
4517a48c7cSmrgfi
4617a48c7cSmrg
4717a48c7cSmrgmsg="missing on your system"
4817a48c7cSmrg
498e0ed500Smrgcase $1 in
5017a48c7cSmrg--run)
5117a48c7cSmrg  # Try to run requested program, and just exit if it succeeds.
5217a48c7cSmrg  run=
5317a48c7cSmrg  shift
5417a48c7cSmrg  "$@" && exit 0
5517a48c7cSmrg  # Exit code 63 means version mismatch.  This often happens
5617a48c7cSmrg  # when the user try to use an ancient version of a tool on
5717a48c7cSmrg  # a file that requires a minimum version.  In this case we
5817a48c7cSmrg  # we should proceed has if the program had been absent, or
5917a48c7cSmrg  # if --run hadn't been passed.
6017a48c7cSmrg  if test $? = 63; then
6117a48c7cSmrg    run=:
6217a48c7cSmrg    msg="probably too old"
6317a48c7cSmrg  fi
6417a48c7cSmrg  ;;
6517a48c7cSmrg
6617a48c7cSmrg  -h|--h|--he|--hel|--help)
6717a48c7cSmrg    echo "\
6817a48c7cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6917a48c7cSmrg
7017a48c7cSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7117a48c7cSmrgerror status if there is no known handling for PROGRAM.
7217a48c7cSmrg
7317a48c7cSmrgOptions:
7417a48c7cSmrg  -h, --help      display this help and exit
7517a48c7cSmrg  -v, --version   output version information and exit
7617a48c7cSmrg  --run           try to run the given command, and emulate it if it fails
7717a48c7cSmrg
7817a48c7cSmrgSupported PROGRAM values:
7917a48c7cSmrg  aclocal      touch file \`aclocal.m4'
8017a48c7cSmrg  autoconf     touch file \`configure'
8117a48c7cSmrg  autoheader   touch file \`config.h.in'
828e0ed500Smrg  autom4te     touch the output file, or create a stub one
8317a48c7cSmrg  automake     touch all \`Makefile.in' files
8417a48c7cSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8517a48c7cSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8617a48c7cSmrg  help2man     touch the output file
8717a48c7cSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8817a48c7cSmrg  makeinfo     touch the output file
8917a48c7cSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9017a48c7cSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9117a48c7cSmrg
9217a48c7cSmrgSend bug reports to <bug-automake@gnu.org>."
9317a48c7cSmrg    exit $?
9417a48c7cSmrg    ;;
9517a48c7cSmrg
9617a48c7cSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9717a48c7cSmrg    echo "missing $scriptversion (GNU Automake)"
9817a48c7cSmrg    exit $?
9917a48c7cSmrg    ;;
10017a48c7cSmrg
10117a48c7cSmrg  -*)
10217a48c7cSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10317a48c7cSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10417a48c7cSmrg    exit 1
10517a48c7cSmrg    ;;
10617a48c7cSmrg
10717a48c7cSmrgesac
10817a48c7cSmrg
10917a48c7cSmrg# Now exit if we have it, but it failed.  Also exit now if we
11017a48c7cSmrg# don't have it and --version was passed (most likely to detect
11117a48c7cSmrg# the program).
1128e0ed500Smrgcase $1 in
11317a48c7cSmrg  lex|yacc)
11417a48c7cSmrg    # Not GNU programs, they don't have --version.
11517a48c7cSmrg    ;;
11617a48c7cSmrg
11717a48c7cSmrg  tar)
11817a48c7cSmrg    if test -n "$run"; then
11917a48c7cSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
12017a48c7cSmrg       exit 1
12117a48c7cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12217a48c7cSmrg       exit 1
12317a48c7cSmrg    fi
12417a48c7cSmrg    ;;
12517a48c7cSmrg
12617a48c7cSmrg  *)
12717a48c7cSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12817a48c7cSmrg       # We have it, but it failed.
12917a48c7cSmrg       exit 1
13017a48c7cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13117a48c7cSmrg       # Could not run --version or --help.  This is probably someone
13217a48c7cSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13317a48c7cSmrg       # $TOOL exists and not knowing $TOOL uses missing.
13417a48c7cSmrg       exit 1
13517a48c7cSmrg    fi
13617a48c7cSmrg    ;;
13717a48c7cSmrgesac
13817a48c7cSmrg
13917a48c7cSmrg# If it does not exist, or fails to run (possibly an outdated version),
14017a48c7cSmrg# try to emulate it.
1418e0ed500Smrgcase $1 in
14217a48c7cSmrg  aclocal*)
14317a48c7cSmrg    echo 1>&2 "\
14417a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
14517a48c7cSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14617a48c7cSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14717a48c7cSmrg         any GNU archive site."
14817a48c7cSmrg    touch aclocal.m4
14917a48c7cSmrg    ;;
15017a48c7cSmrg
15117a48c7cSmrg  autoconf)
15217a48c7cSmrg    echo 1>&2 "\
15317a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
15417a48c7cSmrg         you modified \`${configure_ac}'.  You might want to install the
15517a48c7cSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15617a48c7cSmrg         archive site."
15717a48c7cSmrg    touch configure
15817a48c7cSmrg    ;;
15917a48c7cSmrg
16017a48c7cSmrg  autoheader)
16117a48c7cSmrg    echo 1>&2 "\
16217a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
16317a48c7cSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16417a48c7cSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16517a48c7cSmrg         from any GNU archive site."
16617a48c7cSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16717a48c7cSmrg    test -z "$files" && files="config.h"
16817a48c7cSmrg    touch_files=
16917a48c7cSmrg    for f in $files; do
1708e0ed500Smrg      case $f in
17117a48c7cSmrg      *:*) touch_files="$touch_files "`echo "$f" |
17217a48c7cSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17317a48c7cSmrg      *) touch_files="$touch_files $f.in";;
17417a48c7cSmrg      esac
17517a48c7cSmrg    done
17617a48c7cSmrg    touch $touch_files
17717a48c7cSmrg    ;;
17817a48c7cSmrg
17917a48c7cSmrg  automake*)
18017a48c7cSmrg    echo 1>&2 "\
18117a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
18217a48c7cSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18317a48c7cSmrg         You might want to install the \`Automake' and \`Perl' packages.
18417a48c7cSmrg         Grab them from any GNU archive site."
18517a48c7cSmrg    find . -type f -name Makefile.am -print |
18617a48c7cSmrg	   sed 's/\.am$/.in/' |
18717a48c7cSmrg	   while read f; do touch "$f"; done
18817a48c7cSmrg    ;;
18917a48c7cSmrg
19017a48c7cSmrg  autom4te)
19117a48c7cSmrg    echo 1>&2 "\
19217a48c7cSmrgWARNING: \`$1' is needed, but is $msg.
19317a48c7cSmrg         You might have modified some files without having the
19417a48c7cSmrg         proper tools for further handling them.
19517a48c7cSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
19617a48c7cSmrg         archive site."
19717a48c7cSmrg
1988e0ed500Smrg    file=`echo "$*" | sed -n "$sed_output"`
1998e0ed500Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20017a48c7cSmrg    if test -f "$file"; then
20117a48c7cSmrg	touch $file
20217a48c7cSmrg    else
20317a48c7cSmrg	test -z "$file" || exec >$file
20417a48c7cSmrg	echo "#! /bin/sh"
20517a48c7cSmrg	echo "# Created by GNU Automake missing as a replacement of"
20617a48c7cSmrg	echo "#  $ $@"
20717a48c7cSmrg	echo "exit 0"
20817a48c7cSmrg	chmod +x $file
20917a48c7cSmrg	exit 1
21017a48c7cSmrg    fi
21117a48c7cSmrg    ;;
21217a48c7cSmrg
21317a48c7cSmrg  bison|yacc)
21417a48c7cSmrg    echo 1>&2 "\
21517a48c7cSmrgWARNING: \`$1' $msg.  You should only need it if
21617a48c7cSmrg         you modified a \`.y' file.  You may need the \`Bison' package
21717a48c7cSmrg         in order for those modifications to take effect.  You can get
21817a48c7cSmrg         \`Bison' from any GNU archive site."
21917a48c7cSmrg    rm -f y.tab.c y.tab.h
2208e0ed500Smrg    if test $# -ne 1; then
22117a48c7cSmrg        eval LASTARG="\${$#}"
2228e0ed500Smrg	case $LASTARG in
22317a48c7cSmrg	*.y)
22417a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2258e0ed500Smrg	    if test -f "$SRCFILE"; then
22617a48c7cSmrg	         cp "$SRCFILE" y.tab.c
22717a48c7cSmrg	    fi
22817a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2298e0ed500Smrg	    if test -f "$SRCFILE"; then
23017a48c7cSmrg	         cp "$SRCFILE" y.tab.h
23117a48c7cSmrg	    fi
23217a48c7cSmrg	  ;;
23317a48c7cSmrg	esac
23417a48c7cSmrg    fi
2358e0ed500Smrg    if test ! -f y.tab.h; then
23617a48c7cSmrg	echo >y.tab.h
23717a48c7cSmrg    fi
2388e0ed500Smrg    if test ! -f y.tab.c; then
23917a48c7cSmrg	echo 'main() { return 0; }' >y.tab.c
24017a48c7cSmrg    fi
24117a48c7cSmrg    ;;
24217a48c7cSmrg
24317a48c7cSmrg  lex|flex)
24417a48c7cSmrg    echo 1>&2 "\
24517a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
24617a48c7cSmrg         you modified a \`.l' file.  You may need the \`Flex' package
24717a48c7cSmrg         in order for those modifications to take effect.  You can get
24817a48c7cSmrg         \`Flex' from any GNU archive site."
24917a48c7cSmrg    rm -f lex.yy.c
2508e0ed500Smrg    if test $# -ne 1; then
25117a48c7cSmrg        eval LASTARG="\${$#}"
2528e0ed500Smrg	case $LASTARG in
25317a48c7cSmrg	*.l)
25417a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2558e0ed500Smrg	    if test -f "$SRCFILE"; then
25617a48c7cSmrg	         cp "$SRCFILE" lex.yy.c
25717a48c7cSmrg	    fi
25817a48c7cSmrg	  ;;
25917a48c7cSmrg	esac
26017a48c7cSmrg    fi
2618e0ed500Smrg    if test ! -f lex.yy.c; then
26217a48c7cSmrg	echo 'main() { return 0; }' >lex.yy.c
26317a48c7cSmrg    fi
26417a48c7cSmrg    ;;
26517a48c7cSmrg
26617a48c7cSmrg  help2man)
26717a48c7cSmrg    echo 1>&2 "\
26817a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
26917a48c7cSmrg	 you modified a dependency of a manual page.  You may need the
27017a48c7cSmrg	 \`Help2man' package in order for those modifications to take
27117a48c7cSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
27217a48c7cSmrg
2738e0ed500Smrg    file=`echo "$*" | sed -n "$sed_output"`
2748e0ed500Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2758e0ed500Smrg    if test -f "$file"; then
27617a48c7cSmrg	touch $file
27717a48c7cSmrg    else
27817a48c7cSmrg	test -z "$file" || exec >$file
27917a48c7cSmrg	echo ".ab help2man is required to generate this page"
28017a48c7cSmrg	exit 1
28117a48c7cSmrg    fi
28217a48c7cSmrg    ;;
28317a48c7cSmrg
28417a48c7cSmrg  makeinfo)
28517a48c7cSmrg    echo 1>&2 "\
28617a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
28717a48c7cSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28817a48c7cSmrg         indirectly affecting the aspect of the manual.  The spurious
28917a48c7cSmrg         call might also be the consequence of using a buggy \`make' (AIX,
29017a48c7cSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29117a48c7cSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
29217a48c7cSmrg    # The file to touch is that specified with -o ...
2938e0ed500Smrg    file=`echo "$*" | sed -n "$sed_output"`
2948e0ed500Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29517a48c7cSmrg    if test -z "$file"; then
29617a48c7cSmrg      # ... or it is the one specified with @setfilename ...
29717a48c7cSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2988e0ed500Smrg      file=`sed -n '
2998e0ed500Smrg	/^@setfilename/{
3008e0ed500Smrg	  s/.* \([^ ]*\) *$/\1/
3018e0ed500Smrg	  p
3028e0ed500Smrg	  q
3038e0ed500Smrg	}' $infile`
30417a48c7cSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30517a48c7cSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30617a48c7cSmrg    fi
30717a48c7cSmrg    # If the file does not exist, the user really needs makeinfo;
30817a48c7cSmrg    # let's fail without touching anything.
30917a48c7cSmrg    test -f $file || exit 1
31017a48c7cSmrg    touch $file
31117a48c7cSmrg    ;;
31217a48c7cSmrg
31317a48c7cSmrg  tar)
31417a48c7cSmrg    shift
31517a48c7cSmrg
31617a48c7cSmrg    # We have already tried tar in the generic part.
31717a48c7cSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
31817a48c7cSmrg    # messages.
31917a48c7cSmrg    if (gnutar --version > /dev/null 2>&1); then
32017a48c7cSmrg       gnutar "$@" && exit 0
32117a48c7cSmrg    fi
32217a48c7cSmrg    if (gtar --version > /dev/null 2>&1); then
32317a48c7cSmrg       gtar "$@" && exit 0
32417a48c7cSmrg    fi
32517a48c7cSmrg    firstarg="$1"
32617a48c7cSmrg    if shift; then
3278e0ed500Smrg	case $firstarg in
32817a48c7cSmrg	*o*)
32917a48c7cSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
33017a48c7cSmrg	    tar "$firstarg" "$@" && exit 0
33117a48c7cSmrg	    ;;
33217a48c7cSmrg	esac
3338e0ed500Smrg	case $firstarg in
33417a48c7cSmrg	*h*)
33517a48c7cSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
33617a48c7cSmrg	    tar "$firstarg" "$@" && exit 0
33717a48c7cSmrg	    ;;
33817a48c7cSmrg	esac
33917a48c7cSmrg    fi
34017a48c7cSmrg
34117a48c7cSmrg    echo 1>&2 "\
34217a48c7cSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34317a48c7cSmrg         You may want to install GNU tar or Free paxutils, or check the
34417a48c7cSmrg         command line arguments."
34517a48c7cSmrg    exit 1
34617a48c7cSmrg    ;;
34717a48c7cSmrg
34817a48c7cSmrg  *)
34917a48c7cSmrg    echo 1>&2 "\
35017a48c7cSmrgWARNING: \`$1' is needed, and is $msg.
35117a48c7cSmrg         You might have modified some files without having the
35217a48c7cSmrg         proper tools for further handling them.  Check the \`README' file,
35317a48c7cSmrg         it often tells you about the needed prerequisites for installing
35417a48c7cSmrg         this package.  You may also peek at any GNU archive site, in case
35517a48c7cSmrg         some other package would contain this missing \`$1' program."
35617a48c7cSmrg    exit 1
35717a48c7cSmrg    ;;
35817a48c7cSmrgesac
35917a48c7cSmrg
36017a48c7cSmrgexit 0
36117a48c7cSmrg
36217a48c7cSmrg# Local variables:
36317a48c7cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36417a48c7cSmrg# time-stamp-start: "scriptversion="
36517a48c7cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36617a48c7cSmrg# time-stamp-end: "$"
36717a48c7cSmrg# End:
368