missing revision 29459361
129459361Smrg#! /bin/sh
229459361Smrg# Common stub for a few missing GNU programs while installing.
329459361Smrg
429459361Smrgscriptversion=2005-06-08.21
529459361Smrg
629459361Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
729459361Smrg#   Free Software Foundation, Inc.
829459361Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
929459361Smrg
1029459361Smrg# This program is free software; you can redistribute it and/or modify
1129459361Smrg# it under the terms of the GNU General Public License as published by
1229459361Smrg# the Free Software Foundation; either version 2, or (at your option)
1329459361Smrg# any later version.
1429459361Smrg
1529459361Smrg# This program is distributed in the hope that it will be useful,
1629459361Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1729459361Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1829459361Smrg# GNU General Public License for more details.
1929459361Smrg
2029459361Smrg# You should have received a copy of the GNU General Public License
2129459361Smrg# along with this program; if not, write to the Free Software
2229459361Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2329459361Smrg# 02110-1301, USA.
2429459361Smrg
2529459361Smrg# As a special exception to the GNU General Public License, if you
2629459361Smrg# distribute this file as part of a program that contains a
2729459361Smrg# configuration script generated by Autoconf, you may include it under
2829459361Smrg# the same distribution terms that you use for the rest of that program.
2929459361Smrg
3029459361Smrgif test $# -eq 0; then
3129459361Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3229459361Smrg  exit 1
3329459361Smrgfi
3429459361Smrg
3529459361Smrgrun=:
3629459361Smrg
3729459361Smrg# In the cases where this matters, `missing' is being run in the
3829459361Smrg# srcdir already.
3929459361Smrgif test -f configure.ac; then
4029459361Smrg  configure_ac=configure.ac
4129459361Smrgelse
4229459361Smrg  configure_ac=configure.in
4329459361Smrgfi
4429459361Smrg
4529459361Smrgmsg="missing on your system"
4629459361Smrg
4729459361Smrgcase "$1" in
4829459361Smrg--run)
4929459361Smrg  # Try to run requested program, and just exit if it succeeds.
5029459361Smrg  run=
5129459361Smrg  shift
5229459361Smrg  "$@" && exit 0
5329459361Smrg  # Exit code 63 means version mismatch.  This often happens
5429459361Smrg  # when the user try to use an ancient version of a tool on
5529459361Smrg  # a file that requires a minimum version.  In this case we
5629459361Smrg  # we should proceed has if the program had been absent, or
5729459361Smrg  # if --run hadn't been passed.
5829459361Smrg  if test $? = 63; then
5929459361Smrg    run=:
6029459361Smrg    msg="probably too old"
6129459361Smrg  fi
6229459361Smrg  ;;
6329459361Smrg
6429459361Smrg  -h|--h|--he|--hel|--help)
6529459361Smrg    echo "\
6629459361Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6729459361Smrg
6829459361SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6929459361Smrgerror status if there is no known handling for PROGRAM.
7029459361Smrg
7129459361SmrgOptions:
7229459361Smrg  -h, --help      display this help and exit
7329459361Smrg  -v, --version   output version information and exit
7429459361Smrg  --run           try to run the given command, and emulate it if it fails
7529459361Smrg
7629459361SmrgSupported PROGRAM values:
7729459361Smrg  aclocal      touch file \`aclocal.m4'
7829459361Smrg  autoconf     touch file \`configure'
7929459361Smrg  autoheader   touch file \`config.h.in'
8029459361Smrg  automake     touch all \`Makefile.in' files
8129459361Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8229459361Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8329459361Smrg  help2man     touch the output file
8429459361Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8529459361Smrg  makeinfo     touch the output file
8629459361Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8729459361Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8829459361Smrg
8929459361SmrgSend bug reports to <bug-automake@gnu.org>."
9029459361Smrg    exit $?
9129459361Smrg    ;;
9229459361Smrg
9329459361Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9429459361Smrg    echo "missing $scriptversion (GNU Automake)"
9529459361Smrg    exit $?
9629459361Smrg    ;;
9729459361Smrg
9829459361Smrg  -*)
9929459361Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10029459361Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10129459361Smrg    exit 1
10229459361Smrg    ;;
10329459361Smrg
10429459361Smrgesac
10529459361Smrg
10629459361Smrg# Now exit if we have it, but it failed.  Also exit now if we
10729459361Smrg# don't have it and --version was passed (most likely to detect
10829459361Smrg# the program).
10929459361Smrgcase "$1" in
11029459361Smrg  lex|yacc)
11129459361Smrg    # Not GNU programs, they don't have --version.
11229459361Smrg    ;;
11329459361Smrg
11429459361Smrg  tar)
11529459361Smrg    if test -n "$run"; then
11629459361Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
11729459361Smrg       exit 1
11829459361Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
11929459361Smrg       exit 1
12029459361Smrg    fi
12129459361Smrg    ;;
12229459361Smrg
12329459361Smrg  *)
12429459361Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12529459361Smrg       # We have it, but it failed.
12629459361Smrg       exit 1
12729459361Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12829459361Smrg       # Could not run --version or --help.  This is probably someone
12929459361Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13029459361Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13129459361Smrg       exit 1
13229459361Smrg    fi
13329459361Smrg    ;;
13429459361Smrgesac
13529459361Smrg
13629459361Smrg# If it does not exist, or fails to run (possibly an outdated version),
13729459361Smrg# try to emulate it.
13829459361Smrgcase "$1" in
13929459361Smrg  aclocal*)
14029459361Smrg    echo 1>&2 "\
14129459361SmrgWARNING: \`$1' is $msg.  You should only need it if
14229459361Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14329459361Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14429459361Smrg         any GNU archive site."
14529459361Smrg    touch aclocal.m4
14629459361Smrg    ;;
14729459361Smrg
14829459361Smrg  autoconf)
14929459361Smrg    echo 1>&2 "\
15029459361SmrgWARNING: \`$1' is $msg.  You should only need it if
15129459361Smrg         you modified \`${configure_ac}'.  You might want to install the
15229459361Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15329459361Smrg         archive site."
15429459361Smrg    touch configure
15529459361Smrg    ;;
15629459361Smrg
15729459361Smrg  autoheader)
15829459361Smrg    echo 1>&2 "\
15929459361SmrgWARNING: \`$1' is $msg.  You should only need it if
16029459361Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16129459361Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16229459361Smrg         from any GNU archive site."
16329459361Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16429459361Smrg    test -z "$files" && files="config.h"
16529459361Smrg    touch_files=
16629459361Smrg    for f in $files; do
16729459361Smrg      case "$f" in
16829459361Smrg      *:*) touch_files="$touch_files "`echo "$f" |
16929459361Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17029459361Smrg      *) touch_files="$touch_files $f.in";;
17129459361Smrg      esac
17229459361Smrg    done
17329459361Smrg    touch $touch_files
17429459361Smrg    ;;
17529459361Smrg
17629459361Smrg  automake*)
17729459361Smrg    echo 1>&2 "\
17829459361SmrgWARNING: \`$1' is $msg.  You should only need it if
17929459361Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18029459361Smrg         You might want to install the \`Automake' and \`Perl' packages.
18129459361Smrg         Grab them from any GNU archive site."
18229459361Smrg    find . -type f -name Makefile.am -print |
18329459361Smrg	   sed 's/\.am$/.in/' |
18429459361Smrg	   while read f; do touch "$f"; done
18529459361Smrg    ;;
18629459361Smrg
18729459361Smrg  autom4te)
18829459361Smrg    echo 1>&2 "\
18929459361SmrgWARNING: \`$1' is needed, but is $msg.
19029459361Smrg         You might have modified some files without having the
19129459361Smrg         proper tools for further handling them.
19229459361Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19329459361Smrg         archive site."
19429459361Smrg
19529459361Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
19629459361Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
19729459361Smrg    if test -f "$file"; then
19829459361Smrg	touch $file
19929459361Smrg    else
20029459361Smrg	test -z "$file" || exec >$file
20129459361Smrg	echo "#! /bin/sh"
20229459361Smrg	echo "# Created by GNU Automake missing as a replacement of"
20329459361Smrg	echo "#  $ $@"
20429459361Smrg	echo "exit 0"
20529459361Smrg	chmod +x $file
20629459361Smrg	exit 1
20729459361Smrg    fi
20829459361Smrg    ;;
20929459361Smrg
21029459361Smrg  bison|yacc)
21129459361Smrg    echo 1>&2 "\
21229459361SmrgWARNING: \`$1' $msg.  You should only need it if
21329459361Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21429459361Smrg         in order for those modifications to take effect.  You can get
21529459361Smrg         \`Bison' from any GNU archive site."
21629459361Smrg    rm -f y.tab.c y.tab.h
21729459361Smrg    if [ $# -ne 1 ]; then
21829459361Smrg        eval LASTARG="\${$#}"
21929459361Smrg	case "$LASTARG" in
22029459361Smrg	*.y)
22129459361Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22229459361Smrg	    if [ -f "$SRCFILE" ]; then
22329459361Smrg	         cp "$SRCFILE" y.tab.c
22429459361Smrg	    fi
22529459361Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22629459361Smrg	    if [ -f "$SRCFILE" ]; then
22729459361Smrg	         cp "$SRCFILE" y.tab.h
22829459361Smrg	    fi
22929459361Smrg	  ;;
23029459361Smrg	esac
23129459361Smrg    fi
23229459361Smrg    if [ ! -f y.tab.h ]; then
23329459361Smrg	echo >y.tab.h
23429459361Smrg    fi
23529459361Smrg    if [ ! -f y.tab.c ]; then
23629459361Smrg	echo 'main() { return 0; }' >y.tab.c
23729459361Smrg    fi
23829459361Smrg    ;;
23929459361Smrg
24029459361Smrg  lex|flex)
24129459361Smrg    echo 1>&2 "\
24229459361SmrgWARNING: \`$1' is $msg.  You should only need it if
24329459361Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24429459361Smrg         in order for those modifications to take effect.  You can get
24529459361Smrg         \`Flex' from any GNU archive site."
24629459361Smrg    rm -f lex.yy.c
24729459361Smrg    if [ $# -ne 1 ]; then
24829459361Smrg        eval LASTARG="\${$#}"
24929459361Smrg	case "$LASTARG" in
25029459361Smrg	*.l)
25129459361Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25229459361Smrg	    if [ -f "$SRCFILE" ]; then
25329459361Smrg	         cp "$SRCFILE" lex.yy.c
25429459361Smrg	    fi
25529459361Smrg	  ;;
25629459361Smrg	esac
25729459361Smrg    fi
25829459361Smrg    if [ ! -f lex.yy.c ]; then
25929459361Smrg	echo 'main() { return 0; }' >lex.yy.c
26029459361Smrg    fi
26129459361Smrg    ;;
26229459361Smrg
26329459361Smrg  help2man)
26429459361Smrg    echo 1>&2 "\
26529459361SmrgWARNING: \`$1' is $msg.  You should only need it if
26629459361Smrg	 you modified a dependency of a manual page.  You may need the
26729459361Smrg	 \`Help2man' package in order for those modifications to take
26829459361Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
26929459361Smrg
27029459361Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27129459361Smrg    if test -z "$file"; then
27229459361Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27329459361Smrg    fi
27429459361Smrg    if [ -f "$file" ]; then
27529459361Smrg	touch $file
27629459361Smrg    else
27729459361Smrg	test -z "$file" || exec >$file
27829459361Smrg	echo ".ab help2man is required to generate this page"
27929459361Smrg	exit 1
28029459361Smrg    fi
28129459361Smrg    ;;
28229459361Smrg
28329459361Smrg  makeinfo)
28429459361Smrg    echo 1>&2 "\
28529459361SmrgWARNING: \`$1' is $msg.  You should only need it if
28629459361Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28729459361Smrg         indirectly affecting the aspect of the manual.  The spurious
28829459361Smrg         call might also be the consequence of using a buggy \`make' (AIX,
28929459361Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29029459361Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29129459361Smrg    # The file to touch is that specified with -o ...
29229459361Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29329459361Smrg    if test -z "$file"; then
29429459361Smrg      # ... or it is the one specified with @setfilename ...
29529459361Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29629459361Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
29729459361Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
29829459361Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29929459361Smrg    fi
30029459361Smrg    # If the file does not exist, the user really needs makeinfo;
30129459361Smrg    # let's fail without touching anything.
30229459361Smrg    test -f $file || exit 1
30329459361Smrg    touch $file
30429459361Smrg    ;;
30529459361Smrg
30629459361Smrg  tar)
30729459361Smrg    shift
30829459361Smrg
30929459361Smrg    # We have already tried tar in the generic part.
31029459361Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31129459361Smrg    # messages.
31229459361Smrg    if (gnutar --version > /dev/null 2>&1); then
31329459361Smrg       gnutar "$@" && exit 0
31429459361Smrg    fi
31529459361Smrg    if (gtar --version > /dev/null 2>&1); then
31629459361Smrg       gtar "$@" && exit 0
31729459361Smrg    fi
31829459361Smrg    firstarg="$1"
31929459361Smrg    if shift; then
32029459361Smrg	case "$firstarg" in
32129459361Smrg	*o*)
32229459361Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
32329459361Smrg	    tar "$firstarg" "$@" && exit 0
32429459361Smrg	    ;;
32529459361Smrg	esac
32629459361Smrg	case "$firstarg" in
32729459361Smrg	*h*)
32829459361Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
32929459361Smrg	    tar "$firstarg" "$@" && exit 0
33029459361Smrg	    ;;
33129459361Smrg	esac
33229459361Smrg    fi
33329459361Smrg
33429459361Smrg    echo 1>&2 "\
33529459361SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
33629459361Smrg         You may want to install GNU tar or Free paxutils, or check the
33729459361Smrg         command line arguments."
33829459361Smrg    exit 1
33929459361Smrg    ;;
34029459361Smrg
34129459361Smrg  *)
34229459361Smrg    echo 1>&2 "\
34329459361SmrgWARNING: \`$1' is needed, and is $msg.
34429459361Smrg         You might have modified some files without having the
34529459361Smrg         proper tools for further handling them.  Check the \`README' file,
34629459361Smrg         it often tells you about the needed prerequisites for installing
34729459361Smrg         this package.  You may also peek at any GNU archive site, in case
34829459361Smrg         some other package would contain this missing \`$1' program."
34929459361Smrg    exit 1
35029459361Smrg    ;;
35129459361Smrgesac
35229459361Smrg
35329459361Smrgexit 0
35429459361Smrg
35529459361Smrg# Local variables:
35629459361Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
35729459361Smrg# time-stamp-start: "scriptversion="
35829459361Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
35929459361Smrg# time-stamp-end: "$"
36029459361Smrg# End:
361