missing revision 2a51b5be
132b578d3Smrg#! /bin/sh
232b578d3Smrg# Common stub for a few missing GNU programs while installing.
332b578d3Smrg
42a51b5beSmrgscriptversion=2009-04-28.21; # UTC
532b578d3Smrg
62a51b5beSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
72a51b5beSmrg# 2008, 2009 Free Software Foundation, Inc.
832b578d3Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
932b578d3Smrg
1032b578d3Smrg# This program is free software; you can redistribute it and/or modify
1132b578d3Smrg# it under the terms of the GNU General Public License as published by
1232b578d3Smrg# the Free Software Foundation; either version 2, or (at your option)
1332b578d3Smrg# any later version.
1432b578d3Smrg
1532b578d3Smrg# This program is distributed in the hope that it will be useful,
1632b578d3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1732b578d3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1832b578d3Smrg# GNU General Public License for more details.
1932b578d3Smrg
2032b578d3Smrg# You should have received a copy of the GNU General Public License
212a51b5beSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2232b578d3Smrg
2332b578d3Smrg# As a special exception to the GNU General Public License, if you
2432b578d3Smrg# distribute this file as part of a program that contains a
2532b578d3Smrg# configuration script generated by Autoconf, you may include it under
2632b578d3Smrg# the same distribution terms that you use for the rest of that program.
2732b578d3Smrg
2832b578d3Smrgif test $# -eq 0; then
2932b578d3Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3032b578d3Smrg  exit 1
3132b578d3Smrgfi
3232b578d3Smrg
3332b578d3Smrgrun=:
3432b578d3Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3532b578d3Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3632b578d3Smrg
3732b578d3Smrg# In the cases where this matters, `missing' is being run in the
3832b578d3Smrg# srcdir already.
3932b578d3Smrgif test -f configure.ac; then
4032b578d3Smrg  configure_ac=configure.ac
4132b578d3Smrgelse
4232b578d3Smrg  configure_ac=configure.in
4332b578d3Smrgfi
4432b578d3Smrg
4532b578d3Smrgmsg="missing on your system"
4632b578d3Smrg
4732b578d3Smrgcase $1 in
4832b578d3Smrg--run)
4932b578d3Smrg  # Try to run requested program, and just exit if it succeeds.
5032b578d3Smrg  run=
5132b578d3Smrg  shift
5232b578d3Smrg  "$@" && exit 0
5332b578d3Smrg  # Exit code 63 means version mismatch.  This often happens
5432b578d3Smrg  # when the user try to use an ancient version of a tool on
5532b578d3Smrg  # a file that requires a minimum version.  In this case we
5632b578d3Smrg  # we should proceed has if the program had been absent, or
5732b578d3Smrg  # if --run hadn't been passed.
5832b578d3Smrg  if test $? = 63; then
5932b578d3Smrg    run=:
6032b578d3Smrg    msg="probably too old"
6132b578d3Smrg  fi
6232b578d3Smrg  ;;
6332b578d3Smrg
6432b578d3Smrg  -h|--h|--he|--hel|--help)
6532b578d3Smrg    echo "\
6632b578d3Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6732b578d3Smrg
6832b578d3SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6932b578d3Smrgerror status if there is no known handling for PROGRAM.
7032b578d3Smrg
7132b578d3SmrgOptions:
7232b578d3Smrg  -h, --help      display this help and exit
7332b578d3Smrg  -v, --version   output version information and exit
7432b578d3Smrg  --run           try to run the given command, and emulate it if it fails
7532b578d3Smrg
7632b578d3SmrgSupported PROGRAM values:
7732b578d3Smrg  aclocal      touch file \`aclocal.m4'
7832b578d3Smrg  autoconf     touch file \`configure'
7932b578d3Smrg  autoheader   touch file \`config.h.in'
8032b578d3Smrg  autom4te     touch the output file, or create a stub one
8132b578d3Smrg  automake     touch all \`Makefile.in' files
8232b578d3Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8332b578d3Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8432b578d3Smrg  help2man     touch the output file
8532b578d3Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8632b578d3Smrg  makeinfo     touch the output file
8732b578d3Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8832b578d3Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8932b578d3Smrg
902a51b5beSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
912a51b5beSmrg\`g' are ignored when checking the name.
922a51b5beSmrg
9332b578d3SmrgSend bug reports to <bug-automake@gnu.org>."
9432b578d3Smrg    exit $?
9532b578d3Smrg    ;;
9632b578d3Smrg
9732b578d3Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9832b578d3Smrg    echo "missing $scriptversion (GNU Automake)"
9932b578d3Smrg    exit $?
10032b578d3Smrg    ;;
10132b578d3Smrg
10232b578d3Smrg  -*)
10332b578d3Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10432b578d3Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10532b578d3Smrg    exit 1
10632b578d3Smrg    ;;
10732b578d3Smrg
10832b578d3Smrgesac
10932b578d3Smrg
1102a51b5beSmrg# normalize program name to check for.
1112a51b5beSmrgprogram=`echo "$1" | sed '
1122a51b5beSmrg  s/^gnu-//; t
1132a51b5beSmrg  s/^gnu//; t
1142a51b5beSmrg  s/^g//; t'`
1152a51b5beSmrg
11632b578d3Smrg# Now exit if we have it, but it failed.  Also exit now if we
11732b578d3Smrg# don't have it and --version was passed (most likely to detect
1182a51b5beSmrg# the program).  This is about non-GNU programs, so use $1 not
1192a51b5beSmrg# $program.
12032b578d3Smrgcase $1 in
1212a51b5beSmrg  lex*|yacc*)
12232b578d3Smrg    # Not GNU programs, they don't have --version.
12332b578d3Smrg    ;;
12432b578d3Smrg
1252a51b5beSmrg  tar*)
12632b578d3Smrg    if test -n "$run"; then
12732b578d3Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12832b578d3Smrg       exit 1
12932b578d3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13032b578d3Smrg       exit 1
13132b578d3Smrg    fi
13232b578d3Smrg    ;;
13332b578d3Smrg
13432b578d3Smrg  *)
13532b578d3Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13632b578d3Smrg       # We have it, but it failed.
13732b578d3Smrg       exit 1
13832b578d3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13932b578d3Smrg       # Could not run --version or --help.  This is probably someone
14032b578d3Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14132b578d3Smrg       # $TOOL exists and not knowing $TOOL uses missing.
14232b578d3Smrg       exit 1
14332b578d3Smrg    fi
14432b578d3Smrg    ;;
14532b578d3Smrgesac
14632b578d3Smrg
14732b578d3Smrg# If it does not exist, or fails to run (possibly an outdated version),
14832b578d3Smrg# try to emulate it.
1492a51b5beSmrgcase $program in
15032b578d3Smrg  aclocal*)
15132b578d3Smrg    echo 1>&2 "\
15232b578d3SmrgWARNING: \`$1' is $msg.  You should only need it if
15332b578d3Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15432b578d3Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15532b578d3Smrg         any GNU archive site."
15632b578d3Smrg    touch aclocal.m4
15732b578d3Smrg    ;;
15832b578d3Smrg
1592a51b5beSmrg  autoconf*)
16032b578d3Smrg    echo 1>&2 "\
16132b578d3SmrgWARNING: \`$1' is $msg.  You should only need it if
16232b578d3Smrg         you modified \`${configure_ac}'.  You might want to install the
16332b578d3Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16432b578d3Smrg         archive site."
16532b578d3Smrg    touch configure
16632b578d3Smrg    ;;
16732b578d3Smrg
1682a51b5beSmrg  autoheader*)
16932b578d3Smrg    echo 1>&2 "\
17032b578d3SmrgWARNING: \`$1' is $msg.  You should only need it if
17132b578d3Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17232b578d3Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17332b578d3Smrg         from any GNU archive site."
17432b578d3Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17532b578d3Smrg    test -z "$files" && files="config.h"
17632b578d3Smrg    touch_files=
17732b578d3Smrg    for f in $files; do
17832b578d3Smrg      case $f in
17932b578d3Smrg      *:*) touch_files="$touch_files "`echo "$f" |
18032b578d3Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18132b578d3Smrg      *) touch_files="$touch_files $f.in";;
18232b578d3Smrg      esac
18332b578d3Smrg    done
18432b578d3Smrg    touch $touch_files
18532b578d3Smrg    ;;
18632b578d3Smrg
18732b578d3Smrg  automake*)
18832b578d3Smrg    echo 1>&2 "\
18932b578d3SmrgWARNING: \`$1' is $msg.  You should only need it if
19032b578d3Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19132b578d3Smrg         You might want to install the \`Automake' and \`Perl' packages.
19232b578d3Smrg         Grab them from any GNU archive site."
19332b578d3Smrg    find . -type f -name Makefile.am -print |
19432b578d3Smrg	   sed 's/\.am$/.in/' |
19532b578d3Smrg	   while read f; do touch "$f"; done
19632b578d3Smrg    ;;
19732b578d3Smrg
1982a51b5beSmrg  autom4te*)
19932b578d3Smrg    echo 1>&2 "\
20032b578d3SmrgWARNING: \`$1' is needed, but is $msg.
20132b578d3Smrg         You might have modified some files without having the
20232b578d3Smrg         proper tools for further handling them.
20332b578d3Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
20432b578d3Smrg         archive site."
20532b578d3Smrg
20632b578d3Smrg    file=`echo "$*" | sed -n "$sed_output"`
20732b578d3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20832b578d3Smrg    if test -f "$file"; then
20932b578d3Smrg	touch $file
21032b578d3Smrg    else
21132b578d3Smrg	test -z "$file" || exec >$file
21232b578d3Smrg	echo "#! /bin/sh"
21332b578d3Smrg	echo "# Created by GNU Automake missing as a replacement of"
21432b578d3Smrg	echo "#  $ $@"
21532b578d3Smrg	echo "exit 0"
21632b578d3Smrg	chmod +x $file
21732b578d3Smrg	exit 1
21832b578d3Smrg    fi
21932b578d3Smrg    ;;
22032b578d3Smrg
2212a51b5beSmrg  bison*|yacc*)
22232b578d3Smrg    echo 1>&2 "\
22332b578d3SmrgWARNING: \`$1' $msg.  You should only need it if
22432b578d3Smrg         you modified a \`.y' file.  You may need the \`Bison' package
22532b578d3Smrg         in order for those modifications to take effect.  You can get
22632b578d3Smrg         \`Bison' from any GNU archive site."
22732b578d3Smrg    rm -f y.tab.c y.tab.h
22832b578d3Smrg    if test $# -ne 1; then
22932b578d3Smrg        eval LASTARG="\${$#}"
23032b578d3Smrg	case $LASTARG in
23132b578d3Smrg	*.y)
23232b578d3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
23332b578d3Smrg	    if test -f "$SRCFILE"; then
23432b578d3Smrg	         cp "$SRCFILE" y.tab.c
23532b578d3Smrg	    fi
23632b578d3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
23732b578d3Smrg	    if test -f "$SRCFILE"; then
23832b578d3Smrg	         cp "$SRCFILE" y.tab.h
23932b578d3Smrg	    fi
24032b578d3Smrg	  ;;
24132b578d3Smrg	esac
24232b578d3Smrg    fi
24332b578d3Smrg    if test ! -f y.tab.h; then
24432b578d3Smrg	echo >y.tab.h
24532b578d3Smrg    fi
24632b578d3Smrg    if test ! -f y.tab.c; then
24732b578d3Smrg	echo 'main() { return 0; }' >y.tab.c
24832b578d3Smrg    fi
24932b578d3Smrg    ;;
25032b578d3Smrg
2512a51b5beSmrg  lex*|flex*)
25232b578d3Smrg    echo 1>&2 "\
25332b578d3SmrgWARNING: \`$1' is $msg.  You should only need it if
25432b578d3Smrg         you modified a \`.l' file.  You may need the \`Flex' package
25532b578d3Smrg         in order for those modifications to take effect.  You can get
25632b578d3Smrg         \`Flex' from any GNU archive site."
25732b578d3Smrg    rm -f lex.yy.c
25832b578d3Smrg    if test $# -ne 1; then
25932b578d3Smrg        eval LASTARG="\${$#}"
26032b578d3Smrg	case $LASTARG in
26132b578d3Smrg	*.l)
26232b578d3Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
26332b578d3Smrg	    if test -f "$SRCFILE"; then
26432b578d3Smrg	         cp "$SRCFILE" lex.yy.c
26532b578d3Smrg	    fi
26632b578d3Smrg	  ;;
26732b578d3Smrg	esac
26832b578d3Smrg    fi
26932b578d3Smrg    if test ! -f lex.yy.c; then
27032b578d3Smrg	echo 'main() { return 0; }' >lex.yy.c
27132b578d3Smrg    fi
27232b578d3Smrg    ;;
27332b578d3Smrg
2742a51b5beSmrg  help2man*)
27532b578d3Smrg    echo 1>&2 "\
27632b578d3SmrgWARNING: \`$1' is $msg.  You should only need it if
27732b578d3Smrg	 you modified a dependency of a manual page.  You may need the
27832b578d3Smrg	 \`Help2man' package in order for those modifications to take
27932b578d3Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
28032b578d3Smrg
28132b578d3Smrg    file=`echo "$*" | sed -n "$sed_output"`
28232b578d3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
28332b578d3Smrg    if test -f "$file"; then
28432b578d3Smrg	touch $file
28532b578d3Smrg    else
28632b578d3Smrg	test -z "$file" || exec >$file
28732b578d3Smrg	echo ".ab help2man is required to generate this page"
2882a51b5beSmrg	exit $?
28932b578d3Smrg    fi
29032b578d3Smrg    ;;
29132b578d3Smrg
2922a51b5beSmrg  makeinfo*)
29332b578d3Smrg    echo 1>&2 "\
29432b578d3SmrgWARNING: \`$1' is $msg.  You should only need it if
29532b578d3Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29632b578d3Smrg         indirectly affecting the aspect of the manual.  The spurious
29732b578d3Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29832b578d3Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29932b578d3Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
30032b578d3Smrg    # The file to touch is that specified with -o ...
30132b578d3Smrg    file=`echo "$*" | sed -n "$sed_output"`
30232b578d3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30332b578d3Smrg    if test -z "$file"; then
30432b578d3Smrg      # ... or it is the one specified with @setfilename ...
30532b578d3Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
30632b578d3Smrg      file=`sed -n '
30732b578d3Smrg	/^@setfilename/{
30832b578d3Smrg	  s/.* \([^ ]*\) *$/\1/
30932b578d3Smrg	  p
31032b578d3Smrg	  q
31132b578d3Smrg	}' $infile`
31232b578d3Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31332b578d3Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31432b578d3Smrg    fi
31532b578d3Smrg    # If the file does not exist, the user really needs makeinfo;
31632b578d3Smrg    # let's fail without touching anything.
31732b578d3Smrg    test -f $file || exit 1
31832b578d3Smrg    touch $file
31932b578d3Smrg    ;;
32032b578d3Smrg
3212a51b5beSmrg  tar*)
32232b578d3Smrg    shift
32332b578d3Smrg
32432b578d3Smrg    # We have already tried tar in the generic part.
32532b578d3Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
32632b578d3Smrg    # messages.
32732b578d3Smrg    if (gnutar --version > /dev/null 2>&1); then
32832b578d3Smrg       gnutar "$@" && exit 0
32932b578d3Smrg    fi
33032b578d3Smrg    if (gtar --version > /dev/null 2>&1); then
33132b578d3Smrg       gtar "$@" && exit 0
33232b578d3Smrg    fi
33332b578d3Smrg    firstarg="$1"
33432b578d3Smrg    if shift; then
33532b578d3Smrg	case $firstarg in
33632b578d3Smrg	*o*)
33732b578d3Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33832b578d3Smrg	    tar "$firstarg" "$@" && exit 0
33932b578d3Smrg	    ;;
34032b578d3Smrg	esac
34132b578d3Smrg	case $firstarg in
34232b578d3Smrg	*h*)
34332b578d3Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
34432b578d3Smrg	    tar "$firstarg" "$@" && exit 0
34532b578d3Smrg	    ;;
34632b578d3Smrg	esac
34732b578d3Smrg    fi
34832b578d3Smrg
34932b578d3Smrg    echo 1>&2 "\
35032b578d3SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35132b578d3Smrg         You may want to install GNU tar or Free paxutils, or check the
35232b578d3Smrg         command line arguments."
35332b578d3Smrg    exit 1
35432b578d3Smrg    ;;
35532b578d3Smrg
35632b578d3Smrg  *)
35732b578d3Smrg    echo 1>&2 "\
35832b578d3SmrgWARNING: \`$1' is needed, and is $msg.
35932b578d3Smrg         You might have modified some files without having the
36032b578d3Smrg         proper tools for further handling them.  Check the \`README' file,
36132b578d3Smrg         it often tells you about the needed prerequisites for installing
36232b578d3Smrg         this package.  You may also peek at any GNU archive site, in case
36332b578d3Smrg         some other package would contain this missing \`$1' program."
36432b578d3Smrg    exit 1
36532b578d3Smrg    ;;
36632b578d3Smrgesac
36732b578d3Smrg
36832b578d3Smrgexit 0
36932b578d3Smrg
37032b578d3Smrg# Local variables:
37132b578d3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37232b578d3Smrg# time-stamp-start: "scriptversion="
37332b578d3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3742a51b5beSmrg# time-stamp-time-zone: "UTC"
3752a51b5beSmrg# time-stamp-end: "; # UTC"
37632b578d3Smrg# End:
377