missing revision 43f32c10
143f32c10Smrg#! /bin/sh
243f32c10Smrg# Common stub for a few missing GNU programs while installing.
343f32c10Smrg
443f32c10Smrgscriptversion=2006-05-10.23
543f32c10Smrg
643f32c10Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
743f32c10Smrg#   Free Software Foundation, Inc.
843f32c10Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
943f32c10Smrg
1043f32c10Smrg# This program is free software; you can redistribute it and/or modify
1143f32c10Smrg# it under the terms of the GNU General Public License as published by
1243f32c10Smrg# the Free Software Foundation; either version 2, or (at your option)
1343f32c10Smrg# any later version.
1443f32c10Smrg
1543f32c10Smrg# This program is distributed in the hope that it will be useful,
1643f32c10Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1743f32c10Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1843f32c10Smrg# GNU General Public License for more details.
1943f32c10Smrg
2043f32c10Smrg# You should have received a copy of the GNU General Public License
2143f32c10Smrg# along with this program; if not, write to the Free Software
2243f32c10Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2343f32c10Smrg# 02110-1301, USA.
2443f32c10Smrg
2543f32c10Smrg# As a special exception to the GNU General Public License, if you
2643f32c10Smrg# distribute this file as part of a program that contains a
2743f32c10Smrg# configuration script generated by Autoconf, you may include it under
2843f32c10Smrg# the same distribution terms that you use for the rest of that program.
2943f32c10Smrg
3043f32c10Smrgif test $# -eq 0; then
3143f32c10Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3243f32c10Smrg  exit 1
3343f32c10Smrgfi
3443f32c10Smrg
3543f32c10Smrgrun=:
3643f32c10Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3743f32c10Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3843f32c10Smrg
3943f32c10Smrg# In the cases where this matters, `missing' is being run in the
4043f32c10Smrg# srcdir already.
4143f32c10Smrgif test -f configure.ac; then
4243f32c10Smrg  configure_ac=configure.ac
4343f32c10Smrgelse
4443f32c10Smrg  configure_ac=configure.in
4543f32c10Smrgfi
4643f32c10Smrg
4743f32c10Smrgmsg="missing on your system"
4843f32c10Smrg
4943f32c10Smrgcase $1 in
5043f32c10Smrg--run)
5143f32c10Smrg  # Try to run requested program, and just exit if it succeeds.
5243f32c10Smrg  run=
5343f32c10Smrg  shift
5443f32c10Smrg  "$@" && exit 0
5543f32c10Smrg  # Exit code 63 means version mismatch.  This often happens
5643f32c10Smrg  # when the user try to use an ancient version of a tool on
5743f32c10Smrg  # a file that requires a minimum version.  In this case we
5843f32c10Smrg  # we should proceed has if the program had been absent, or
5943f32c10Smrg  # if --run hadn't been passed.
6043f32c10Smrg  if test $? = 63; then
6143f32c10Smrg    run=:
6243f32c10Smrg    msg="probably too old"
6343f32c10Smrg  fi
6443f32c10Smrg  ;;
6543f32c10Smrg
6643f32c10Smrg  -h|--h|--he|--hel|--help)
6743f32c10Smrg    echo "\
6843f32c10Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6943f32c10Smrg
7043f32c10SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7143f32c10Smrgerror status if there is no known handling for PROGRAM.
7243f32c10Smrg
7343f32c10SmrgOptions:
7443f32c10Smrg  -h, --help      display this help and exit
7543f32c10Smrg  -v, --version   output version information and exit
7643f32c10Smrg  --run           try to run the given command, and emulate it if it fails
7743f32c10Smrg
7843f32c10SmrgSupported PROGRAM values:
7943f32c10Smrg  aclocal      touch file \`aclocal.m4'
8043f32c10Smrg  autoconf     touch file \`configure'
8143f32c10Smrg  autoheader   touch file \`config.h.in'
8243f32c10Smrg  autom4te     touch the output file, or create a stub one
8343f32c10Smrg  automake     touch all \`Makefile.in' files
8443f32c10Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8543f32c10Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8643f32c10Smrg  help2man     touch the output file
8743f32c10Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8843f32c10Smrg  makeinfo     touch the output file
8943f32c10Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9043f32c10Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9143f32c10Smrg
9243f32c10SmrgSend bug reports to <bug-automake@gnu.org>."
9343f32c10Smrg    exit $?
9443f32c10Smrg    ;;
9543f32c10Smrg
9643f32c10Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9743f32c10Smrg    echo "missing $scriptversion (GNU Automake)"
9843f32c10Smrg    exit $?
9943f32c10Smrg    ;;
10043f32c10Smrg
10143f32c10Smrg  -*)
10243f32c10Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10343f32c10Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10443f32c10Smrg    exit 1
10543f32c10Smrg    ;;
10643f32c10Smrg
10743f32c10Smrgesac
10843f32c10Smrg
10943f32c10Smrg# Now exit if we have it, but it failed.  Also exit now if we
11043f32c10Smrg# don't have it and --version was passed (most likely to detect
11143f32c10Smrg# the program).
11243f32c10Smrgcase $1 in
11343f32c10Smrg  lex|yacc)
11443f32c10Smrg    # Not GNU programs, they don't have --version.
11543f32c10Smrg    ;;
11643f32c10Smrg
11743f32c10Smrg  tar)
11843f32c10Smrg    if test -n "$run"; then
11943f32c10Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12043f32c10Smrg       exit 1
12143f32c10Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12243f32c10Smrg       exit 1
12343f32c10Smrg    fi
12443f32c10Smrg    ;;
12543f32c10Smrg
12643f32c10Smrg  *)
12743f32c10Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12843f32c10Smrg       # We have it, but it failed.
12943f32c10Smrg       exit 1
13043f32c10Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13143f32c10Smrg       # Could not run --version or --help.  This is probably someone
13243f32c10Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13343f32c10Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13443f32c10Smrg       exit 1
13543f32c10Smrg    fi
13643f32c10Smrg    ;;
13743f32c10Smrgesac
13843f32c10Smrg
13943f32c10Smrg# If it does not exist, or fails to run (possibly an outdated version),
14043f32c10Smrg# try to emulate it.
14143f32c10Smrgcase $1 in
14243f32c10Smrg  aclocal*)
14343f32c10Smrg    echo 1>&2 "\
14443f32c10SmrgWARNING: \`$1' is $msg.  You should only need it if
14543f32c10Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14643f32c10Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14743f32c10Smrg         any GNU archive site."
14843f32c10Smrg    touch aclocal.m4
14943f32c10Smrg    ;;
15043f32c10Smrg
15143f32c10Smrg  autoconf)
15243f32c10Smrg    echo 1>&2 "\
15343f32c10SmrgWARNING: \`$1' is $msg.  You should only need it if
15443f32c10Smrg         you modified \`${configure_ac}'.  You might want to install the
15543f32c10Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15643f32c10Smrg         archive site."
15743f32c10Smrg    touch configure
15843f32c10Smrg    ;;
15943f32c10Smrg
16043f32c10Smrg  autoheader)
16143f32c10Smrg    echo 1>&2 "\
16243f32c10SmrgWARNING: \`$1' is $msg.  You should only need it if
16343f32c10Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16443f32c10Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16543f32c10Smrg         from any GNU archive site."
16643f32c10Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16743f32c10Smrg    test -z "$files" && files="config.h"
16843f32c10Smrg    touch_files=
16943f32c10Smrg    for f in $files; do
17043f32c10Smrg      case $f in
17143f32c10Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17243f32c10Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17343f32c10Smrg      *) touch_files="$touch_files $f.in";;
17443f32c10Smrg      esac
17543f32c10Smrg    done
17643f32c10Smrg    touch $touch_files
17743f32c10Smrg    ;;
17843f32c10Smrg
17943f32c10Smrg  automake*)
18043f32c10Smrg    echo 1>&2 "\
18143f32c10SmrgWARNING: \`$1' is $msg.  You should only need it if
18243f32c10Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18343f32c10Smrg         You might want to install the \`Automake' and \`Perl' packages.
18443f32c10Smrg         Grab them from any GNU archive site."
18543f32c10Smrg    find . -type f -name Makefile.am -print |
18643f32c10Smrg	   sed 's/\.am$/.in/' |
18743f32c10Smrg	   while read f; do touch "$f"; done
18843f32c10Smrg    ;;
18943f32c10Smrg
19043f32c10Smrg  autom4te)
19143f32c10Smrg    echo 1>&2 "\
19243f32c10SmrgWARNING: \`$1' is needed, but is $msg.
19343f32c10Smrg         You might have modified some files without having the
19443f32c10Smrg         proper tools for further handling them.
19543f32c10Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19643f32c10Smrg         archive site."
19743f32c10Smrg
19843f32c10Smrg    file=`echo "$*" | sed -n "$sed_output"`
19943f32c10Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20043f32c10Smrg    if test -f "$file"; then
20143f32c10Smrg	touch $file
20243f32c10Smrg    else
20343f32c10Smrg	test -z "$file" || exec >$file
20443f32c10Smrg	echo "#! /bin/sh"
20543f32c10Smrg	echo "# Created by GNU Automake missing as a replacement of"
20643f32c10Smrg	echo "#  $ $@"
20743f32c10Smrg	echo "exit 0"
20843f32c10Smrg	chmod +x $file
20943f32c10Smrg	exit 1
21043f32c10Smrg    fi
21143f32c10Smrg    ;;
21243f32c10Smrg
21343f32c10Smrg  bison|yacc)
21443f32c10Smrg    echo 1>&2 "\
21543f32c10SmrgWARNING: \`$1' $msg.  You should only need it if
21643f32c10Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21743f32c10Smrg         in order for those modifications to take effect.  You can get
21843f32c10Smrg         \`Bison' from any GNU archive site."
21943f32c10Smrg    rm -f y.tab.c y.tab.h
22043f32c10Smrg    if test $# -ne 1; then
22143f32c10Smrg        eval LASTARG="\${$#}"
22243f32c10Smrg	case $LASTARG in
22343f32c10Smrg	*.y)
22443f32c10Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22543f32c10Smrg	    if test -f "$SRCFILE"; then
22643f32c10Smrg	         cp "$SRCFILE" y.tab.c
22743f32c10Smrg	    fi
22843f32c10Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22943f32c10Smrg	    if test -f "$SRCFILE"; then
23043f32c10Smrg	         cp "$SRCFILE" y.tab.h
23143f32c10Smrg	    fi
23243f32c10Smrg	  ;;
23343f32c10Smrg	esac
23443f32c10Smrg    fi
23543f32c10Smrg    if test ! -f y.tab.h; then
23643f32c10Smrg	echo >y.tab.h
23743f32c10Smrg    fi
23843f32c10Smrg    if test ! -f y.tab.c; then
23943f32c10Smrg	echo 'main() { return 0; }' >y.tab.c
24043f32c10Smrg    fi
24143f32c10Smrg    ;;
24243f32c10Smrg
24343f32c10Smrg  lex|flex)
24443f32c10Smrg    echo 1>&2 "\
24543f32c10SmrgWARNING: \`$1' is $msg.  You should only need it if
24643f32c10Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24743f32c10Smrg         in order for those modifications to take effect.  You can get
24843f32c10Smrg         \`Flex' from any GNU archive site."
24943f32c10Smrg    rm -f lex.yy.c
25043f32c10Smrg    if test $# -ne 1; then
25143f32c10Smrg        eval LASTARG="\${$#}"
25243f32c10Smrg	case $LASTARG in
25343f32c10Smrg	*.l)
25443f32c10Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25543f32c10Smrg	    if test -f "$SRCFILE"; then
25643f32c10Smrg	         cp "$SRCFILE" lex.yy.c
25743f32c10Smrg	    fi
25843f32c10Smrg	  ;;
25943f32c10Smrg	esac
26043f32c10Smrg    fi
26143f32c10Smrg    if test ! -f lex.yy.c; then
26243f32c10Smrg	echo 'main() { return 0; }' >lex.yy.c
26343f32c10Smrg    fi
26443f32c10Smrg    ;;
26543f32c10Smrg
26643f32c10Smrg  help2man)
26743f32c10Smrg    echo 1>&2 "\
26843f32c10SmrgWARNING: \`$1' is $msg.  You should only need it if
26943f32c10Smrg	 you modified a dependency of a manual page.  You may need the
27043f32c10Smrg	 \`Help2man' package in order for those modifications to take
27143f32c10Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27243f32c10Smrg
27343f32c10Smrg    file=`echo "$*" | sed -n "$sed_output"`
27443f32c10Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
27543f32c10Smrg    if test -f "$file"; then
27643f32c10Smrg	touch $file
27743f32c10Smrg    else
27843f32c10Smrg	test -z "$file" || exec >$file
27943f32c10Smrg	echo ".ab help2man is required to generate this page"
28043f32c10Smrg	exit 1
28143f32c10Smrg    fi
28243f32c10Smrg    ;;
28343f32c10Smrg
28443f32c10Smrg  makeinfo)
28543f32c10Smrg    echo 1>&2 "\
28643f32c10SmrgWARNING: \`$1' is $msg.  You should only need it if
28743f32c10Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28843f32c10Smrg         indirectly affecting the aspect of the manual.  The spurious
28943f32c10Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29043f32c10Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29143f32c10Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29243f32c10Smrg    # The file to touch is that specified with -o ...
29343f32c10Smrg    file=`echo "$*" | sed -n "$sed_output"`
29443f32c10Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29543f32c10Smrg    if test -z "$file"; then
29643f32c10Smrg      # ... or it is the one specified with @setfilename ...
29743f32c10Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29843f32c10Smrg      file=`sed -n '
29943f32c10Smrg	/^@setfilename/{
30043f32c10Smrg	  s/.* \([^ ]*\) *$/\1/
30143f32c10Smrg	  p
30243f32c10Smrg	  q
30343f32c10Smrg	}' $infile`
30443f32c10Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30543f32c10Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30643f32c10Smrg    fi
30743f32c10Smrg    # If the file does not exist, the user really needs makeinfo;
30843f32c10Smrg    # let's fail without touching anything.
30943f32c10Smrg    test -f $file || exit 1
31043f32c10Smrg    touch $file
31143f32c10Smrg    ;;
31243f32c10Smrg
31343f32c10Smrg  tar)
31443f32c10Smrg    shift
31543f32c10Smrg
31643f32c10Smrg    # We have already tried tar in the generic part.
31743f32c10Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31843f32c10Smrg    # messages.
31943f32c10Smrg    if (gnutar --version > /dev/null 2>&1); then
32043f32c10Smrg       gnutar "$@" && exit 0
32143f32c10Smrg    fi
32243f32c10Smrg    if (gtar --version > /dev/null 2>&1); then
32343f32c10Smrg       gtar "$@" && exit 0
32443f32c10Smrg    fi
32543f32c10Smrg    firstarg="$1"
32643f32c10Smrg    if shift; then
32743f32c10Smrg	case $firstarg in
32843f32c10Smrg	*o*)
32943f32c10Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33043f32c10Smrg	    tar "$firstarg" "$@" && exit 0
33143f32c10Smrg	    ;;
33243f32c10Smrg	esac
33343f32c10Smrg	case $firstarg in
33443f32c10Smrg	*h*)
33543f32c10Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33643f32c10Smrg	    tar "$firstarg" "$@" && exit 0
33743f32c10Smrg	    ;;
33843f32c10Smrg	esac
33943f32c10Smrg    fi
34043f32c10Smrg
34143f32c10Smrg    echo 1>&2 "\
34243f32c10SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34343f32c10Smrg         You may want to install GNU tar or Free paxutils, or check the
34443f32c10Smrg         command line arguments."
34543f32c10Smrg    exit 1
34643f32c10Smrg    ;;
34743f32c10Smrg
34843f32c10Smrg  *)
34943f32c10Smrg    echo 1>&2 "\
35043f32c10SmrgWARNING: \`$1' is needed, and is $msg.
35143f32c10Smrg         You might have modified some files without having the
35243f32c10Smrg         proper tools for further handling them.  Check the \`README' file,
35343f32c10Smrg         it often tells you about the needed prerequisites for installing
35443f32c10Smrg         this package.  You may also peek at any GNU archive site, in case
35543f32c10Smrg         some other package would contain this missing \`$1' program."
35643f32c10Smrg    exit 1
35743f32c10Smrg    ;;
35843f32c10Smrgesac
35943f32c10Smrg
36043f32c10Smrgexit 0
36143f32c10Smrg
36243f32c10Smrg# Local variables:
36343f32c10Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36443f32c10Smrg# time-stamp-start: "scriptversion="
36543f32c10Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36643f32c10Smrg# time-stamp-end: "$"
36743f32c10Smrg# End:
368