missing revision 09885543
109885543Smrg#! /bin/sh
209885543Smrg# Common stub for a few missing GNU programs while installing.
309885543Smrg
409885543Smrgscriptversion=2005-06-08.21
509885543Smrg
609885543Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
709885543Smrg#   Free Software Foundation, Inc.
809885543Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
909885543Smrg
1009885543Smrg# This program is free software; you can redistribute it and/or modify
1109885543Smrg# it under the terms of the GNU General Public License as published by
1209885543Smrg# the Free Software Foundation; either version 2, or (at your option)
1309885543Smrg# any later version.
1409885543Smrg
1509885543Smrg# This program is distributed in the hope that it will be useful,
1609885543Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1709885543Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1809885543Smrg# GNU General Public License for more details.
1909885543Smrg
2009885543Smrg# You should have received a copy of the GNU General Public License
2109885543Smrg# along with this program; if not, write to the Free Software
2209885543Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2309885543Smrg# 02110-1301, USA.
2409885543Smrg
2509885543Smrg# As a special exception to the GNU General Public License, if you
2609885543Smrg# distribute this file as part of a program that contains a
2709885543Smrg# configuration script generated by Autoconf, you may include it under
2809885543Smrg# the same distribution terms that you use for the rest of that program.
2909885543Smrg
3009885543Smrgif test $# -eq 0; then
3109885543Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3209885543Smrg  exit 1
3309885543Smrgfi
3409885543Smrg
3509885543Smrgrun=:
3609885543Smrg
3709885543Smrg# In the cases where this matters, `missing' is being run in the
3809885543Smrg# srcdir already.
3909885543Smrgif test -f configure.ac; then
4009885543Smrg  configure_ac=configure.ac
4109885543Smrgelse
4209885543Smrg  configure_ac=configure.in
4309885543Smrgfi
4409885543Smrg
4509885543Smrgmsg="missing on your system"
4609885543Smrg
4709885543Smrgcase "$1" in
4809885543Smrg--run)
4909885543Smrg  # Try to run requested program, and just exit if it succeeds.
5009885543Smrg  run=
5109885543Smrg  shift
5209885543Smrg  "$@" && exit 0
5309885543Smrg  # Exit code 63 means version mismatch.  This often happens
5409885543Smrg  # when the user try to use an ancient version of a tool on
5509885543Smrg  # a file that requires a minimum version.  In this case we
5609885543Smrg  # we should proceed has if the program had been absent, or
5709885543Smrg  # if --run hadn't been passed.
5809885543Smrg  if test $? = 63; then
5909885543Smrg    run=:
6009885543Smrg    msg="probably too old"
6109885543Smrg  fi
6209885543Smrg  ;;
6309885543Smrg
6409885543Smrg  -h|--h|--he|--hel|--help)
6509885543Smrg    echo "\
6609885543Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6709885543Smrg
6809885543SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6909885543Smrgerror status if there is no known handling for PROGRAM.
7009885543Smrg
7109885543SmrgOptions:
7209885543Smrg  -h, --help      display this help and exit
7309885543Smrg  -v, --version   output version information and exit
7409885543Smrg  --run           try to run the given command, and emulate it if it fails
7509885543Smrg
7609885543SmrgSupported PROGRAM values:
7709885543Smrg  aclocal      touch file \`aclocal.m4'
7809885543Smrg  autoconf     touch file \`configure'
7909885543Smrg  autoheader   touch file \`config.h.in'
8009885543Smrg  automake     touch all \`Makefile.in' files
8109885543Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8209885543Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8309885543Smrg  help2man     touch the output file
8409885543Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8509885543Smrg  makeinfo     touch the output file
8609885543Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8709885543Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8809885543Smrg
8909885543SmrgSend bug reports to <bug-automake@gnu.org>."
9009885543Smrg    exit $?
9109885543Smrg    ;;
9209885543Smrg
9309885543Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9409885543Smrg    echo "missing $scriptversion (GNU Automake)"
9509885543Smrg    exit $?
9609885543Smrg    ;;
9709885543Smrg
9809885543Smrg  -*)
9909885543Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10009885543Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10109885543Smrg    exit 1
10209885543Smrg    ;;
10309885543Smrg
10409885543Smrgesac
10509885543Smrg
10609885543Smrg# Now exit if we have it, but it failed.  Also exit now if we
10709885543Smrg# don't have it and --version was passed (most likely to detect
10809885543Smrg# the program).
10909885543Smrgcase "$1" in
11009885543Smrg  lex|yacc)
11109885543Smrg    # Not GNU programs, they don't have --version.
11209885543Smrg    ;;
11309885543Smrg
11409885543Smrg  tar)
11509885543Smrg    if test -n "$run"; then
11609885543Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
11709885543Smrg       exit 1
11809885543Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
11909885543Smrg       exit 1
12009885543Smrg    fi
12109885543Smrg    ;;
12209885543Smrg
12309885543Smrg  *)
12409885543Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12509885543Smrg       # We have it, but it failed.
12609885543Smrg       exit 1
12709885543Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12809885543Smrg       # Could not run --version or --help.  This is probably someone
12909885543Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13009885543Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13109885543Smrg       exit 1
13209885543Smrg    fi
13309885543Smrg    ;;
13409885543Smrgesac
13509885543Smrg
13609885543Smrg# If it does not exist, or fails to run (possibly an outdated version),
13709885543Smrg# try to emulate it.
13809885543Smrgcase "$1" in
13909885543Smrg  aclocal*)
14009885543Smrg    echo 1>&2 "\
14109885543SmrgWARNING: \`$1' is $msg.  You should only need it if
14209885543Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14309885543Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14409885543Smrg         any GNU archive site."
14509885543Smrg    touch aclocal.m4
14609885543Smrg    ;;
14709885543Smrg
14809885543Smrg  autoconf)
14909885543Smrg    echo 1>&2 "\
15009885543SmrgWARNING: \`$1' is $msg.  You should only need it if
15109885543Smrg         you modified \`${configure_ac}'.  You might want to install the
15209885543Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15309885543Smrg         archive site."
15409885543Smrg    touch configure
15509885543Smrg    ;;
15609885543Smrg
15709885543Smrg  autoheader)
15809885543Smrg    echo 1>&2 "\
15909885543SmrgWARNING: \`$1' is $msg.  You should only need it if
16009885543Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16109885543Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16209885543Smrg         from any GNU archive site."
16309885543Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16409885543Smrg    test -z "$files" && files="config.h"
16509885543Smrg    touch_files=
16609885543Smrg    for f in $files; do
16709885543Smrg      case "$f" in
16809885543Smrg      *:*) touch_files="$touch_files "`echo "$f" |
16909885543Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17009885543Smrg      *) touch_files="$touch_files $f.in";;
17109885543Smrg      esac
17209885543Smrg    done
17309885543Smrg    touch $touch_files
17409885543Smrg    ;;
17509885543Smrg
17609885543Smrg  automake*)
17709885543Smrg    echo 1>&2 "\
17809885543SmrgWARNING: \`$1' is $msg.  You should only need it if
17909885543Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18009885543Smrg         You might want to install the \`Automake' and \`Perl' packages.
18109885543Smrg         Grab them from any GNU archive site."
18209885543Smrg    find . -type f -name Makefile.am -print |
18309885543Smrg	   sed 's/\.am$/.in/' |
18409885543Smrg	   while read f; do touch "$f"; done
18509885543Smrg    ;;
18609885543Smrg
18709885543Smrg  autom4te)
18809885543Smrg    echo 1>&2 "\
18909885543SmrgWARNING: \`$1' is needed, but is $msg.
19009885543Smrg         You might have modified some files without having the
19109885543Smrg         proper tools for further handling them.
19209885543Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19309885543Smrg         archive site."
19409885543Smrg
19509885543Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
19609885543Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
19709885543Smrg    if test -f "$file"; then
19809885543Smrg	touch $file
19909885543Smrg    else
20009885543Smrg	test -z "$file" || exec >$file
20109885543Smrg	echo "#! /bin/sh"
20209885543Smrg	echo "# Created by GNU Automake missing as a replacement of"
20309885543Smrg	echo "#  $ $@"
20409885543Smrg	echo "exit 0"
20509885543Smrg	chmod +x $file
20609885543Smrg	exit 1
20709885543Smrg    fi
20809885543Smrg    ;;
20909885543Smrg
21009885543Smrg  bison|yacc)
21109885543Smrg    echo 1>&2 "\
21209885543SmrgWARNING: \`$1' $msg.  You should only need it if
21309885543Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21409885543Smrg         in order for those modifications to take effect.  You can get
21509885543Smrg         \`Bison' from any GNU archive site."
21609885543Smrg    rm -f y.tab.c y.tab.h
21709885543Smrg    if [ $# -ne 1 ]; then
21809885543Smrg        eval LASTARG="\${$#}"
21909885543Smrg	case "$LASTARG" in
22009885543Smrg	*.y)
22109885543Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22209885543Smrg	    if [ -f "$SRCFILE" ]; then
22309885543Smrg	         cp "$SRCFILE" y.tab.c
22409885543Smrg	    fi
22509885543Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22609885543Smrg	    if [ -f "$SRCFILE" ]; then
22709885543Smrg	         cp "$SRCFILE" y.tab.h
22809885543Smrg	    fi
22909885543Smrg	  ;;
23009885543Smrg	esac
23109885543Smrg    fi
23209885543Smrg    if [ ! -f y.tab.h ]; then
23309885543Smrg	echo >y.tab.h
23409885543Smrg    fi
23509885543Smrg    if [ ! -f y.tab.c ]; then
23609885543Smrg	echo 'main() { return 0; }' >y.tab.c
23709885543Smrg    fi
23809885543Smrg    ;;
23909885543Smrg
24009885543Smrg  lex|flex)
24109885543Smrg    echo 1>&2 "\
24209885543SmrgWARNING: \`$1' is $msg.  You should only need it if
24309885543Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24409885543Smrg         in order for those modifications to take effect.  You can get
24509885543Smrg         \`Flex' from any GNU archive site."
24609885543Smrg    rm -f lex.yy.c
24709885543Smrg    if [ $# -ne 1 ]; then
24809885543Smrg        eval LASTARG="\${$#}"
24909885543Smrg	case "$LASTARG" in
25009885543Smrg	*.l)
25109885543Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25209885543Smrg	    if [ -f "$SRCFILE" ]; then
25309885543Smrg	         cp "$SRCFILE" lex.yy.c
25409885543Smrg	    fi
25509885543Smrg	  ;;
25609885543Smrg	esac
25709885543Smrg    fi
25809885543Smrg    if [ ! -f lex.yy.c ]; then
25909885543Smrg	echo 'main() { return 0; }' >lex.yy.c
26009885543Smrg    fi
26109885543Smrg    ;;
26209885543Smrg
26309885543Smrg  help2man)
26409885543Smrg    echo 1>&2 "\
26509885543SmrgWARNING: \`$1' is $msg.  You should only need it if
26609885543Smrg	 you modified a dependency of a manual page.  You may need the
26709885543Smrg	 \`Help2man' package in order for those modifications to take
26809885543Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
26909885543Smrg
27009885543Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27109885543Smrg    if test -z "$file"; then
27209885543Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27309885543Smrg    fi
27409885543Smrg    if [ -f "$file" ]; then
27509885543Smrg	touch $file
27609885543Smrg    else
27709885543Smrg	test -z "$file" || exec >$file
27809885543Smrg	echo ".ab help2man is required to generate this page"
27909885543Smrg	exit 1
28009885543Smrg    fi
28109885543Smrg    ;;
28209885543Smrg
28309885543Smrg  makeinfo)
28409885543Smrg    echo 1>&2 "\
28509885543SmrgWARNING: \`$1' is $msg.  You should only need it if
28609885543Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28709885543Smrg         indirectly affecting the aspect of the manual.  The spurious
28809885543Smrg         call might also be the consequence of using a buggy \`make' (AIX,
28909885543Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29009885543Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29109885543Smrg    # The file to touch is that specified with -o ...
29209885543Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29309885543Smrg    if test -z "$file"; then
29409885543Smrg      # ... or it is the one specified with @setfilename ...
29509885543Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29609885543Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
29709885543Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
29809885543Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29909885543Smrg    fi
30009885543Smrg    # If the file does not exist, the user really needs makeinfo;
30109885543Smrg    # let's fail without touching anything.
30209885543Smrg    test -f $file || exit 1
30309885543Smrg    touch $file
30409885543Smrg    ;;
30509885543Smrg
30609885543Smrg  tar)
30709885543Smrg    shift
30809885543Smrg
30909885543Smrg    # We have already tried tar in the generic part.
31009885543Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31109885543Smrg    # messages.
31209885543Smrg    if (gnutar --version > /dev/null 2>&1); then
31309885543Smrg       gnutar "$@" && exit 0
31409885543Smrg    fi
31509885543Smrg    if (gtar --version > /dev/null 2>&1); then
31609885543Smrg       gtar "$@" && exit 0
31709885543Smrg    fi
31809885543Smrg    firstarg="$1"
31909885543Smrg    if shift; then
32009885543Smrg	case "$firstarg" in
32109885543Smrg	*o*)
32209885543Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
32309885543Smrg	    tar "$firstarg" "$@" && exit 0
32409885543Smrg	    ;;
32509885543Smrg	esac
32609885543Smrg	case "$firstarg" in
32709885543Smrg	*h*)
32809885543Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
32909885543Smrg	    tar "$firstarg" "$@" && exit 0
33009885543Smrg	    ;;
33109885543Smrg	esac
33209885543Smrg    fi
33309885543Smrg
33409885543Smrg    echo 1>&2 "\
33509885543SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
33609885543Smrg         You may want to install GNU tar or Free paxutils, or check the
33709885543Smrg         command line arguments."
33809885543Smrg    exit 1
33909885543Smrg    ;;
34009885543Smrg
34109885543Smrg  *)
34209885543Smrg    echo 1>&2 "\
34309885543SmrgWARNING: \`$1' is needed, and is $msg.
34409885543Smrg         You might have modified some files without having the
34509885543Smrg         proper tools for further handling them.  Check the \`README' file,
34609885543Smrg         it often tells you about the needed prerequisites for installing
34709885543Smrg         this package.  You may also peek at any GNU archive site, in case
34809885543Smrg         some other package would contain this missing \`$1' program."
34909885543Smrg    exit 1
35009885543Smrg    ;;
35109885543Smrgesac
35209885543Smrg
35309885543Smrgexit 0
35409885543Smrg
35509885543Smrg# Local variables:
35609885543Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
35709885543Smrg# time-stamp-start: "scriptversion="
35809885543Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
35909885543Smrg# time-stamp-end: "$"
36009885543Smrg# End:
361