missing revision 8255a313
192bb16f8Smrg#! /bin/sh
292bb16f8Smrg# Common stub for a few missing GNU programs while installing.
392bb16f8Smrg
48255a313Smrgscriptversion=2009-04-28.21; # UTC
592bb16f8Smrg
68255a313Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
78255a313Smrg# 2008, 2009 Free Software Foundation, Inc.
892bb16f8Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
992bb16f8Smrg
1092bb16f8Smrg# This program is free software; you can redistribute it and/or modify
1192bb16f8Smrg# it under the terms of the GNU General Public License as published by
1292bb16f8Smrg# the Free Software Foundation; either version 2, or (at your option)
1392bb16f8Smrg# any later version.
1492bb16f8Smrg
1592bb16f8Smrg# This program is distributed in the hope that it will be useful,
1692bb16f8Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1792bb16f8Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1892bb16f8Smrg# GNU General Public License for more details.
1992bb16f8Smrg
2092bb16f8Smrg# You should have received a copy of the GNU General Public License
218255a313Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2292bb16f8Smrg
2392bb16f8Smrg# As a special exception to the GNU General Public License, if you
2492bb16f8Smrg# distribute this file as part of a program that contains a
2592bb16f8Smrg# configuration script generated by Autoconf, you may include it under
2692bb16f8Smrg# the same distribution terms that you use for the rest of that program.
2792bb16f8Smrg
2892bb16f8Smrgif test $# -eq 0; then
2992bb16f8Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3092bb16f8Smrg  exit 1
3192bb16f8Smrgfi
3292bb16f8Smrg
3392bb16f8Smrgrun=:
348255a313Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
358255a313Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3692bb16f8Smrg
3792bb16f8Smrg# In the cases where this matters, `missing' is being run in the
3892bb16f8Smrg# srcdir already.
3992bb16f8Smrgif test -f configure.ac; then
4092bb16f8Smrg  configure_ac=configure.ac
4192bb16f8Smrgelse
4292bb16f8Smrg  configure_ac=configure.in
4392bb16f8Smrgfi
4492bb16f8Smrg
4592bb16f8Smrgmsg="missing on your system"
4692bb16f8Smrg
478255a313Smrgcase $1 in
4892bb16f8Smrg--run)
4992bb16f8Smrg  # Try to run requested program, and just exit if it succeeds.
5092bb16f8Smrg  run=
5192bb16f8Smrg  shift
5292bb16f8Smrg  "$@" && exit 0
5392bb16f8Smrg  # Exit code 63 means version mismatch.  This often happens
5492bb16f8Smrg  # when the user try to use an ancient version of a tool on
5592bb16f8Smrg  # a file that requires a minimum version.  In this case we
5692bb16f8Smrg  # we should proceed has if the program had been absent, or
5792bb16f8Smrg  # if --run hadn't been passed.
5892bb16f8Smrg  if test $? = 63; then
5992bb16f8Smrg    run=:
6092bb16f8Smrg    msg="probably too old"
6192bb16f8Smrg  fi
6292bb16f8Smrg  ;;
6392bb16f8Smrg
6492bb16f8Smrg  -h|--h|--he|--hel|--help)
6592bb16f8Smrg    echo "\
6692bb16f8Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6792bb16f8Smrg
6892bb16f8SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6992bb16f8Smrgerror status if there is no known handling for PROGRAM.
7092bb16f8Smrg
7192bb16f8SmrgOptions:
7292bb16f8Smrg  -h, --help      display this help and exit
7392bb16f8Smrg  -v, --version   output version information and exit
7492bb16f8Smrg  --run           try to run the given command, and emulate it if it fails
7592bb16f8Smrg
7692bb16f8SmrgSupported PROGRAM values:
7792bb16f8Smrg  aclocal      touch file \`aclocal.m4'
7892bb16f8Smrg  autoconf     touch file \`configure'
7992bb16f8Smrg  autoheader   touch file \`config.h.in'
808255a313Smrg  autom4te     touch the output file, or create a stub one
8192bb16f8Smrg  automake     touch all \`Makefile.in' files
8292bb16f8Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8392bb16f8Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8492bb16f8Smrg  help2man     touch the output file
8592bb16f8Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8692bb16f8Smrg  makeinfo     touch the output file
8792bb16f8Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8892bb16f8Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8992bb16f8Smrg
908255a313SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
918255a313Smrg\`g' are ignored when checking the name.
928255a313Smrg
9392bb16f8SmrgSend bug reports to <bug-automake@gnu.org>."
9492bb16f8Smrg    exit $?
9592bb16f8Smrg    ;;
9692bb16f8Smrg
9792bb16f8Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9892bb16f8Smrg    echo "missing $scriptversion (GNU Automake)"
9992bb16f8Smrg    exit $?
10092bb16f8Smrg    ;;
10192bb16f8Smrg
10292bb16f8Smrg  -*)
10392bb16f8Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10492bb16f8Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10592bb16f8Smrg    exit 1
10692bb16f8Smrg    ;;
10792bb16f8Smrg
10892bb16f8Smrgesac
10992bb16f8Smrg
1108255a313Smrg# normalize program name to check for.
1118255a313Smrgprogram=`echo "$1" | sed '
1128255a313Smrg  s/^gnu-//; t
1138255a313Smrg  s/^gnu//; t
1148255a313Smrg  s/^g//; t'`
1158255a313Smrg
11692bb16f8Smrg# Now exit if we have it, but it failed.  Also exit now if we
11792bb16f8Smrg# don't have it and --version was passed (most likely to detect
1188255a313Smrg# the program).  This is about non-GNU programs, so use $1 not
1198255a313Smrg# $program.
1208255a313Smrgcase $1 in
1218255a313Smrg  lex*|yacc*)
12292bb16f8Smrg    # Not GNU programs, they don't have --version.
12392bb16f8Smrg    ;;
12492bb16f8Smrg
1258255a313Smrg  tar*)
12692bb16f8Smrg    if test -n "$run"; then
12792bb16f8Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12892bb16f8Smrg       exit 1
12992bb16f8Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13092bb16f8Smrg       exit 1
13192bb16f8Smrg    fi
13292bb16f8Smrg    ;;
13392bb16f8Smrg
13492bb16f8Smrg  *)
13592bb16f8Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13692bb16f8Smrg       # We have it, but it failed.
13792bb16f8Smrg       exit 1
13892bb16f8Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13992bb16f8Smrg       # Could not run --version or --help.  This is probably someone
14092bb16f8Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14192bb16f8Smrg       # $TOOL exists and not knowing $TOOL uses missing.
14292bb16f8Smrg       exit 1
14392bb16f8Smrg    fi
14492bb16f8Smrg    ;;
14592bb16f8Smrgesac
14692bb16f8Smrg
14792bb16f8Smrg# If it does not exist, or fails to run (possibly an outdated version),
14892bb16f8Smrg# try to emulate it.
1498255a313Smrgcase $program in
15092bb16f8Smrg  aclocal*)
15192bb16f8Smrg    echo 1>&2 "\
15292bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
15392bb16f8Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15492bb16f8Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15592bb16f8Smrg         any GNU archive site."
15692bb16f8Smrg    touch aclocal.m4
15792bb16f8Smrg    ;;
15892bb16f8Smrg
1598255a313Smrg  autoconf*)
16092bb16f8Smrg    echo 1>&2 "\
16192bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
16292bb16f8Smrg         you modified \`${configure_ac}'.  You might want to install the
16392bb16f8Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16492bb16f8Smrg         archive site."
16592bb16f8Smrg    touch configure
16692bb16f8Smrg    ;;
16792bb16f8Smrg
1688255a313Smrg  autoheader*)
16992bb16f8Smrg    echo 1>&2 "\
17092bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
17192bb16f8Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17292bb16f8Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17392bb16f8Smrg         from any GNU archive site."
17492bb16f8Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17592bb16f8Smrg    test -z "$files" && files="config.h"
17692bb16f8Smrg    touch_files=
17792bb16f8Smrg    for f in $files; do
1788255a313Smrg      case $f in
17992bb16f8Smrg      *:*) touch_files="$touch_files "`echo "$f" |
18092bb16f8Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18192bb16f8Smrg      *) touch_files="$touch_files $f.in";;
18292bb16f8Smrg      esac
18392bb16f8Smrg    done
18492bb16f8Smrg    touch $touch_files
18592bb16f8Smrg    ;;
18692bb16f8Smrg
18792bb16f8Smrg  automake*)
18892bb16f8Smrg    echo 1>&2 "\
18992bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
19092bb16f8Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19192bb16f8Smrg         You might want to install the \`Automake' and \`Perl' packages.
19292bb16f8Smrg         Grab them from any GNU archive site."
19392bb16f8Smrg    find . -type f -name Makefile.am -print |
19492bb16f8Smrg	   sed 's/\.am$/.in/' |
19592bb16f8Smrg	   while read f; do touch "$f"; done
19692bb16f8Smrg    ;;
19792bb16f8Smrg
1988255a313Smrg  autom4te*)
19992bb16f8Smrg    echo 1>&2 "\
20092bb16f8SmrgWARNING: \`$1' is needed, but is $msg.
20192bb16f8Smrg         You might have modified some files without having the
20292bb16f8Smrg         proper tools for further handling them.
20392bb16f8Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
20492bb16f8Smrg         archive site."
20592bb16f8Smrg
2068255a313Smrg    file=`echo "$*" | sed -n "$sed_output"`
2078255a313Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20892bb16f8Smrg    if test -f "$file"; then
20992bb16f8Smrg	touch $file
21092bb16f8Smrg    else
21192bb16f8Smrg	test -z "$file" || exec >$file
21292bb16f8Smrg	echo "#! /bin/sh"
21392bb16f8Smrg	echo "# Created by GNU Automake missing as a replacement of"
21492bb16f8Smrg	echo "#  $ $@"
21592bb16f8Smrg	echo "exit 0"
21692bb16f8Smrg	chmod +x $file
21792bb16f8Smrg	exit 1
21892bb16f8Smrg    fi
21992bb16f8Smrg    ;;
22092bb16f8Smrg
2218255a313Smrg  bison*|yacc*)
22292bb16f8Smrg    echo 1>&2 "\
22392bb16f8SmrgWARNING: \`$1' $msg.  You should only need it if
22492bb16f8Smrg         you modified a \`.y' file.  You may need the \`Bison' package
22592bb16f8Smrg         in order for those modifications to take effect.  You can get
22692bb16f8Smrg         \`Bison' from any GNU archive site."
22792bb16f8Smrg    rm -f y.tab.c y.tab.h
2288255a313Smrg    if test $# -ne 1; then
22992bb16f8Smrg        eval LASTARG="\${$#}"
2308255a313Smrg	case $LASTARG in
23192bb16f8Smrg	*.y)
23292bb16f8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2338255a313Smrg	    if test -f "$SRCFILE"; then
23492bb16f8Smrg	         cp "$SRCFILE" y.tab.c
23592bb16f8Smrg	    fi
23692bb16f8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2378255a313Smrg	    if test -f "$SRCFILE"; then
23892bb16f8Smrg	         cp "$SRCFILE" y.tab.h
23992bb16f8Smrg	    fi
24092bb16f8Smrg	  ;;
24192bb16f8Smrg	esac
24292bb16f8Smrg    fi
2438255a313Smrg    if test ! -f y.tab.h; then
24492bb16f8Smrg	echo >y.tab.h
24592bb16f8Smrg    fi
2468255a313Smrg    if test ! -f y.tab.c; then
24792bb16f8Smrg	echo 'main() { return 0; }' >y.tab.c
24892bb16f8Smrg    fi
24992bb16f8Smrg    ;;
25092bb16f8Smrg
2518255a313Smrg  lex*|flex*)
25292bb16f8Smrg    echo 1>&2 "\
25392bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
25492bb16f8Smrg         you modified a \`.l' file.  You may need the \`Flex' package
25592bb16f8Smrg         in order for those modifications to take effect.  You can get
25692bb16f8Smrg         \`Flex' from any GNU archive site."
25792bb16f8Smrg    rm -f lex.yy.c
2588255a313Smrg    if test $# -ne 1; then
25992bb16f8Smrg        eval LASTARG="\${$#}"
2608255a313Smrg	case $LASTARG in
26192bb16f8Smrg	*.l)
26292bb16f8Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2638255a313Smrg	    if test -f "$SRCFILE"; then
26492bb16f8Smrg	         cp "$SRCFILE" lex.yy.c
26592bb16f8Smrg	    fi
26692bb16f8Smrg	  ;;
26792bb16f8Smrg	esac
26892bb16f8Smrg    fi
2698255a313Smrg    if test ! -f lex.yy.c; then
27092bb16f8Smrg	echo 'main() { return 0; }' >lex.yy.c
27192bb16f8Smrg    fi
27292bb16f8Smrg    ;;
27392bb16f8Smrg
2748255a313Smrg  help2man*)
27592bb16f8Smrg    echo 1>&2 "\
27692bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
27792bb16f8Smrg	 you modified a dependency of a manual page.  You may need the
27892bb16f8Smrg	 \`Help2man' package in order for those modifications to take
27992bb16f8Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
28092bb16f8Smrg
2818255a313Smrg    file=`echo "$*" | sed -n "$sed_output"`
2828255a313Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2838255a313Smrg    if test -f "$file"; then
28492bb16f8Smrg	touch $file
28592bb16f8Smrg    else
28692bb16f8Smrg	test -z "$file" || exec >$file
28792bb16f8Smrg	echo ".ab help2man is required to generate this page"
2888255a313Smrg	exit $?
28992bb16f8Smrg    fi
29092bb16f8Smrg    ;;
29192bb16f8Smrg
2928255a313Smrg  makeinfo*)
29392bb16f8Smrg    echo 1>&2 "\
29492bb16f8SmrgWARNING: \`$1' is $msg.  You should only need it if
29592bb16f8Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29692bb16f8Smrg         indirectly affecting the aspect of the manual.  The spurious
29792bb16f8Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29892bb16f8Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29992bb16f8Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
30092bb16f8Smrg    # The file to touch is that specified with -o ...
3018255a313Smrg    file=`echo "$*" | sed -n "$sed_output"`
3028255a313Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30392bb16f8Smrg    if test -z "$file"; then
30492bb16f8Smrg      # ... or it is the one specified with @setfilename ...
30592bb16f8Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3068255a313Smrg      file=`sed -n '
3078255a313Smrg	/^@setfilename/{
3088255a313Smrg	  s/.* \([^ ]*\) *$/\1/
3098255a313Smrg	  p
3108255a313Smrg	  q
3118255a313Smrg	}' $infile`
31292bb16f8Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31392bb16f8Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31492bb16f8Smrg    fi
31592bb16f8Smrg    # If the file does not exist, the user really needs makeinfo;
31692bb16f8Smrg    # let's fail without touching anything.
31792bb16f8Smrg    test -f $file || exit 1
31892bb16f8Smrg    touch $file
31992bb16f8Smrg    ;;
32092bb16f8Smrg
3218255a313Smrg  tar*)
32292bb16f8Smrg    shift
32392bb16f8Smrg
32492bb16f8Smrg    # We have already tried tar in the generic part.
32592bb16f8Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
32692bb16f8Smrg    # messages.
32792bb16f8Smrg    if (gnutar --version > /dev/null 2>&1); then
32892bb16f8Smrg       gnutar "$@" && exit 0
32992bb16f8Smrg    fi
33092bb16f8Smrg    if (gtar --version > /dev/null 2>&1); then
33192bb16f8Smrg       gtar "$@" && exit 0
33292bb16f8Smrg    fi
33392bb16f8Smrg    firstarg="$1"
33492bb16f8Smrg    if shift; then
3358255a313Smrg	case $firstarg in
33692bb16f8Smrg	*o*)
33792bb16f8Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33892bb16f8Smrg	    tar "$firstarg" "$@" && exit 0
33992bb16f8Smrg	    ;;
34092bb16f8Smrg	esac
3418255a313Smrg	case $firstarg in
34292bb16f8Smrg	*h*)
34392bb16f8Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
34492bb16f8Smrg	    tar "$firstarg" "$@" && exit 0
34592bb16f8Smrg	    ;;
34692bb16f8Smrg	esac
34792bb16f8Smrg    fi
34892bb16f8Smrg
34992bb16f8Smrg    echo 1>&2 "\
35092bb16f8SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35192bb16f8Smrg         You may want to install GNU tar or Free paxutils, or check the
35292bb16f8Smrg         command line arguments."
35392bb16f8Smrg    exit 1
35492bb16f8Smrg    ;;
35592bb16f8Smrg
35692bb16f8Smrg  *)
35792bb16f8Smrg    echo 1>&2 "\
35892bb16f8SmrgWARNING: \`$1' is needed, and is $msg.
35992bb16f8Smrg         You might have modified some files without having the
36092bb16f8Smrg         proper tools for further handling them.  Check the \`README' file,
36192bb16f8Smrg         it often tells you about the needed prerequisites for installing
36292bb16f8Smrg         this package.  You may also peek at any GNU archive site, in case
36392bb16f8Smrg         some other package would contain this missing \`$1' program."
36492bb16f8Smrg    exit 1
36592bb16f8Smrg    ;;
36692bb16f8Smrgesac
36792bb16f8Smrg
36892bb16f8Smrgexit 0
36992bb16f8Smrg
37092bb16f8Smrg# Local variables:
37192bb16f8Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37292bb16f8Smrg# time-stamp-start: "scriptversion="
37392bb16f8Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3748255a313Smrg# time-stamp-time-zone: "UTC"
3758255a313Smrg# time-stamp-end: "; # UTC"
37692bb16f8Smrg# End:
377