152f9793fSmrg#! /bin/sh
252f9793fSmrg# Common stub for a few missing GNU programs while installing.
352f9793fSmrg
42faa96e0Smrgscriptversion=2009-04-28.21; # UTC
552f9793fSmrg
62faa96e0Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
72faa96e0Smrg# 2008, 2009 Free Software Foundation, Inc.
852f9793fSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
952f9793fSmrg
1052f9793fSmrg# This program is free software; you can redistribute it and/or modify
1152f9793fSmrg# it under the terms of the GNU General Public License as published by
1252f9793fSmrg# the Free Software Foundation; either version 2, or (at your option)
1352f9793fSmrg# any later version.
1452f9793fSmrg
1552f9793fSmrg# This program is distributed in the hope that it will be useful,
1652f9793fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1752f9793fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1852f9793fSmrg# GNU General Public License for more details.
1952f9793fSmrg
2052f9793fSmrg# You should have received a copy of the GNU General Public License
212faa96e0Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2252f9793fSmrg
2352f9793fSmrg# As a special exception to the GNU General Public License, if you
2452f9793fSmrg# distribute this file as part of a program that contains a
2552f9793fSmrg# configuration script generated by Autoconf, you may include it under
2652f9793fSmrg# the same distribution terms that you use for the rest of that program.
2752f9793fSmrg
2852f9793fSmrgif test $# -eq 0; then
2952f9793fSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3052f9793fSmrg  exit 1
3152f9793fSmrgfi
3252f9793fSmrg
3352f9793fSmrgrun=:
342faa96e0Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
352faa96e0Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3652f9793fSmrg
3752f9793fSmrg# In the cases where this matters, `missing' is being run in the
3852f9793fSmrg# srcdir already.
3952f9793fSmrgif test -f configure.ac; then
4052f9793fSmrg  configure_ac=configure.ac
4152f9793fSmrgelse
4252f9793fSmrg  configure_ac=configure.in
4352f9793fSmrgfi
4452f9793fSmrg
4552f9793fSmrgmsg="missing on your system"
4652f9793fSmrg
472faa96e0Smrgcase $1 in
4852f9793fSmrg--run)
4952f9793fSmrg  # Try to run requested program, and just exit if it succeeds.
5052f9793fSmrg  run=
5152f9793fSmrg  shift
5252f9793fSmrg  "$@" && exit 0
5352f9793fSmrg  # Exit code 63 means version mismatch.  This often happens
5452f9793fSmrg  # when the user try to use an ancient version of a tool on
5552f9793fSmrg  # a file that requires a minimum version.  In this case we
5652f9793fSmrg  # we should proceed has if the program had been absent, or
5752f9793fSmrg  # if --run hadn't been passed.
5852f9793fSmrg  if test $? = 63; then
5952f9793fSmrg    run=:
6052f9793fSmrg    msg="probably too old"
6152f9793fSmrg  fi
6252f9793fSmrg  ;;
6352f9793fSmrg
6452f9793fSmrg  -h|--h|--he|--hel|--help)
6552f9793fSmrg    echo "\
6652f9793fSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6752f9793fSmrg
6852f9793fSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6952f9793fSmrgerror status if there is no known handling for PROGRAM.
7052f9793fSmrg
7152f9793fSmrgOptions:
7252f9793fSmrg  -h, --help      display this help and exit
7352f9793fSmrg  -v, --version   output version information and exit
7452f9793fSmrg  --run           try to run the given command, and emulate it if it fails
7552f9793fSmrg
7652f9793fSmrgSupported PROGRAM values:
7752f9793fSmrg  aclocal      touch file \`aclocal.m4'
7852f9793fSmrg  autoconf     touch file \`configure'
7952f9793fSmrg  autoheader   touch file \`config.h.in'
802faa96e0Smrg  autom4te     touch the output file, or create a stub one
8152f9793fSmrg  automake     touch all \`Makefile.in' files
8252f9793fSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8352f9793fSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8452f9793fSmrg  help2man     touch the output file
8552f9793fSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8652f9793fSmrg  makeinfo     touch the output file
8752f9793fSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8852f9793fSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8952f9793fSmrg
902faa96e0SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
912faa96e0Smrg\`g' are ignored when checking the name.
922faa96e0Smrg
9352f9793fSmrgSend bug reports to <bug-automake@gnu.org>."
9452f9793fSmrg    exit $?
9552f9793fSmrg    ;;
9652f9793fSmrg
9752f9793fSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9852f9793fSmrg    echo "missing $scriptversion (GNU Automake)"
9952f9793fSmrg    exit $?
10052f9793fSmrg    ;;
10152f9793fSmrg
10252f9793fSmrg  -*)
10352f9793fSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10452f9793fSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10552f9793fSmrg    exit 1
10652f9793fSmrg    ;;
10752f9793fSmrg
10852f9793fSmrgesac
10952f9793fSmrg
1102faa96e0Smrg# normalize program name to check for.
1112faa96e0Smrgprogram=`echo "$1" | sed '
1122faa96e0Smrg  s/^gnu-//; t
1132faa96e0Smrg  s/^gnu//; t
1142faa96e0Smrg  s/^g//; t'`
1152faa96e0Smrg
11652f9793fSmrg# Now exit if we have it, but it failed.  Also exit now if we
11752f9793fSmrg# don't have it and --version was passed (most likely to detect
1182faa96e0Smrg# the program).  This is about non-GNU programs, so use $1 not
1192faa96e0Smrg# $program.
1202faa96e0Smrgcase $1 in
1212faa96e0Smrg  lex*|yacc*)
12252f9793fSmrg    # Not GNU programs, they don't have --version.
12352f9793fSmrg    ;;
12452f9793fSmrg
1252faa96e0Smrg  tar*)
12652f9793fSmrg    if test -n "$run"; then
12752f9793fSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
12852f9793fSmrg       exit 1
12952f9793fSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13052f9793fSmrg       exit 1
13152f9793fSmrg    fi
13252f9793fSmrg    ;;
13352f9793fSmrg
13452f9793fSmrg  *)
13552f9793fSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13652f9793fSmrg       # We have it, but it failed.
13752f9793fSmrg       exit 1
13852f9793fSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13952f9793fSmrg       # Could not run --version or --help.  This is probably someone
14052f9793fSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14152f9793fSmrg       # $TOOL exists and not knowing $TOOL uses missing.
14252f9793fSmrg       exit 1
14352f9793fSmrg    fi
14452f9793fSmrg    ;;
14552f9793fSmrgesac
14652f9793fSmrg
14752f9793fSmrg# If it does not exist, or fails to run (possibly an outdated version),
14852f9793fSmrg# try to emulate it.
1492faa96e0Smrgcase $program in
15052f9793fSmrg  aclocal*)
15152f9793fSmrg    echo 1>&2 "\
15252f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
15352f9793fSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15452f9793fSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15552f9793fSmrg         any GNU archive site."
15652f9793fSmrg    touch aclocal.m4
15752f9793fSmrg    ;;
15852f9793fSmrg
1592faa96e0Smrg  autoconf*)
16052f9793fSmrg    echo 1>&2 "\
16152f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
16252f9793fSmrg         you modified \`${configure_ac}'.  You might want to install the
16352f9793fSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16452f9793fSmrg         archive site."
16552f9793fSmrg    touch configure
16652f9793fSmrg    ;;
16752f9793fSmrg
1682faa96e0Smrg  autoheader*)
16952f9793fSmrg    echo 1>&2 "\
17052f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
17152f9793fSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17252f9793fSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17352f9793fSmrg         from any GNU archive site."
17452f9793fSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17552f9793fSmrg    test -z "$files" && files="config.h"
17652f9793fSmrg    touch_files=
17752f9793fSmrg    for f in $files; do
1782faa96e0Smrg      case $f in
17952f9793fSmrg      *:*) touch_files="$touch_files "`echo "$f" |
18052f9793fSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18152f9793fSmrg      *) touch_files="$touch_files $f.in";;
18252f9793fSmrg      esac
18352f9793fSmrg    done
18452f9793fSmrg    touch $touch_files
18552f9793fSmrg    ;;
18652f9793fSmrg
18752f9793fSmrg  automake*)
18852f9793fSmrg    echo 1>&2 "\
18952f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
19052f9793fSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19152f9793fSmrg         You might want to install the \`Automake' and \`Perl' packages.
19252f9793fSmrg         Grab them from any GNU archive site."
19352f9793fSmrg    find . -type f -name Makefile.am -print |
19452f9793fSmrg	   sed 's/\.am$/.in/' |
19552f9793fSmrg	   while read f; do touch "$f"; done
19652f9793fSmrg    ;;
19752f9793fSmrg
1982faa96e0Smrg  autom4te*)
19952f9793fSmrg    echo 1>&2 "\
20052f9793fSmrgWARNING: \`$1' is needed, but is $msg.
20152f9793fSmrg         You might have modified some files without having the
20252f9793fSmrg         proper tools for further handling them.
20352f9793fSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
20452f9793fSmrg         archive site."
20552f9793fSmrg
2062faa96e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
2072faa96e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20852f9793fSmrg    if test -f "$file"; then
20952f9793fSmrg	touch $file
21052f9793fSmrg    else
21152f9793fSmrg	test -z "$file" || exec >$file
21252f9793fSmrg	echo "#! /bin/sh"
21352f9793fSmrg	echo "# Created by GNU Automake missing as a replacement of"
21452f9793fSmrg	echo "#  $ $@"
21552f9793fSmrg	echo "exit 0"
21652f9793fSmrg	chmod +x $file
21752f9793fSmrg	exit 1
21852f9793fSmrg    fi
21952f9793fSmrg    ;;
22052f9793fSmrg
2212faa96e0Smrg  bison*|yacc*)
22252f9793fSmrg    echo 1>&2 "\
22352f9793fSmrgWARNING: \`$1' $msg.  You should only need it if
22452f9793fSmrg         you modified a \`.y' file.  You may need the \`Bison' package
22552f9793fSmrg         in order for those modifications to take effect.  You can get
22652f9793fSmrg         \`Bison' from any GNU archive site."
22752f9793fSmrg    rm -f y.tab.c y.tab.h
2282faa96e0Smrg    if test $# -ne 1; then
22952f9793fSmrg        eval LASTARG="\${$#}"
2302faa96e0Smrg	case $LASTARG in
23152f9793fSmrg	*.y)
23252f9793fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2332faa96e0Smrg	    if test -f "$SRCFILE"; then
23452f9793fSmrg	         cp "$SRCFILE" y.tab.c
23552f9793fSmrg	    fi
23652f9793fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2372faa96e0Smrg	    if test -f "$SRCFILE"; then
23852f9793fSmrg	         cp "$SRCFILE" y.tab.h
23952f9793fSmrg	    fi
24052f9793fSmrg	  ;;
24152f9793fSmrg	esac
24252f9793fSmrg    fi
2432faa96e0Smrg    if test ! -f y.tab.h; then
24452f9793fSmrg	echo >y.tab.h
24552f9793fSmrg    fi
2462faa96e0Smrg    if test ! -f y.tab.c; then
24752f9793fSmrg	echo 'main() { return 0; }' >y.tab.c
24852f9793fSmrg    fi
24952f9793fSmrg    ;;
25052f9793fSmrg
2512faa96e0Smrg  lex*|flex*)
25252f9793fSmrg    echo 1>&2 "\
25352f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
25452f9793fSmrg         you modified a \`.l' file.  You may need the \`Flex' package
25552f9793fSmrg         in order for those modifications to take effect.  You can get
25652f9793fSmrg         \`Flex' from any GNU archive site."
25752f9793fSmrg    rm -f lex.yy.c
2582faa96e0Smrg    if test $# -ne 1; then
25952f9793fSmrg        eval LASTARG="\${$#}"
2602faa96e0Smrg	case $LASTARG in
26152f9793fSmrg	*.l)
26252f9793fSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2632faa96e0Smrg	    if test -f "$SRCFILE"; then
26452f9793fSmrg	         cp "$SRCFILE" lex.yy.c
26552f9793fSmrg	    fi
26652f9793fSmrg	  ;;
26752f9793fSmrg	esac
26852f9793fSmrg    fi
2692faa96e0Smrg    if test ! -f lex.yy.c; then
27052f9793fSmrg	echo 'main() { return 0; }' >lex.yy.c
27152f9793fSmrg    fi
27252f9793fSmrg    ;;
27352f9793fSmrg
2742faa96e0Smrg  help2man*)
27552f9793fSmrg    echo 1>&2 "\
27652f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
27752f9793fSmrg	 you modified a dependency of a manual page.  You may need the
27852f9793fSmrg	 \`Help2man' package in order for those modifications to take
27952f9793fSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
28052f9793fSmrg
2812faa96e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
2822faa96e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2832faa96e0Smrg    if test -f "$file"; then
28452f9793fSmrg	touch $file
28552f9793fSmrg    else
28652f9793fSmrg	test -z "$file" || exec >$file
28752f9793fSmrg	echo ".ab help2man is required to generate this page"
2882faa96e0Smrg	exit $?
28952f9793fSmrg    fi
29052f9793fSmrg    ;;
29152f9793fSmrg
2922faa96e0Smrg  makeinfo*)
29352f9793fSmrg    echo 1>&2 "\
29452f9793fSmrgWARNING: \`$1' is $msg.  You should only need it if
29552f9793fSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29652f9793fSmrg         indirectly affecting the aspect of the manual.  The spurious
29752f9793fSmrg         call might also be the consequence of using a buggy \`make' (AIX,
29852f9793fSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29952f9793fSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
30052f9793fSmrg    # The file to touch is that specified with -o ...
3012faa96e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
3022faa96e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30352f9793fSmrg    if test -z "$file"; then
30452f9793fSmrg      # ... or it is the one specified with @setfilename ...
30552f9793fSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3062faa96e0Smrg      file=`sed -n '
3072faa96e0Smrg	/^@setfilename/{
3082faa96e0Smrg	  s/.* \([^ ]*\) *$/\1/
3092faa96e0Smrg	  p
3102faa96e0Smrg	  q
3112faa96e0Smrg	}' $infile`
31252f9793fSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31352f9793fSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31452f9793fSmrg    fi
31552f9793fSmrg    # If the file does not exist, the user really needs makeinfo;
31652f9793fSmrg    # let's fail without touching anything.
31752f9793fSmrg    test -f $file || exit 1
31852f9793fSmrg    touch $file
31952f9793fSmrg    ;;
32052f9793fSmrg
3212faa96e0Smrg  tar*)
32252f9793fSmrg    shift
32352f9793fSmrg
32452f9793fSmrg    # We have already tried tar in the generic part.
32552f9793fSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
32652f9793fSmrg    # messages.
32752f9793fSmrg    if (gnutar --version > /dev/null 2>&1); then
32852f9793fSmrg       gnutar "$@" && exit 0
32952f9793fSmrg    fi
33052f9793fSmrg    if (gtar --version > /dev/null 2>&1); then
33152f9793fSmrg       gtar "$@" && exit 0
33252f9793fSmrg    fi
33352f9793fSmrg    firstarg="$1"
33452f9793fSmrg    if shift; then
3352faa96e0Smrg	case $firstarg in
33652f9793fSmrg	*o*)
33752f9793fSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
33852f9793fSmrg	    tar "$firstarg" "$@" && exit 0
33952f9793fSmrg	    ;;
34052f9793fSmrg	esac
3412faa96e0Smrg	case $firstarg in
34252f9793fSmrg	*h*)
34352f9793fSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
34452f9793fSmrg	    tar "$firstarg" "$@" && exit 0
34552f9793fSmrg	    ;;
34652f9793fSmrg	esac
34752f9793fSmrg    fi
34852f9793fSmrg
34952f9793fSmrg    echo 1>&2 "\
35052f9793fSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35152f9793fSmrg         You may want to install GNU tar or Free paxutils, or check the
35252f9793fSmrg         command line arguments."
35352f9793fSmrg    exit 1
35452f9793fSmrg    ;;
35552f9793fSmrg
35652f9793fSmrg  *)
35752f9793fSmrg    echo 1>&2 "\
35852f9793fSmrgWARNING: \`$1' is needed, and is $msg.
35952f9793fSmrg         You might have modified some files without having the
36052f9793fSmrg         proper tools for further handling them.  Check the \`README' file,
36152f9793fSmrg         it often tells you about the needed prerequisites for installing
36252f9793fSmrg         this package.  You may also peek at any GNU archive site, in case
36352f9793fSmrg         some other package would contain this missing \`$1' program."
36452f9793fSmrg    exit 1
36552f9793fSmrg    ;;
36652f9793fSmrgesac
36752f9793fSmrg
36852f9793fSmrgexit 0
36952f9793fSmrg
37052f9793fSmrg# Local variables:
37152f9793fSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37252f9793fSmrg# time-stamp-start: "scriptversion="
37352f9793fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3742faa96e0Smrg# time-stamp-time-zone: "UTC"
3752faa96e0Smrg# time-stamp-end: "; # UTC"
37652f9793fSmrg# End:
377