missing revision e19dfac4
127702724Smrg#! /bin/sh
227702724Smrg# Common stub for a few missing GNU programs while installing.
327702724Smrg
4e19dfac4Smrgscriptversion=2006-05-10.23
527702724Smrg
6e19dfac4Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
727702724Smrg#   Free Software Foundation, Inc.
827702724Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
927702724Smrg
1027702724Smrg# This program is free software; you can redistribute it and/or modify
1127702724Smrg# it under the terms of the GNU General Public License as published by
1227702724Smrg# the Free Software Foundation; either version 2, or (at your option)
1327702724Smrg# any later version.
1427702724Smrg
1527702724Smrg# This program is distributed in the hope that it will be useful,
1627702724Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1727702724Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1827702724Smrg# GNU General Public License for more details.
1927702724Smrg
2027702724Smrg# You should have received a copy of the GNU General Public License
2127702724Smrg# along with this program; if not, write to the Free Software
2227702724Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2327702724Smrg# 02110-1301, USA.
2427702724Smrg
2527702724Smrg# As a special exception to the GNU General Public License, if you
2627702724Smrg# distribute this file as part of a program that contains a
2727702724Smrg# configuration script generated by Autoconf, you may include it under
2827702724Smrg# the same distribution terms that you use for the rest of that program.
2927702724Smrg
3027702724Smrgif test $# -eq 0; then
3127702724Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3227702724Smrg  exit 1
3327702724Smrgfi
3427702724Smrg
3527702724Smrgrun=:
36e19dfac4Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37e19dfac4Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3827702724Smrg
3927702724Smrg# In the cases where this matters, `missing' is being run in the
4027702724Smrg# srcdir already.
4127702724Smrgif test -f configure.ac; then
4227702724Smrg  configure_ac=configure.ac
4327702724Smrgelse
4427702724Smrg  configure_ac=configure.in
4527702724Smrgfi
4627702724Smrg
4727702724Smrgmsg="missing on your system"
4827702724Smrg
49e19dfac4Smrgcase $1 in
5027702724Smrg--run)
5127702724Smrg  # Try to run requested program, and just exit if it succeeds.
5227702724Smrg  run=
5327702724Smrg  shift
5427702724Smrg  "$@" && exit 0
5527702724Smrg  # Exit code 63 means version mismatch.  This often happens
5627702724Smrg  # when the user try to use an ancient version of a tool on
5727702724Smrg  # a file that requires a minimum version.  In this case we
5827702724Smrg  # we should proceed has if the program had been absent, or
5927702724Smrg  # if --run hadn't been passed.
6027702724Smrg  if test $? = 63; then
6127702724Smrg    run=:
6227702724Smrg    msg="probably too old"
6327702724Smrg  fi
6427702724Smrg  ;;
6527702724Smrg
6627702724Smrg  -h|--h|--he|--hel|--help)
6727702724Smrg    echo "\
6827702724Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6927702724Smrg
7027702724SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7127702724Smrgerror status if there is no known handling for PROGRAM.
7227702724Smrg
7327702724SmrgOptions:
7427702724Smrg  -h, --help      display this help and exit
7527702724Smrg  -v, --version   output version information and exit
7627702724Smrg  --run           try to run the given command, and emulate it if it fails
7727702724Smrg
7827702724SmrgSupported PROGRAM values:
7927702724Smrg  aclocal      touch file \`aclocal.m4'
8027702724Smrg  autoconf     touch file \`configure'
8127702724Smrg  autoheader   touch file \`config.h.in'
82e19dfac4Smrg  autom4te     touch the output file, or create a stub one
8327702724Smrg  automake     touch all \`Makefile.in' files
8427702724Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8527702724Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8627702724Smrg  help2man     touch the output file
8727702724Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8827702724Smrg  makeinfo     touch the output file
8927702724Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9027702724Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9127702724Smrg
9227702724SmrgSend bug reports to <bug-automake@gnu.org>."
9327702724Smrg    exit $?
9427702724Smrg    ;;
9527702724Smrg
9627702724Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9727702724Smrg    echo "missing $scriptversion (GNU Automake)"
9827702724Smrg    exit $?
9927702724Smrg    ;;
10027702724Smrg
10127702724Smrg  -*)
10227702724Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10327702724Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10427702724Smrg    exit 1
10527702724Smrg    ;;
10627702724Smrg
10727702724Smrgesac
10827702724Smrg
10927702724Smrg# Now exit if we have it, but it failed.  Also exit now if we
11027702724Smrg# don't have it and --version was passed (most likely to detect
11127702724Smrg# the program).
112e19dfac4Smrgcase $1 in
11327702724Smrg  lex|yacc)
11427702724Smrg    # Not GNU programs, they don't have --version.
11527702724Smrg    ;;
11627702724Smrg
11727702724Smrg  tar)
11827702724Smrg    if test -n "$run"; then
11927702724Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12027702724Smrg       exit 1
12127702724Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12227702724Smrg       exit 1
12327702724Smrg    fi
12427702724Smrg    ;;
12527702724Smrg
12627702724Smrg  *)
12727702724Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12827702724Smrg       # We have it, but it failed.
12927702724Smrg       exit 1
13027702724Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13127702724Smrg       # Could not run --version or --help.  This is probably someone
13227702724Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13327702724Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13427702724Smrg       exit 1
13527702724Smrg    fi
13627702724Smrg    ;;
13727702724Smrgesac
13827702724Smrg
13927702724Smrg# If it does not exist, or fails to run (possibly an outdated version),
14027702724Smrg# try to emulate it.
141e19dfac4Smrgcase $1 in
14227702724Smrg  aclocal*)
14327702724Smrg    echo 1>&2 "\
14427702724SmrgWARNING: \`$1' is $msg.  You should only need it if
14527702724Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14627702724Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14727702724Smrg         any GNU archive site."
14827702724Smrg    touch aclocal.m4
14927702724Smrg    ;;
15027702724Smrg
15127702724Smrg  autoconf)
15227702724Smrg    echo 1>&2 "\
15327702724SmrgWARNING: \`$1' is $msg.  You should only need it if
15427702724Smrg         you modified \`${configure_ac}'.  You might want to install the
15527702724Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15627702724Smrg         archive site."
15727702724Smrg    touch configure
15827702724Smrg    ;;
15927702724Smrg
16027702724Smrg  autoheader)
16127702724Smrg    echo 1>&2 "\
16227702724SmrgWARNING: \`$1' is $msg.  You should only need it if
16327702724Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16427702724Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16527702724Smrg         from any GNU archive site."
16627702724Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16727702724Smrg    test -z "$files" && files="config.h"
16827702724Smrg    touch_files=
16927702724Smrg    for f in $files; do
170e19dfac4Smrg      case $f in
17127702724Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17227702724Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17327702724Smrg      *) touch_files="$touch_files $f.in";;
17427702724Smrg      esac
17527702724Smrg    done
17627702724Smrg    touch $touch_files
17727702724Smrg    ;;
17827702724Smrg
17927702724Smrg  automake*)
18027702724Smrg    echo 1>&2 "\
18127702724SmrgWARNING: \`$1' is $msg.  You should only need it if
18227702724Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18327702724Smrg         You might want to install the \`Automake' and \`Perl' packages.
18427702724Smrg         Grab them from any GNU archive site."
18527702724Smrg    find . -type f -name Makefile.am -print |
18627702724Smrg	   sed 's/\.am$/.in/' |
18727702724Smrg	   while read f; do touch "$f"; done
18827702724Smrg    ;;
18927702724Smrg
19027702724Smrg  autom4te)
19127702724Smrg    echo 1>&2 "\
19227702724SmrgWARNING: \`$1' is needed, but is $msg.
19327702724Smrg         You might have modified some files without having the
19427702724Smrg         proper tools for further handling them.
19527702724Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19627702724Smrg         archive site."
19727702724Smrg
198e19dfac4Smrg    file=`echo "$*" | sed -n "$sed_output"`
199e19dfac4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20027702724Smrg    if test -f "$file"; then
20127702724Smrg	touch $file
20227702724Smrg    else
20327702724Smrg	test -z "$file" || exec >$file
20427702724Smrg	echo "#! /bin/sh"
20527702724Smrg	echo "# Created by GNU Automake missing as a replacement of"
20627702724Smrg	echo "#  $ $@"
20727702724Smrg	echo "exit 0"
20827702724Smrg	chmod +x $file
20927702724Smrg	exit 1
21027702724Smrg    fi
21127702724Smrg    ;;
21227702724Smrg
21327702724Smrg  bison|yacc)
21427702724Smrg    echo 1>&2 "\
21527702724SmrgWARNING: \`$1' $msg.  You should only need it if
21627702724Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21727702724Smrg         in order for those modifications to take effect.  You can get
21827702724Smrg         \`Bison' from any GNU archive site."
21927702724Smrg    rm -f y.tab.c y.tab.h
220e19dfac4Smrg    if test $# -ne 1; then
22127702724Smrg        eval LASTARG="\${$#}"
222e19dfac4Smrg	case $LASTARG in
22327702724Smrg	*.y)
22427702724Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225e19dfac4Smrg	    if test -f "$SRCFILE"; then
22627702724Smrg	         cp "$SRCFILE" y.tab.c
22727702724Smrg	    fi
22827702724Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229e19dfac4Smrg	    if test -f "$SRCFILE"; then
23027702724Smrg	         cp "$SRCFILE" y.tab.h
23127702724Smrg	    fi
23227702724Smrg	  ;;
23327702724Smrg	esac
23427702724Smrg    fi
235e19dfac4Smrg    if test ! -f y.tab.h; then
23627702724Smrg	echo >y.tab.h
23727702724Smrg    fi
238e19dfac4Smrg    if test ! -f y.tab.c; then
23927702724Smrg	echo 'main() { return 0; }' >y.tab.c
24027702724Smrg    fi
24127702724Smrg    ;;
24227702724Smrg
24327702724Smrg  lex|flex)
24427702724Smrg    echo 1>&2 "\
24527702724SmrgWARNING: \`$1' is $msg.  You should only need it if
24627702724Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24727702724Smrg         in order for those modifications to take effect.  You can get
24827702724Smrg         \`Flex' from any GNU archive site."
24927702724Smrg    rm -f lex.yy.c
250e19dfac4Smrg    if test $# -ne 1; then
25127702724Smrg        eval LASTARG="\${$#}"
252e19dfac4Smrg	case $LASTARG in
25327702724Smrg	*.l)
25427702724Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255e19dfac4Smrg	    if test -f "$SRCFILE"; then
25627702724Smrg	         cp "$SRCFILE" lex.yy.c
25727702724Smrg	    fi
25827702724Smrg	  ;;
25927702724Smrg	esac
26027702724Smrg    fi
261e19dfac4Smrg    if test ! -f lex.yy.c; then
26227702724Smrg	echo 'main() { return 0; }' >lex.yy.c
26327702724Smrg    fi
26427702724Smrg    ;;
26527702724Smrg
26627702724Smrg  help2man)
26727702724Smrg    echo 1>&2 "\
26827702724SmrgWARNING: \`$1' is $msg.  You should only need it if
26927702724Smrg	 you modified a dependency of a manual page.  You may need the
27027702724Smrg	 \`Help2man' package in order for those modifications to take
27127702724Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27227702724Smrg
273e19dfac4Smrg    file=`echo "$*" | sed -n "$sed_output"`
274e19dfac4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275e19dfac4Smrg    if test -f "$file"; then
27627702724Smrg	touch $file
27727702724Smrg    else
27827702724Smrg	test -z "$file" || exec >$file
27927702724Smrg	echo ".ab help2man is required to generate this page"
28027702724Smrg	exit 1
28127702724Smrg    fi
28227702724Smrg    ;;
28327702724Smrg
28427702724Smrg  makeinfo)
28527702724Smrg    echo 1>&2 "\
28627702724SmrgWARNING: \`$1' is $msg.  You should only need it if
28727702724Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28827702724Smrg         indirectly affecting the aspect of the manual.  The spurious
28927702724Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29027702724Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29127702724Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29227702724Smrg    # The file to touch is that specified with -o ...
293e19dfac4Smrg    file=`echo "$*" | sed -n "$sed_output"`
294e19dfac4Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29527702724Smrg    if test -z "$file"; then
29627702724Smrg      # ... or it is the one specified with @setfilename ...
29727702724Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298e19dfac4Smrg      file=`sed -n '
299e19dfac4Smrg	/^@setfilename/{
300e19dfac4Smrg	  s/.* \([^ ]*\) *$/\1/
301e19dfac4Smrg	  p
302e19dfac4Smrg	  q
303e19dfac4Smrg	}' $infile`
30427702724Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30527702724Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30627702724Smrg    fi
30727702724Smrg    # If the file does not exist, the user really needs makeinfo;
30827702724Smrg    # let's fail without touching anything.
30927702724Smrg    test -f $file || exit 1
31027702724Smrg    touch $file
31127702724Smrg    ;;
31227702724Smrg
31327702724Smrg  tar)
31427702724Smrg    shift
31527702724Smrg
31627702724Smrg    # We have already tried tar in the generic part.
31727702724Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31827702724Smrg    # messages.
31927702724Smrg    if (gnutar --version > /dev/null 2>&1); then
32027702724Smrg       gnutar "$@" && exit 0
32127702724Smrg    fi
32227702724Smrg    if (gtar --version > /dev/null 2>&1); then
32327702724Smrg       gtar "$@" && exit 0
32427702724Smrg    fi
32527702724Smrg    firstarg="$1"
32627702724Smrg    if shift; then
327e19dfac4Smrg	case $firstarg in
32827702724Smrg	*o*)
32927702724Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33027702724Smrg	    tar "$firstarg" "$@" && exit 0
33127702724Smrg	    ;;
33227702724Smrg	esac
333e19dfac4Smrg	case $firstarg in
33427702724Smrg	*h*)
33527702724Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33627702724Smrg	    tar "$firstarg" "$@" && exit 0
33727702724Smrg	    ;;
33827702724Smrg	esac
33927702724Smrg    fi
34027702724Smrg
34127702724Smrg    echo 1>&2 "\
34227702724SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34327702724Smrg         You may want to install GNU tar or Free paxutils, or check the
34427702724Smrg         command line arguments."
34527702724Smrg    exit 1
34627702724Smrg    ;;
34727702724Smrg
34827702724Smrg  *)
34927702724Smrg    echo 1>&2 "\
35027702724SmrgWARNING: \`$1' is needed, and is $msg.
35127702724Smrg         You might have modified some files without having the
35227702724Smrg         proper tools for further handling them.  Check the \`README' file,
35327702724Smrg         it often tells you about the needed prerequisites for installing
35427702724Smrg         this package.  You may also peek at any GNU archive site, in case
35527702724Smrg         some other package would contain this missing \`$1' program."
35627702724Smrg    exit 1
35727702724Smrg    ;;
35827702724Smrgesac
35927702724Smrg
36027702724Smrgexit 0
36127702724Smrg
36227702724Smrg# Local variables:
36327702724Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36427702724Smrg# time-stamp-start: "scriptversion="
36527702724Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36627702724Smrg# time-stamp-end: "$"
36727702724Smrg# End:
368