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