missing revision 1ae1b5e8
176888252Smrg#! /bin/sh
276888252Smrg# Common stub for a few missing GNU programs while installing.
376888252Smrg
41ae1b5e8Smrgscriptversion=2006-05-10.23
576888252Smrg
61ae1b5e8Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
776888252Smrg#   Free Software Foundation, Inc.
876888252Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
976888252Smrg
1076888252Smrg# This program is free software; you can redistribute it and/or modify
1176888252Smrg# it under the terms of the GNU General Public License as published by
1276888252Smrg# the Free Software Foundation; either version 2, or (at your option)
1376888252Smrg# any later version.
1476888252Smrg
1576888252Smrg# This program is distributed in the hope that it will be useful,
1676888252Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1776888252Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1876888252Smrg# GNU General Public License for more details.
1976888252Smrg
2076888252Smrg# You should have received a copy of the GNU General Public License
2176888252Smrg# along with this program; if not, write to the Free Software
2276888252Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2376888252Smrg# 02110-1301, USA.
2476888252Smrg
2576888252Smrg# As a special exception to the GNU General Public License, if you
2676888252Smrg# distribute this file as part of a program that contains a
2776888252Smrg# configuration script generated by Autoconf, you may include it under
2876888252Smrg# the same distribution terms that you use for the rest of that program.
2976888252Smrg
3076888252Smrgif test $# -eq 0; then
3176888252Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3276888252Smrg  exit 1
3376888252Smrgfi
3476888252Smrg
3576888252Smrgrun=:
361ae1b5e8Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
371ae1b5e8Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3876888252Smrg
3976888252Smrg# In the cases where this matters, `missing' is being run in the
4076888252Smrg# srcdir already.
4176888252Smrgif test -f configure.ac; then
4276888252Smrg  configure_ac=configure.ac
4376888252Smrgelse
4476888252Smrg  configure_ac=configure.in
4576888252Smrgfi
4676888252Smrg
4776888252Smrgmsg="missing on your system"
4876888252Smrg
491ae1b5e8Smrgcase $1 in
5076888252Smrg--run)
5176888252Smrg  # Try to run requested program, and just exit if it succeeds.
5276888252Smrg  run=
5376888252Smrg  shift
5476888252Smrg  "$@" && exit 0
5576888252Smrg  # Exit code 63 means version mismatch.  This often happens
5676888252Smrg  # when the user try to use an ancient version of a tool on
5776888252Smrg  # a file that requires a minimum version.  In this case we
5876888252Smrg  # we should proceed has if the program had been absent, or
5976888252Smrg  # if --run hadn't been passed.
6076888252Smrg  if test $? = 63; then
6176888252Smrg    run=:
6276888252Smrg    msg="probably too old"
6376888252Smrg  fi
6476888252Smrg  ;;
6576888252Smrg
6676888252Smrg  -h|--h|--he|--hel|--help)
6776888252Smrg    echo "\
6876888252Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6976888252Smrg
7076888252SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7176888252Smrgerror status if there is no known handling for PROGRAM.
7276888252Smrg
7376888252SmrgOptions:
7476888252Smrg  -h, --help      display this help and exit
7576888252Smrg  -v, --version   output version information and exit
7676888252Smrg  --run           try to run the given command, and emulate it if it fails
7776888252Smrg
7876888252SmrgSupported PROGRAM values:
7976888252Smrg  aclocal      touch file \`aclocal.m4'
8076888252Smrg  autoconf     touch file \`configure'
8176888252Smrg  autoheader   touch file \`config.h.in'
821ae1b5e8Smrg  autom4te     touch the output file, or create a stub one
8376888252Smrg  automake     touch all \`Makefile.in' files
8476888252Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8576888252Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8676888252Smrg  help2man     touch the output file
8776888252Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8876888252Smrg  makeinfo     touch the output file
8976888252Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9076888252Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9176888252Smrg
9276888252SmrgSend bug reports to <bug-automake@gnu.org>."
9376888252Smrg    exit $?
9476888252Smrg    ;;
9576888252Smrg
9676888252Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9776888252Smrg    echo "missing $scriptversion (GNU Automake)"
9876888252Smrg    exit $?
9976888252Smrg    ;;
10076888252Smrg
10176888252Smrg  -*)
10276888252Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10376888252Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10476888252Smrg    exit 1
10576888252Smrg    ;;
10676888252Smrg
10776888252Smrgesac
10876888252Smrg
10976888252Smrg# Now exit if we have it, but it failed.  Also exit now if we
11076888252Smrg# don't have it and --version was passed (most likely to detect
11176888252Smrg# the program).
1121ae1b5e8Smrgcase $1 in
11376888252Smrg  lex|yacc)
11476888252Smrg    # Not GNU programs, they don't have --version.
11576888252Smrg    ;;
11676888252Smrg
11776888252Smrg  tar)
11876888252Smrg    if test -n "$run"; then
11976888252Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12076888252Smrg       exit 1
12176888252Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12276888252Smrg       exit 1
12376888252Smrg    fi
12476888252Smrg    ;;
12576888252Smrg
12676888252Smrg  *)
12776888252Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12876888252Smrg       # We have it, but it failed.
12976888252Smrg       exit 1
13076888252Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13176888252Smrg       # Could not run --version or --help.  This is probably someone
13276888252Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13376888252Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13476888252Smrg       exit 1
13576888252Smrg    fi
13676888252Smrg    ;;
13776888252Smrgesac
13876888252Smrg
13976888252Smrg# If it does not exist, or fails to run (possibly an outdated version),
14076888252Smrg# try to emulate it.
1411ae1b5e8Smrgcase $1 in
14276888252Smrg  aclocal*)
14376888252Smrg    echo 1>&2 "\
14476888252SmrgWARNING: \`$1' is $msg.  You should only need it if
14576888252Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14676888252Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14776888252Smrg         any GNU archive site."
14876888252Smrg    touch aclocal.m4
14976888252Smrg    ;;
15076888252Smrg
15176888252Smrg  autoconf)
15276888252Smrg    echo 1>&2 "\
15376888252SmrgWARNING: \`$1' is $msg.  You should only need it if
15476888252Smrg         you modified \`${configure_ac}'.  You might want to install the
15576888252Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15676888252Smrg         archive site."
15776888252Smrg    touch configure
15876888252Smrg    ;;
15976888252Smrg
16076888252Smrg  autoheader)
16176888252Smrg    echo 1>&2 "\
16276888252SmrgWARNING: \`$1' is $msg.  You should only need it if
16376888252Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16476888252Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16576888252Smrg         from any GNU archive site."
16676888252Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16776888252Smrg    test -z "$files" && files="config.h"
16876888252Smrg    touch_files=
16976888252Smrg    for f in $files; do
1701ae1b5e8Smrg      case $f in
17176888252Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17276888252Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17376888252Smrg      *) touch_files="$touch_files $f.in";;
17476888252Smrg      esac
17576888252Smrg    done
17676888252Smrg    touch $touch_files
17776888252Smrg    ;;
17876888252Smrg
17976888252Smrg  automake*)
18076888252Smrg    echo 1>&2 "\
18176888252SmrgWARNING: \`$1' is $msg.  You should only need it if
18276888252Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18376888252Smrg         You might want to install the \`Automake' and \`Perl' packages.
18476888252Smrg         Grab them from any GNU archive site."
18576888252Smrg    find . -type f -name Makefile.am -print |
18676888252Smrg	   sed 's/\.am$/.in/' |
18776888252Smrg	   while read f; do touch "$f"; done
18876888252Smrg    ;;
18976888252Smrg
19076888252Smrg  autom4te)
19176888252Smrg    echo 1>&2 "\
19276888252SmrgWARNING: \`$1' is needed, but is $msg.
19376888252Smrg         You might have modified some files without having the
19476888252Smrg         proper tools for further handling them.
19576888252Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19676888252Smrg         archive site."
19776888252Smrg
1981ae1b5e8Smrg    file=`echo "$*" | sed -n "$sed_output"`
1991ae1b5e8Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20076888252Smrg    if test -f "$file"; then
20176888252Smrg	touch $file
20276888252Smrg    else
20376888252Smrg	test -z "$file" || exec >$file
20476888252Smrg	echo "#! /bin/sh"
20576888252Smrg	echo "# Created by GNU Automake missing as a replacement of"
20676888252Smrg	echo "#  $ $@"
20776888252Smrg	echo "exit 0"
20876888252Smrg	chmod +x $file
20976888252Smrg	exit 1
21076888252Smrg    fi
21176888252Smrg    ;;
21276888252Smrg
21376888252Smrg  bison|yacc)
21476888252Smrg    echo 1>&2 "\
21576888252SmrgWARNING: \`$1' $msg.  You should only need it if
21676888252Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21776888252Smrg         in order for those modifications to take effect.  You can get
21876888252Smrg         \`Bison' from any GNU archive site."
21976888252Smrg    rm -f y.tab.c y.tab.h
2201ae1b5e8Smrg    if test $# -ne 1; then
22176888252Smrg        eval LASTARG="\${$#}"
2221ae1b5e8Smrg	case $LASTARG in
22376888252Smrg	*.y)
22476888252Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2251ae1b5e8Smrg	    if test -f "$SRCFILE"; then
22676888252Smrg	         cp "$SRCFILE" y.tab.c
22776888252Smrg	    fi
22876888252Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2291ae1b5e8Smrg	    if test -f "$SRCFILE"; then
23076888252Smrg	         cp "$SRCFILE" y.tab.h
23176888252Smrg	    fi
23276888252Smrg	  ;;
23376888252Smrg	esac
23476888252Smrg    fi
2351ae1b5e8Smrg    if test ! -f y.tab.h; then
23676888252Smrg	echo >y.tab.h
23776888252Smrg    fi
2381ae1b5e8Smrg    if test ! -f y.tab.c; then
23976888252Smrg	echo 'main() { return 0; }' >y.tab.c
24076888252Smrg    fi
24176888252Smrg    ;;
24276888252Smrg
24376888252Smrg  lex|flex)
24476888252Smrg    echo 1>&2 "\
24576888252SmrgWARNING: \`$1' is $msg.  You should only need it if
24676888252Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24776888252Smrg         in order for those modifications to take effect.  You can get
24876888252Smrg         \`Flex' from any GNU archive site."
24976888252Smrg    rm -f lex.yy.c
2501ae1b5e8Smrg    if test $# -ne 1; then
25176888252Smrg        eval LASTARG="\${$#}"
2521ae1b5e8Smrg	case $LASTARG in
25376888252Smrg	*.l)
25476888252Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2551ae1b5e8Smrg	    if test -f "$SRCFILE"; then
25676888252Smrg	         cp "$SRCFILE" lex.yy.c
25776888252Smrg	    fi
25876888252Smrg	  ;;
25976888252Smrg	esac
26076888252Smrg    fi
2611ae1b5e8Smrg    if test ! -f lex.yy.c; then
26276888252Smrg	echo 'main() { return 0; }' >lex.yy.c
26376888252Smrg    fi
26476888252Smrg    ;;
26576888252Smrg
26676888252Smrg  help2man)
26776888252Smrg    echo 1>&2 "\
26876888252SmrgWARNING: \`$1' is $msg.  You should only need it if
26976888252Smrg	 you modified a dependency of a manual page.  You may need the
27076888252Smrg	 \`Help2man' package in order for those modifications to take
27176888252Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27276888252Smrg
2731ae1b5e8Smrg    file=`echo "$*" | sed -n "$sed_output"`
2741ae1b5e8Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2751ae1b5e8Smrg    if test -f "$file"; then
27676888252Smrg	touch $file
27776888252Smrg    else
27876888252Smrg	test -z "$file" || exec >$file
27976888252Smrg	echo ".ab help2man is required to generate this page"
28076888252Smrg	exit 1
28176888252Smrg    fi
28276888252Smrg    ;;
28376888252Smrg
28476888252Smrg  makeinfo)
28576888252Smrg    echo 1>&2 "\
28676888252SmrgWARNING: \`$1' is $msg.  You should only need it if
28776888252Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28876888252Smrg         indirectly affecting the aspect of the manual.  The spurious
28976888252Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29076888252Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29176888252Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29276888252Smrg    # The file to touch is that specified with -o ...
2931ae1b5e8Smrg    file=`echo "$*" | sed -n "$sed_output"`
2941ae1b5e8Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29576888252Smrg    if test -z "$file"; then
29676888252Smrg      # ... or it is the one specified with @setfilename ...
29776888252Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
2981ae1b5e8Smrg      file=`sed -n '
2991ae1b5e8Smrg	/^@setfilename/{
3001ae1b5e8Smrg	  s/.* \([^ ]*\) *$/\1/
3011ae1b5e8Smrg	  p
3021ae1b5e8Smrg	  q
3031ae1b5e8Smrg	}' $infile`
30476888252Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30576888252Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30676888252Smrg    fi
30776888252Smrg    # If the file does not exist, the user really needs makeinfo;
30876888252Smrg    # let's fail without touching anything.
30976888252Smrg    test -f $file || exit 1
31076888252Smrg    touch $file
31176888252Smrg    ;;
31276888252Smrg
31376888252Smrg  tar)
31476888252Smrg    shift
31576888252Smrg
31676888252Smrg    # We have already tried tar in the generic part.
31776888252Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31876888252Smrg    # messages.
31976888252Smrg    if (gnutar --version > /dev/null 2>&1); then
32076888252Smrg       gnutar "$@" && exit 0
32176888252Smrg    fi
32276888252Smrg    if (gtar --version > /dev/null 2>&1); then
32376888252Smrg       gtar "$@" && exit 0
32476888252Smrg    fi
32576888252Smrg    firstarg="$1"
32676888252Smrg    if shift; then
3271ae1b5e8Smrg	case $firstarg in
32876888252Smrg	*o*)
32976888252Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33076888252Smrg	    tar "$firstarg" "$@" && exit 0
33176888252Smrg	    ;;
33276888252Smrg	esac
3331ae1b5e8Smrg	case $firstarg in
33476888252Smrg	*h*)
33576888252Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33676888252Smrg	    tar "$firstarg" "$@" && exit 0
33776888252Smrg	    ;;
33876888252Smrg	esac
33976888252Smrg    fi
34076888252Smrg
34176888252Smrg    echo 1>&2 "\
34276888252SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34376888252Smrg         You may want to install GNU tar or Free paxutils, or check the
34476888252Smrg         command line arguments."
34576888252Smrg    exit 1
34676888252Smrg    ;;
34776888252Smrg
34876888252Smrg  *)
34976888252Smrg    echo 1>&2 "\
35076888252SmrgWARNING: \`$1' is needed, and is $msg.
35176888252Smrg         You might have modified some files without having the
35276888252Smrg         proper tools for further handling them.  Check the \`README' file,
35376888252Smrg         it often tells you about the needed prerequisites for installing
35476888252Smrg         this package.  You may also peek at any GNU archive site, in case
35576888252Smrg         some other package would contain this missing \`$1' program."
35676888252Smrg    exit 1
35776888252Smrg    ;;
35876888252Smrgesac
35976888252Smrg
36076888252Smrgexit 0
36176888252Smrg
36276888252Smrg# Local variables:
36376888252Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36476888252Smrg# time-stamp-start: "scriptversion="
36576888252Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36676888252Smrg# time-stamp-end: "$"
36776888252Smrg# End:
368