missing revision 21c2f794
121c2f794Smrg#! /bin/sh
221c2f794Smrg# Common stub for a few missing GNU programs while installing.
321c2f794Smrg
421c2f794Smrgscriptversion=2006-05-10.23
521c2f794Smrg
621c2f794Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
721c2f794Smrg#   Free Software Foundation, Inc.
821c2f794Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
921c2f794Smrg
1021c2f794Smrg# This program is free software; you can redistribute it and/or modify
1121c2f794Smrg# it under the terms of the GNU General Public License as published by
1221c2f794Smrg# the Free Software Foundation; either version 2, or (at your option)
1321c2f794Smrg# any later version.
1421c2f794Smrg
1521c2f794Smrg# This program is distributed in the hope that it will be useful,
1621c2f794Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1721c2f794Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1821c2f794Smrg# GNU General Public License for more details.
1921c2f794Smrg
2021c2f794Smrg# You should have received a copy of the GNU General Public License
2121c2f794Smrg# along with this program; if not, write to the Free Software
2221c2f794Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2321c2f794Smrg# 02110-1301, USA.
2421c2f794Smrg
2521c2f794Smrg# As a special exception to the GNU General Public License, if you
2621c2f794Smrg# distribute this file as part of a program that contains a
2721c2f794Smrg# configuration script generated by Autoconf, you may include it under
2821c2f794Smrg# the same distribution terms that you use for the rest of that program.
2921c2f794Smrg
3021c2f794Smrgif test $# -eq 0; then
3121c2f794Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3221c2f794Smrg  exit 1
3321c2f794Smrgfi
3421c2f794Smrg
3521c2f794Smrgrun=:
3621c2f794Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3721c2f794Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3821c2f794Smrg
3921c2f794Smrg# In the cases where this matters, `missing' is being run in the
4021c2f794Smrg# srcdir already.
4121c2f794Smrgif test -f configure.ac; then
4221c2f794Smrg  configure_ac=configure.ac
4321c2f794Smrgelse
4421c2f794Smrg  configure_ac=configure.in
4521c2f794Smrgfi
4621c2f794Smrg
4721c2f794Smrgmsg="missing on your system"
4821c2f794Smrg
4921c2f794Smrgcase $1 in
5021c2f794Smrg--run)
5121c2f794Smrg  # Try to run requested program, and just exit if it succeeds.
5221c2f794Smrg  run=
5321c2f794Smrg  shift
5421c2f794Smrg  "$@" && exit 0
5521c2f794Smrg  # Exit code 63 means version mismatch.  This often happens
5621c2f794Smrg  # when the user try to use an ancient version of a tool on
5721c2f794Smrg  # a file that requires a minimum version.  In this case we
5821c2f794Smrg  # we should proceed has if the program had been absent, or
5921c2f794Smrg  # if --run hadn't been passed.
6021c2f794Smrg  if test $? = 63; then
6121c2f794Smrg    run=:
6221c2f794Smrg    msg="probably too old"
6321c2f794Smrg  fi
6421c2f794Smrg  ;;
6521c2f794Smrg
6621c2f794Smrg  -h|--h|--he|--hel|--help)
6721c2f794Smrg    echo "\
6821c2f794Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6921c2f794Smrg
7021c2f794SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7121c2f794Smrgerror status if there is no known handling for PROGRAM.
7221c2f794Smrg
7321c2f794SmrgOptions:
7421c2f794Smrg  -h, --help      display this help and exit
7521c2f794Smrg  -v, --version   output version information and exit
7621c2f794Smrg  --run           try to run the given command, and emulate it if it fails
7721c2f794Smrg
7821c2f794SmrgSupported PROGRAM values:
7921c2f794Smrg  aclocal      touch file \`aclocal.m4'
8021c2f794Smrg  autoconf     touch file \`configure'
8121c2f794Smrg  autoheader   touch file \`config.h.in'
8221c2f794Smrg  autom4te     touch the output file, or create a stub one
8321c2f794Smrg  automake     touch all \`Makefile.in' files
8421c2f794Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8521c2f794Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8621c2f794Smrg  help2man     touch the output file
8721c2f794Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8821c2f794Smrg  makeinfo     touch the output file
8921c2f794Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9021c2f794Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9121c2f794Smrg
9221c2f794SmrgSend bug reports to <bug-automake@gnu.org>."
9321c2f794Smrg    exit $?
9421c2f794Smrg    ;;
9521c2f794Smrg
9621c2f794Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9721c2f794Smrg    echo "missing $scriptversion (GNU Automake)"
9821c2f794Smrg    exit $?
9921c2f794Smrg    ;;
10021c2f794Smrg
10121c2f794Smrg  -*)
10221c2f794Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10321c2f794Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10421c2f794Smrg    exit 1
10521c2f794Smrg    ;;
10621c2f794Smrg
10721c2f794Smrgesac
10821c2f794Smrg
10921c2f794Smrg# Now exit if we have it, but it failed.  Also exit now if we
11021c2f794Smrg# don't have it and --version was passed (most likely to detect
11121c2f794Smrg# the program).
11221c2f794Smrgcase $1 in
11321c2f794Smrg  lex|yacc)
11421c2f794Smrg    # Not GNU programs, they don't have --version.
11521c2f794Smrg    ;;
11621c2f794Smrg
11721c2f794Smrg  tar)
11821c2f794Smrg    if test -n "$run"; then
11921c2f794Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12021c2f794Smrg       exit 1
12121c2f794Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12221c2f794Smrg       exit 1
12321c2f794Smrg    fi
12421c2f794Smrg    ;;
12521c2f794Smrg
12621c2f794Smrg  *)
12721c2f794Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12821c2f794Smrg       # We have it, but it failed.
12921c2f794Smrg       exit 1
13021c2f794Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13121c2f794Smrg       # Could not run --version or --help.  This is probably someone
13221c2f794Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13321c2f794Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13421c2f794Smrg       exit 1
13521c2f794Smrg    fi
13621c2f794Smrg    ;;
13721c2f794Smrgesac
13821c2f794Smrg
13921c2f794Smrg# If it does not exist, or fails to run (possibly an outdated version),
14021c2f794Smrg# try to emulate it.
14121c2f794Smrgcase $1 in
14221c2f794Smrg  aclocal*)
14321c2f794Smrg    echo 1>&2 "\
14421c2f794SmrgWARNING: \`$1' is $msg.  You should only need it if
14521c2f794Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14621c2f794Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14721c2f794Smrg         any GNU archive site."
14821c2f794Smrg    touch aclocal.m4
14921c2f794Smrg    ;;
15021c2f794Smrg
15121c2f794Smrg  autoconf)
15221c2f794Smrg    echo 1>&2 "\
15321c2f794SmrgWARNING: \`$1' is $msg.  You should only need it if
15421c2f794Smrg         you modified \`${configure_ac}'.  You might want to install the
15521c2f794Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15621c2f794Smrg         archive site."
15721c2f794Smrg    touch configure
15821c2f794Smrg    ;;
15921c2f794Smrg
16021c2f794Smrg  autoheader)
16121c2f794Smrg    echo 1>&2 "\
16221c2f794SmrgWARNING: \`$1' is $msg.  You should only need it if
16321c2f794Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16421c2f794Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16521c2f794Smrg         from any GNU archive site."
16621c2f794Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16721c2f794Smrg    test -z "$files" && files="config.h"
16821c2f794Smrg    touch_files=
16921c2f794Smrg    for f in $files; do
17021c2f794Smrg      case $f in
17121c2f794Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17221c2f794Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17321c2f794Smrg      *) touch_files="$touch_files $f.in";;
17421c2f794Smrg      esac
17521c2f794Smrg    done
17621c2f794Smrg    touch $touch_files
17721c2f794Smrg    ;;
17821c2f794Smrg
17921c2f794Smrg  automake*)
18021c2f794Smrg    echo 1>&2 "\
18121c2f794SmrgWARNING: \`$1' is $msg.  You should only need it if
18221c2f794Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18321c2f794Smrg         You might want to install the \`Automake' and \`Perl' packages.
18421c2f794Smrg         Grab them from any GNU archive site."
18521c2f794Smrg    find . -type f -name Makefile.am -print |
18621c2f794Smrg	   sed 's/\.am$/.in/' |
18721c2f794Smrg	   while read f; do touch "$f"; done
18821c2f794Smrg    ;;
18921c2f794Smrg
19021c2f794Smrg  autom4te)
19121c2f794Smrg    echo 1>&2 "\
19221c2f794SmrgWARNING: \`$1' is needed, but is $msg.
19321c2f794Smrg         You might have modified some files without having the
19421c2f794Smrg         proper tools for further handling them.
19521c2f794Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19621c2f794Smrg         archive site."
19721c2f794Smrg
19821c2f794Smrg    file=`echo "$*" | sed -n "$sed_output"`
19921c2f794Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20021c2f794Smrg    if test -f "$file"; then
20121c2f794Smrg	touch $file
20221c2f794Smrg    else
20321c2f794Smrg	test -z "$file" || exec >$file
20421c2f794Smrg	echo "#! /bin/sh"
20521c2f794Smrg	echo "# Created by GNU Automake missing as a replacement of"
20621c2f794Smrg	echo "#  $ $@"
20721c2f794Smrg	echo "exit 0"
20821c2f794Smrg	chmod +x $file
20921c2f794Smrg	exit 1
21021c2f794Smrg    fi
21121c2f794Smrg    ;;
21221c2f794Smrg
21321c2f794Smrg  bison|yacc)
21421c2f794Smrg    echo 1>&2 "\
21521c2f794SmrgWARNING: \`$1' $msg.  You should only need it if
21621c2f794Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21721c2f794Smrg         in order for those modifications to take effect.  You can get
21821c2f794Smrg         \`Bison' from any GNU archive site."
21921c2f794Smrg    rm -f y.tab.c y.tab.h
22021c2f794Smrg    if test $# -ne 1; then
22121c2f794Smrg        eval LASTARG="\${$#}"
22221c2f794Smrg	case $LASTARG in
22321c2f794Smrg	*.y)
22421c2f794Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22521c2f794Smrg	    if test -f "$SRCFILE"; then
22621c2f794Smrg	         cp "$SRCFILE" y.tab.c
22721c2f794Smrg	    fi
22821c2f794Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22921c2f794Smrg	    if test -f "$SRCFILE"; then
23021c2f794Smrg	         cp "$SRCFILE" y.tab.h
23121c2f794Smrg	    fi
23221c2f794Smrg	  ;;
23321c2f794Smrg	esac
23421c2f794Smrg    fi
23521c2f794Smrg    if test ! -f y.tab.h; then
23621c2f794Smrg	echo >y.tab.h
23721c2f794Smrg    fi
23821c2f794Smrg    if test ! -f y.tab.c; then
23921c2f794Smrg	echo 'main() { return 0; }' >y.tab.c
24021c2f794Smrg    fi
24121c2f794Smrg    ;;
24221c2f794Smrg
24321c2f794Smrg  lex|flex)
24421c2f794Smrg    echo 1>&2 "\
24521c2f794SmrgWARNING: \`$1' is $msg.  You should only need it if
24621c2f794Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24721c2f794Smrg         in order for those modifications to take effect.  You can get
24821c2f794Smrg         \`Flex' from any GNU archive site."
24921c2f794Smrg    rm -f lex.yy.c
25021c2f794Smrg    if test $# -ne 1; then
25121c2f794Smrg        eval LASTARG="\${$#}"
25221c2f794Smrg	case $LASTARG in
25321c2f794Smrg	*.l)
25421c2f794Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25521c2f794Smrg	    if test -f "$SRCFILE"; then
25621c2f794Smrg	         cp "$SRCFILE" lex.yy.c
25721c2f794Smrg	    fi
25821c2f794Smrg	  ;;
25921c2f794Smrg	esac
26021c2f794Smrg    fi
26121c2f794Smrg    if test ! -f lex.yy.c; then
26221c2f794Smrg	echo 'main() { return 0; }' >lex.yy.c
26321c2f794Smrg    fi
26421c2f794Smrg    ;;
26521c2f794Smrg
26621c2f794Smrg  help2man)
26721c2f794Smrg    echo 1>&2 "\
26821c2f794SmrgWARNING: \`$1' is $msg.  You should only need it if
26921c2f794Smrg	 you modified a dependency of a manual page.  You may need the
27021c2f794Smrg	 \`Help2man' package in order for those modifications to take
27121c2f794Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27221c2f794Smrg
27321c2f794Smrg    file=`echo "$*" | sed -n "$sed_output"`
27421c2f794Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
27521c2f794Smrg    if test -f "$file"; then
27621c2f794Smrg	touch $file
27721c2f794Smrg    else
27821c2f794Smrg	test -z "$file" || exec >$file
27921c2f794Smrg	echo ".ab help2man is required to generate this page"
28021c2f794Smrg	exit 1
28121c2f794Smrg    fi
28221c2f794Smrg    ;;
28321c2f794Smrg
28421c2f794Smrg  makeinfo)
28521c2f794Smrg    echo 1>&2 "\
28621c2f794SmrgWARNING: \`$1' is $msg.  You should only need it if
28721c2f794Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28821c2f794Smrg         indirectly affecting the aspect of the manual.  The spurious
28921c2f794Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29021c2f794Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29121c2f794Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29221c2f794Smrg    # The file to touch is that specified with -o ...
29321c2f794Smrg    file=`echo "$*" | sed -n "$sed_output"`
29421c2f794Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29521c2f794Smrg    if test -z "$file"; then
29621c2f794Smrg      # ... or it is the one specified with @setfilename ...
29721c2f794Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29821c2f794Smrg      file=`sed -n '
29921c2f794Smrg	/^@setfilename/{
30021c2f794Smrg	  s/.* \([^ ]*\) *$/\1/
30121c2f794Smrg	  p
30221c2f794Smrg	  q
30321c2f794Smrg	}' $infile`
30421c2f794Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30521c2f794Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30621c2f794Smrg    fi
30721c2f794Smrg    # If the file does not exist, the user really needs makeinfo;
30821c2f794Smrg    # let's fail without touching anything.
30921c2f794Smrg    test -f $file || exit 1
31021c2f794Smrg    touch $file
31121c2f794Smrg    ;;
31221c2f794Smrg
31321c2f794Smrg  tar)
31421c2f794Smrg    shift
31521c2f794Smrg
31621c2f794Smrg    # We have already tried tar in the generic part.
31721c2f794Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31821c2f794Smrg    # messages.
31921c2f794Smrg    if (gnutar --version > /dev/null 2>&1); then
32021c2f794Smrg       gnutar "$@" && exit 0
32121c2f794Smrg    fi
32221c2f794Smrg    if (gtar --version > /dev/null 2>&1); then
32321c2f794Smrg       gtar "$@" && exit 0
32421c2f794Smrg    fi
32521c2f794Smrg    firstarg="$1"
32621c2f794Smrg    if shift; then
32721c2f794Smrg	case $firstarg in
32821c2f794Smrg	*o*)
32921c2f794Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33021c2f794Smrg	    tar "$firstarg" "$@" && exit 0
33121c2f794Smrg	    ;;
33221c2f794Smrg	esac
33321c2f794Smrg	case $firstarg in
33421c2f794Smrg	*h*)
33521c2f794Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33621c2f794Smrg	    tar "$firstarg" "$@" && exit 0
33721c2f794Smrg	    ;;
33821c2f794Smrg	esac
33921c2f794Smrg    fi
34021c2f794Smrg
34121c2f794Smrg    echo 1>&2 "\
34221c2f794SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34321c2f794Smrg         You may want to install GNU tar or Free paxutils, or check the
34421c2f794Smrg         command line arguments."
34521c2f794Smrg    exit 1
34621c2f794Smrg    ;;
34721c2f794Smrg
34821c2f794Smrg  *)
34921c2f794Smrg    echo 1>&2 "\
35021c2f794SmrgWARNING: \`$1' is needed, and is $msg.
35121c2f794Smrg         You might have modified some files without having the
35221c2f794Smrg         proper tools for further handling them.  Check the \`README' file,
35321c2f794Smrg         it often tells you about the needed prerequisites for installing
35421c2f794Smrg         this package.  You may also peek at any GNU archive site, in case
35521c2f794Smrg         some other package would contain this missing \`$1' program."
35621c2f794Smrg    exit 1
35721c2f794Smrg    ;;
35821c2f794Smrgesac
35921c2f794Smrg
36021c2f794Smrgexit 0
36121c2f794Smrg
36221c2f794Smrg# Local variables:
36321c2f794Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36421c2f794Smrg# time-stamp-start: "scriptversion="
36521c2f794Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36621c2f794Smrg# time-stamp-end: "$"
36721c2f794Smrg# End:
368