missing revision 1fd23544
172b676d7Smrg#! /bin/sh
272b676d7Smrg# Common stub for a few missing GNU programs while installing.
372b676d7Smrg
41fd23544Smrgscriptversion=2006-05-10.23
572b676d7Smrg
61fd23544Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
772b676d7Smrg#   Free Software Foundation, Inc.
872b676d7Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
972b676d7Smrg
1072b676d7Smrg# This program is free software; you can redistribute it and/or modify
1172b676d7Smrg# it under the terms of the GNU General Public License as published by
1272b676d7Smrg# the Free Software Foundation; either version 2, or (at your option)
1372b676d7Smrg# any later version.
1472b676d7Smrg
1572b676d7Smrg# This program is distributed in the hope that it will be useful,
1672b676d7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1772b676d7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1872b676d7Smrg# GNU General Public License for more details.
1972b676d7Smrg
2072b676d7Smrg# You should have received a copy of the GNU General Public License
2172b676d7Smrg# along with this program; if not, write to the Free Software
2272b676d7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2372b676d7Smrg# 02110-1301, USA.
2472b676d7Smrg
2572b676d7Smrg# As a special exception to the GNU General Public License, if you
2672b676d7Smrg# distribute this file as part of a program that contains a
2772b676d7Smrg# configuration script generated by Autoconf, you may include it under
2872b676d7Smrg# the same distribution terms that you use for the rest of that program.
2972b676d7Smrg
3072b676d7Smrgif test $# -eq 0; then
3172b676d7Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3272b676d7Smrg  exit 1
3372b676d7Smrgfi
3472b676d7Smrg
3572b676d7Smrgrun=:
361fd23544Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
371fd23544Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3872b676d7Smrg
3972b676d7Smrg# In the cases where this matters, `missing' is being run in the
4072b676d7Smrg# srcdir already.
4172b676d7Smrgif test -f configure.ac; then
4272b676d7Smrg  configure_ac=configure.ac
4372b676d7Smrgelse
4472b676d7Smrg  configure_ac=configure.in
4572b676d7Smrgfi
4672b676d7Smrg
4772b676d7Smrgmsg="missing on your system"
4872b676d7Smrg
491fd23544Smrgcase $1 in
5072b676d7Smrg--run)
5172b676d7Smrg  # Try to run requested program, and just exit if it succeeds.
5272b676d7Smrg  run=
5372b676d7Smrg  shift
5472b676d7Smrg  "$@" && exit 0
5572b676d7Smrg  # Exit code 63 means version mismatch.  This often happens
5672b676d7Smrg  # when the user try to use an ancient version of a tool on
5772b676d7Smrg  # a file that requires a minimum version.  In this case we
5872b676d7Smrg  # we should proceed has if the program had been absent, or
5972b676d7Smrg  # if --run hadn't been passed.
6072b676d7Smrg  if test $? = 63; then
6172b676d7Smrg    run=:
6272b676d7Smrg    msg="probably too old"
6372b676d7Smrg  fi
6472b676d7Smrg  ;;
6572b676d7Smrg
6672b676d7Smrg  -h|--h|--he|--hel|--help)
6772b676d7Smrg    echo "\
6872b676d7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6972b676d7Smrg
7072b676d7SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7172b676d7Smrgerror status if there is no known handling for PROGRAM.
7272b676d7Smrg
7372b676d7SmrgOptions:
7472b676d7Smrg  -h, --help      display this help and exit
7572b676d7Smrg  -v, --version   output version information and exit
7672b676d7Smrg  --run           try to run the given command, and emulate it if it fails
7772b676d7Smrg
7872b676d7SmrgSupported PROGRAM values:
7972b676d7Smrg  aclocal      touch file \`aclocal.m4'
8072b676d7Smrg  autoconf     touch file \`configure'
8172b676d7Smrg  autoheader   touch file \`config.h.in'
821fd23544Smrg  autom4te     touch the output file, or create a stub one
8372b676d7Smrg  automake     touch all \`Makefile.in' files
8472b676d7Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8572b676d7Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8672b676d7Smrg  help2man     touch the output file
8772b676d7Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8872b676d7Smrg  makeinfo     touch the output file
8972b676d7Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9072b676d7Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9172b676d7Smrg
9272b676d7SmrgSend bug reports to <bug-automake@gnu.org>."
9372b676d7Smrg    exit $?
9472b676d7Smrg    ;;
9572b676d7Smrg
9672b676d7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9772b676d7Smrg    echo "missing $scriptversion (GNU Automake)"
9872b676d7Smrg    exit $?
9972b676d7Smrg    ;;
10072b676d7Smrg
10172b676d7Smrg  -*)
10272b676d7Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10372b676d7Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10472b676d7Smrg    exit 1
10572b676d7Smrg    ;;
10672b676d7Smrg
10772b676d7Smrgesac
10872b676d7Smrg
10972b676d7Smrg# Now exit if we have it, but it failed.  Also exit now if we
11072b676d7Smrg# don't have it and --version was passed (most likely to detect
11172b676d7Smrg# the program).
1121fd23544Smrgcase $1 in
11372b676d7Smrg  lex|yacc)
11472b676d7Smrg    # Not GNU programs, they don't have --version.
11572b676d7Smrg    ;;
11672b676d7Smrg
11772b676d7Smrg  tar)
11872b676d7Smrg    if test -n "$run"; then
11972b676d7Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12072b676d7Smrg       exit 1
12172b676d7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12272b676d7Smrg       exit 1
12372b676d7Smrg    fi
12472b676d7Smrg    ;;
12572b676d7Smrg
12672b676d7Smrg  *)
12772b676d7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12872b676d7Smrg       # We have it, but it failed.
12972b676d7Smrg       exit 1
13072b676d7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13172b676d7Smrg       # Could not run --version or --help.  This is probably someone
13272b676d7Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13372b676d7Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13472b676d7Smrg       exit 1
13572b676d7Smrg    fi
13672b676d7Smrg    ;;
13772b676d7Smrgesac
13872b676d7Smrg
13972b676d7Smrg# If it does not exist, or fails to run (possibly an outdated version),
14072b676d7Smrg# try to emulate it.
1411fd23544Smrgcase $1 in
14272b676d7Smrg  aclocal*)
14372b676d7Smrg    echo 1>&2 "\
14472b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
14572b676d7Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14672b676d7Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14772b676d7Smrg         any GNU archive site."
14872b676d7Smrg    touch aclocal.m4
14972b676d7Smrg    ;;
15072b676d7Smrg
15172b676d7Smrg  autoconf)
15272b676d7Smrg    echo 1>&2 "\
15372b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
15472b676d7Smrg         you modified \`${configure_ac}'.  You might want to install the
15572b676d7Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15672b676d7Smrg         archive site."
15772b676d7Smrg    touch configure
15872b676d7Smrg    ;;
15972b676d7Smrg
16072b676d7Smrg  autoheader)
16172b676d7Smrg    echo 1>&2 "\
16272b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
16372b676d7Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16472b676d7Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16572b676d7Smrg         from any GNU archive site."
16672b676d7Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16772b676d7Smrg    test -z "$files" && files="config.h"
16872b676d7Smrg    touch_files=
16972b676d7Smrg    for f in $files; do
1701fd23544Smrg      case $f in
17172b676d7Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17272b676d7Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17372b676d7Smrg      *) touch_files="$touch_files $f.in";;
17472b676d7Smrg      esac
17572b676d7Smrg    done
17672b676d7Smrg    touch $touch_files
17772b676d7Smrg    ;;
17872b676d7Smrg
17972b676d7Smrg  automake*)
18072b676d7Smrg    echo 1>&2 "\
18172b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
18272b676d7Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18372b676d7Smrg         You might want to install the \`Automake' and \`Perl' packages.
18472b676d7Smrg         Grab them from any GNU archive site."
18572b676d7Smrg    find . -type f -name Makefile.am -print |
18672b676d7Smrg	   sed 's/\.am$/.in/' |
18772b676d7Smrg	   while read f; do touch "$f"; done
18872b676d7Smrg    ;;
18972b676d7Smrg
19072b676d7Smrg  autom4te)
19172b676d7Smrg    echo 1>&2 "\
19272b676d7SmrgWARNING: \`$1' is needed, but is $msg.
19372b676d7Smrg         You might have modified some files without having the
19472b676d7Smrg         proper tools for further handling them.
19572b676d7Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19672b676d7Smrg         archive site."
19772b676d7Smrg
1981fd23544Smrg    file=`echo "$*" | sed -n "$sed_output"`
1991fd23544Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20072b676d7Smrg    if test -f "$file"; then
20172b676d7Smrg	touch $file
20272b676d7Smrg    else
20372b676d7Smrg	test -z "$file" || exec >$file
20472b676d7Smrg	echo "#! /bin/sh"
20572b676d7Smrg	echo "# Created by GNU Automake missing as a replacement of"
20672b676d7Smrg	echo "#  $ $@"
20772b676d7Smrg	echo "exit 0"
20872b676d7Smrg	chmod +x $file
20972b676d7Smrg	exit 1
21072b676d7Smrg    fi
21172b676d7Smrg    ;;
21272b676d7Smrg
21372b676d7Smrg  bison|yacc)
21472b676d7Smrg    echo 1>&2 "\
21572b676d7SmrgWARNING: \`$1' $msg.  You should only need it if
21672b676d7Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21772b676d7Smrg         in order for those modifications to take effect.  You can get
21872b676d7Smrg         \`Bison' from any GNU archive site."
21972b676d7Smrg    rm -f y.tab.c y.tab.h
2201fd23544Smrg    if test $# -ne 1; then
22172b676d7Smrg        eval LASTARG="\${$#}"
2221fd23544Smrg	case $LASTARG in
22372b676d7Smrg	*.y)
22472b676d7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2251fd23544Smrg	    if test -f "$SRCFILE"; then
22672b676d7Smrg	         cp "$SRCFILE" y.tab.c
22772b676d7Smrg	    fi
22872b676d7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2291fd23544Smrg	    if test -f "$SRCFILE"; then
23072b676d7Smrg	         cp "$SRCFILE" y.tab.h
23172b676d7Smrg	    fi
23272b676d7Smrg	  ;;
23372b676d7Smrg	esac
23472b676d7Smrg    fi
2351fd23544Smrg    if test ! -f y.tab.h; then
23672b676d7Smrg	echo >y.tab.h
23772b676d7Smrg    fi
2381fd23544Smrg    if test ! -f y.tab.c; then
23972b676d7Smrg	echo 'main() { return 0; }' >y.tab.c
24072b676d7Smrg    fi
24172b676d7Smrg    ;;
24272b676d7Smrg
24372b676d7Smrg  lex|flex)
24472b676d7Smrg    echo 1>&2 "\
24572b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
24672b676d7Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24772b676d7Smrg         in order for those modifications to take effect.  You can get
24872b676d7Smrg         \`Flex' from any GNU archive site."
24972b676d7Smrg    rm -f lex.yy.c
2501fd23544Smrg    if test $# -ne 1; then
25172b676d7Smrg        eval LASTARG="\${$#}"
2521fd23544Smrg	case $LASTARG in
25372b676d7Smrg	*.l)
25472b676d7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2551fd23544Smrg	    if test -f "$SRCFILE"; then
25672b676d7Smrg	         cp "$SRCFILE" lex.yy.c
25772b676d7Smrg	    fi
25872b676d7Smrg	  ;;
25972b676d7Smrg	esac
26072b676d7Smrg    fi
2611fd23544Smrg    if test ! -f lex.yy.c; then
26272b676d7Smrg	echo 'main() { return 0; }' >lex.yy.c
26372b676d7Smrg    fi
26472b676d7Smrg    ;;
26572b676d7Smrg
26672b676d7Smrg  help2man)
26772b676d7Smrg    echo 1>&2 "\
26872b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
26972b676d7Smrg	 you modified a dependency of a manual page.  You may need the
27072b676d7Smrg	 \`Help2man' package in order for those modifications to take
27172b676d7Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27272b676d7Smrg
2731fd23544Smrg    file=`echo "$*" | sed -n "$sed_output"`
2741fd23544Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2751fd23544Smrg    if test -f "$file"; then
27672b676d7Smrg	touch $file
27772b676d7Smrg    else
27872b676d7Smrg	test -z "$file" || exec >$file
27972b676d7Smrg	echo ".ab help2man is required to generate this page"
28072b676d7Smrg	exit 1
28172b676d7Smrg    fi
28272b676d7Smrg    ;;
28372b676d7Smrg
28472b676d7Smrg  makeinfo)
28572b676d7Smrg    echo 1>&2 "\
28672b676d7SmrgWARNING: \`$1' is $msg.  You should only need it if
28772b676d7Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28872b676d7Smrg         indirectly affecting the aspect of the manual.  The spurious
28972b676d7Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29072b676d7Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29172b676d7Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29272b676d7Smrg    # The file to touch is that specified with -o ...
2931fd23544Smrg    file=`echo "$*" | sed -n "$sed_output"`
2941fd23544Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29572b676d7Smrg    if test -z "$file"; then
29672b676d7Smrg      # ... or it is the one specified with @setfilename ...
29772b676d7Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2981fd23544Smrg      file=`sed -n '
2991fd23544Smrg	/^@setfilename/{
3001fd23544Smrg	  s/.* \([^ ]*\) *$/\1/
3011fd23544Smrg	  p
3021fd23544Smrg	  q
3031fd23544Smrg	}' $infile`
30472b676d7Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30572b676d7Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30672b676d7Smrg    fi
30772b676d7Smrg    # If the file does not exist, the user really needs makeinfo;
30872b676d7Smrg    # let's fail without touching anything.
30972b676d7Smrg    test -f $file || exit 1
31072b676d7Smrg    touch $file
31172b676d7Smrg    ;;
31272b676d7Smrg
31372b676d7Smrg  tar)
31472b676d7Smrg    shift
31572b676d7Smrg
31672b676d7Smrg    # We have already tried tar in the generic part.
31772b676d7Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31872b676d7Smrg    # messages.
31972b676d7Smrg    if (gnutar --version > /dev/null 2>&1); then
32072b676d7Smrg       gnutar "$@" && exit 0
32172b676d7Smrg    fi
32272b676d7Smrg    if (gtar --version > /dev/null 2>&1); then
32372b676d7Smrg       gtar "$@" && exit 0
32472b676d7Smrg    fi
32572b676d7Smrg    firstarg="$1"
32672b676d7Smrg    if shift; then
3271fd23544Smrg	case $firstarg in
32872b676d7Smrg	*o*)
32972b676d7Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33072b676d7Smrg	    tar "$firstarg" "$@" && exit 0
33172b676d7Smrg	    ;;
33272b676d7Smrg	esac
3331fd23544Smrg	case $firstarg in
33472b676d7Smrg	*h*)
33572b676d7Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33672b676d7Smrg	    tar "$firstarg" "$@" && exit 0
33772b676d7Smrg	    ;;
33872b676d7Smrg	esac
33972b676d7Smrg    fi
34072b676d7Smrg
34172b676d7Smrg    echo 1>&2 "\
34272b676d7SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34372b676d7Smrg         You may want to install GNU tar or Free paxutils, or check the
34472b676d7Smrg         command line arguments."
34572b676d7Smrg    exit 1
34672b676d7Smrg    ;;
34772b676d7Smrg
34872b676d7Smrg  *)
34972b676d7Smrg    echo 1>&2 "\
35072b676d7SmrgWARNING: \`$1' is needed, and is $msg.
35172b676d7Smrg         You might have modified some files without having the
35272b676d7Smrg         proper tools for further handling them.  Check the \`README' file,
35372b676d7Smrg         it often tells you about the needed prerequisites for installing
35472b676d7Smrg         this package.  You may also peek at any GNU archive site, in case
35572b676d7Smrg         some other package would contain this missing \`$1' program."
35672b676d7Smrg    exit 1
35772b676d7Smrg    ;;
35872b676d7Smrgesac
35972b676d7Smrg
36072b676d7Smrgexit 0
36172b676d7Smrg
36272b676d7Smrg# Local variables:
36372b676d7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36472b676d7Smrg# time-stamp-start: "scriptversion="
36572b676d7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36672b676d7Smrg# time-stamp-end: "$"
36772b676d7Smrg# End:
368