missing revision bf2eeab3
114c0a534Smrg#! /bin/sh
214c0a534Smrg# Common stub for a few missing GNU programs while installing.
314c0a534Smrg
4bf2eeab3Smrgscriptversion=2009-04-28.21; # UTC
514c0a534Smrg
6bf2eeab3Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7bf2eeab3Smrg# 2008, 2009 Free Software Foundation, Inc.
814c0a534Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
914c0a534Smrg
1014c0a534Smrg# This program is free software; you can redistribute it and/or modify
1114c0a534Smrg# it under the terms of the GNU General Public License as published by
1214c0a534Smrg# the Free Software Foundation; either version 2, or (at your option)
1314c0a534Smrg# any later version.
1414c0a534Smrg
1514c0a534Smrg# This program is distributed in the hope that it will be useful,
1614c0a534Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1714c0a534Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1814c0a534Smrg# GNU General Public License for more details.
1914c0a534Smrg
2014c0a534Smrg# You should have received a copy of the GNU General Public License
21bf2eeab3Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2214c0a534Smrg
2314c0a534Smrg# As a special exception to the GNU General Public License, if you
2414c0a534Smrg# distribute this file as part of a program that contains a
2514c0a534Smrg# configuration script generated by Autoconf, you may include it under
2614c0a534Smrg# the same distribution terms that you use for the rest of that program.
2714c0a534Smrg
2814c0a534Smrgif test $# -eq 0; then
2914c0a534Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3014c0a534Smrg  exit 1
3114c0a534Smrgfi
3214c0a534Smrg
3314c0a534Smrgrun=:
34bf2eeab3Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35bf2eeab3Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3614c0a534Smrg
3714c0a534Smrg# In the cases where this matters, `missing' is being run in the
3814c0a534Smrg# srcdir already.
3914c0a534Smrgif test -f configure.ac; then
4014c0a534Smrg  configure_ac=configure.ac
4114c0a534Smrgelse
4214c0a534Smrg  configure_ac=configure.in
4314c0a534Smrgfi
4414c0a534Smrg
4514c0a534Smrgmsg="missing on your system"
4614c0a534Smrg
47bf2eeab3Smrgcase $1 in
4814c0a534Smrg--run)
4914c0a534Smrg  # Try to run requested program, and just exit if it succeeds.
5014c0a534Smrg  run=
5114c0a534Smrg  shift
5214c0a534Smrg  "$@" && exit 0
5314c0a534Smrg  # Exit code 63 means version mismatch.  This often happens
5414c0a534Smrg  # when the user try to use an ancient version of a tool on
5514c0a534Smrg  # a file that requires a minimum version.  In this case we
5614c0a534Smrg  # we should proceed has if the program had been absent, or
5714c0a534Smrg  # if --run hadn't been passed.
5814c0a534Smrg  if test $? = 63; then
5914c0a534Smrg    run=:
6014c0a534Smrg    msg="probably too old"
6114c0a534Smrg  fi
6214c0a534Smrg  ;;
6314c0a534Smrg
6414c0a534Smrg  -h|--h|--he|--hel|--help)
6514c0a534Smrg    echo "\
6614c0a534Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6714c0a534Smrg
6814c0a534SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6914c0a534Smrgerror status if there is no known handling for PROGRAM.
7014c0a534Smrg
7114c0a534SmrgOptions:
7214c0a534Smrg  -h, --help      display this help and exit
7314c0a534Smrg  -v, --version   output version information and exit
7414c0a534Smrg  --run           try to run the given command, and emulate it if it fails
7514c0a534Smrg
7614c0a534SmrgSupported PROGRAM values:
7714c0a534Smrg  aclocal      touch file \`aclocal.m4'
7814c0a534Smrg  autoconf     touch file \`configure'
7914c0a534Smrg  autoheader   touch file \`config.h.in'
80bf2eeab3Smrg  autom4te     touch the output file, or create a stub one
8114c0a534Smrg  automake     touch all \`Makefile.in' files
8214c0a534Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8314c0a534Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8414c0a534Smrg  help2man     touch the output file
8514c0a534Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8614c0a534Smrg  makeinfo     touch the output file
8714c0a534Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8814c0a534Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8914c0a534Smrg
90bf2eeab3SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91bf2eeab3Smrg\`g' are ignored when checking the name.
92bf2eeab3Smrg
9314c0a534SmrgSend bug reports to <bug-automake@gnu.org>."
9414c0a534Smrg    exit $?
9514c0a534Smrg    ;;
9614c0a534Smrg
9714c0a534Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9814c0a534Smrg    echo "missing $scriptversion (GNU Automake)"
9914c0a534Smrg    exit $?
10014c0a534Smrg    ;;
10114c0a534Smrg
10214c0a534Smrg  -*)
10314c0a534Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10414c0a534Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10514c0a534Smrg    exit 1
10614c0a534Smrg    ;;
10714c0a534Smrg
10814c0a534Smrgesac
10914c0a534Smrg
110bf2eeab3Smrg# normalize program name to check for.
111bf2eeab3Smrgprogram=`echo "$1" | sed '
112bf2eeab3Smrg  s/^gnu-//; t
113bf2eeab3Smrg  s/^gnu//; t
114bf2eeab3Smrg  s/^g//; t'`
115bf2eeab3Smrg
11614c0a534Smrg# Now exit if we have it, but it failed.  Also exit now if we
11714c0a534Smrg# don't have it and --version was passed (most likely to detect
118bf2eeab3Smrg# the program).  This is about non-GNU programs, so use $1 not
119bf2eeab3Smrg# $program.
120bf2eeab3Smrgcase $1 in
121bf2eeab3Smrg  lex*|yacc*)
12214c0a534Smrg    # Not GNU programs, they don't have --version.
12314c0a534Smrg    ;;
12414c0a534Smrg
125bf2eeab3Smrg  tar*)
12614c0a534Smrg    if test -n "$run"; then
12714c0a534Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12814c0a534Smrg       exit 1
12914c0a534Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13014c0a534Smrg       exit 1
13114c0a534Smrg    fi
13214c0a534Smrg    ;;
13314c0a534Smrg
13414c0a534Smrg  *)
13514c0a534Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13614c0a534Smrg       # We have it, but it failed.
13714c0a534Smrg       exit 1
13814c0a534Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13914c0a534Smrg       # Could not run --version or --help.  This is probably someone
14014c0a534Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14114c0a534Smrg       # $TOOL exists and not knowing $TOOL uses missing.
14214c0a534Smrg       exit 1
14314c0a534Smrg    fi
14414c0a534Smrg    ;;
14514c0a534Smrgesac
14614c0a534Smrg
14714c0a534Smrg# If it does not exist, or fails to run (possibly an outdated version),
14814c0a534Smrg# try to emulate it.
149bf2eeab3Smrgcase $program in
15014c0a534Smrg  aclocal*)
15114c0a534Smrg    echo 1>&2 "\
15214c0a534SmrgWARNING: \`$1' is $msg.  You should only need it if
15314c0a534Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15414c0a534Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15514c0a534Smrg         any GNU archive site."
15614c0a534Smrg    touch aclocal.m4
15714c0a534Smrg    ;;
15814c0a534Smrg
159bf2eeab3Smrg  autoconf*)
16014c0a534Smrg    echo 1>&2 "\
16114c0a534SmrgWARNING: \`$1' is $msg.  You should only need it if
16214c0a534Smrg         you modified \`${configure_ac}'.  You might want to install the
16314c0a534Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16414c0a534Smrg         archive site."
16514c0a534Smrg    touch configure
16614c0a534Smrg    ;;
16714c0a534Smrg
168bf2eeab3Smrg  autoheader*)
16914c0a534Smrg    echo 1>&2 "\
17014c0a534SmrgWARNING: \`$1' is $msg.  You should only need it if
17114c0a534Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17214c0a534Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17314c0a534Smrg         from any GNU archive site."
17414c0a534Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17514c0a534Smrg    test -z "$files" && files="config.h"
17614c0a534Smrg    touch_files=
17714c0a534Smrg    for f in $files; do
178bf2eeab3Smrg      case $f in
17914c0a534Smrg      *:*) touch_files="$touch_files "`echo "$f" |
18014c0a534Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18114c0a534Smrg      *) touch_files="$touch_files $f.in";;
18214c0a534Smrg      esac
18314c0a534Smrg    done
18414c0a534Smrg    touch $touch_files
18514c0a534Smrg    ;;
18614c0a534Smrg
18714c0a534Smrg  automake*)
18814c0a534Smrg    echo 1>&2 "\
18914c0a534SmrgWARNING: \`$1' is $msg.  You should only need it if
19014c0a534Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19114c0a534Smrg         You might want to install the \`Automake' and \`Perl' packages.
19214c0a534Smrg         Grab them from any GNU archive site."
19314c0a534Smrg    find . -type f -name Makefile.am -print |
19414c0a534Smrg	   sed 's/\.am$/.in/' |
19514c0a534Smrg	   while read f; do touch "$f"; done
19614c0a534Smrg    ;;
19714c0a534Smrg
198bf2eeab3Smrg  autom4te*)
19914c0a534Smrg    echo 1>&2 "\
20014c0a534SmrgWARNING: \`$1' is needed, but is $msg.
20114c0a534Smrg         You might have modified some files without having the
20214c0a534Smrg         proper tools for further handling them.
20314c0a534Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
20414c0a534Smrg         archive site."
20514c0a534Smrg
206bf2eeab3Smrg    file=`echo "$*" | sed -n "$sed_output"`
207bf2eeab3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20814c0a534Smrg    if test -f "$file"; then
20914c0a534Smrg	touch $file
21014c0a534Smrg    else
21114c0a534Smrg	test -z "$file" || exec >$file
21214c0a534Smrg	echo "#! /bin/sh"
21314c0a534Smrg	echo "# Created by GNU Automake missing as a replacement of"
21414c0a534Smrg	echo "#  $ $@"
21514c0a534Smrg	echo "exit 0"
21614c0a534Smrg	chmod +x $file
21714c0a534Smrg	exit 1
21814c0a534Smrg    fi
21914c0a534Smrg    ;;
22014c0a534Smrg
221bf2eeab3Smrg  bison*|yacc*)
22214c0a534Smrg    echo 1>&2 "\
22314c0a534SmrgWARNING: \`$1' $msg.  You should only need it if
22414c0a534Smrg         you modified a \`.y' file.  You may need the \`Bison' package
22514c0a534Smrg         in order for those modifications to take effect.  You can get
22614c0a534Smrg         \`Bison' from any GNU archive site."
22714c0a534Smrg    rm -f y.tab.c y.tab.h
228bf2eeab3Smrg    if test $# -ne 1; then
22914c0a534Smrg        eval LASTARG="\${$#}"
230bf2eeab3Smrg	case $LASTARG in
23114c0a534Smrg	*.y)
23214c0a534Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233bf2eeab3Smrg	    if test -f "$SRCFILE"; then
23414c0a534Smrg	         cp "$SRCFILE" y.tab.c
23514c0a534Smrg	    fi
23614c0a534Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237bf2eeab3Smrg	    if test -f "$SRCFILE"; then
23814c0a534Smrg	         cp "$SRCFILE" y.tab.h
23914c0a534Smrg	    fi
24014c0a534Smrg	  ;;
24114c0a534Smrg	esac
24214c0a534Smrg    fi
243bf2eeab3Smrg    if test ! -f y.tab.h; then
24414c0a534Smrg	echo >y.tab.h
24514c0a534Smrg    fi
246bf2eeab3Smrg    if test ! -f y.tab.c; then
24714c0a534Smrg	echo 'main() { return 0; }' >y.tab.c
24814c0a534Smrg    fi
24914c0a534Smrg    ;;
25014c0a534Smrg
251bf2eeab3Smrg  lex*|flex*)
25214c0a534Smrg    echo 1>&2 "\
25314c0a534SmrgWARNING: \`$1' is $msg.  You should only need it if
25414c0a534Smrg         you modified a \`.l' file.  You may need the \`Flex' package
25514c0a534Smrg         in order for those modifications to take effect.  You can get
25614c0a534Smrg         \`Flex' from any GNU archive site."
25714c0a534Smrg    rm -f lex.yy.c
258bf2eeab3Smrg    if test $# -ne 1; then
25914c0a534Smrg        eval LASTARG="\${$#}"
260bf2eeab3Smrg	case $LASTARG in
26114c0a534Smrg	*.l)
26214c0a534Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263bf2eeab3Smrg	    if test -f "$SRCFILE"; then
26414c0a534Smrg	         cp "$SRCFILE" lex.yy.c
26514c0a534Smrg	    fi
26614c0a534Smrg	  ;;
26714c0a534Smrg	esac
26814c0a534Smrg    fi
269bf2eeab3Smrg    if test ! -f lex.yy.c; then
27014c0a534Smrg	echo 'main() { return 0; }' >lex.yy.c
27114c0a534Smrg    fi
27214c0a534Smrg    ;;
27314c0a534Smrg
274bf2eeab3Smrg  help2man*)
27514c0a534Smrg    echo 1>&2 "\
27614c0a534SmrgWARNING: \`$1' is $msg.  You should only need it if
27714c0a534Smrg	 you modified a dependency of a manual page.  You may need the
27814c0a534Smrg	 \`Help2man' package in order for those modifications to take
27914c0a534Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
28014c0a534Smrg
281bf2eeab3Smrg    file=`echo "$*" | sed -n "$sed_output"`
282bf2eeab3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283bf2eeab3Smrg    if test -f "$file"; then
28414c0a534Smrg	touch $file
28514c0a534Smrg    else
28614c0a534Smrg	test -z "$file" || exec >$file
28714c0a534Smrg	echo ".ab help2man is required to generate this page"
288bf2eeab3Smrg	exit $?
28914c0a534Smrg    fi
29014c0a534Smrg    ;;
29114c0a534Smrg
292bf2eeab3Smrg  makeinfo*)
29314c0a534Smrg    echo 1>&2 "\
29414c0a534SmrgWARNING: \`$1' is $msg.  You should only need it if
29514c0a534Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29614c0a534Smrg         indirectly affecting the aspect of the manual.  The spurious
29714c0a534Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29814c0a534Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29914c0a534Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
30014c0a534Smrg    # The file to touch is that specified with -o ...
301bf2eeab3Smrg    file=`echo "$*" | sed -n "$sed_output"`
302bf2eeab3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30314c0a534Smrg    if test -z "$file"; then
30414c0a534Smrg      # ... or it is the one specified with @setfilename ...
30514c0a534Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306bf2eeab3Smrg      file=`sed -n '
307bf2eeab3Smrg	/^@setfilename/{
308bf2eeab3Smrg	  s/.* \([^ ]*\) *$/\1/
309bf2eeab3Smrg	  p
310bf2eeab3Smrg	  q
311bf2eeab3Smrg	}' $infile`
31214c0a534Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31314c0a534Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31414c0a534Smrg    fi
31514c0a534Smrg    # If the file does not exist, the user really needs makeinfo;
31614c0a534Smrg    # let's fail without touching anything.
31714c0a534Smrg    test -f $file || exit 1
31814c0a534Smrg    touch $file
31914c0a534Smrg    ;;
32014c0a534Smrg
321bf2eeab3Smrg  tar*)
32214c0a534Smrg    shift
32314c0a534Smrg
32414c0a534Smrg    # We have already tried tar in the generic part.
32514c0a534Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
32614c0a534Smrg    # messages.
32714c0a534Smrg    if (gnutar --version > /dev/null 2>&1); then
32814c0a534Smrg       gnutar "$@" && exit 0
32914c0a534Smrg    fi
33014c0a534Smrg    if (gtar --version > /dev/null 2>&1); then
33114c0a534Smrg       gtar "$@" && exit 0
33214c0a534Smrg    fi
33314c0a534Smrg    firstarg="$1"
33414c0a534Smrg    if shift; then
335bf2eeab3Smrg	case $firstarg in
33614c0a534Smrg	*o*)
33714c0a534Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33814c0a534Smrg	    tar "$firstarg" "$@" && exit 0
33914c0a534Smrg	    ;;
34014c0a534Smrg	esac
341bf2eeab3Smrg	case $firstarg in
34214c0a534Smrg	*h*)
34314c0a534Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
34414c0a534Smrg	    tar "$firstarg" "$@" && exit 0
34514c0a534Smrg	    ;;
34614c0a534Smrg	esac
34714c0a534Smrg    fi
34814c0a534Smrg
34914c0a534Smrg    echo 1>&2 "\
35014c0a534SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35114c0a534Smrg         You may want to install GNU tar or Free paxutils, or check the
35214c0a534Smrg         command line arguments."
35314c0a534Smrg    exit 1
35414c0a534Smrg    ;;
35514c0a534Smrg
35614c0a534Smrg  *)
35714c0a534Smrg    echo 1>&2 "\
35814c0a534SmrgWARNING: \`$1' is needed, and is $msg.
35914c0a534Smrg         You might have modified some files without having the
36014c0a534Smrg         proper tools for further handling them.  Check the \`README' file,
36114c0a534Smrg         it often tells you about the needed prerequisites for installing
36214c0a534Smrg         this package.  You may also peek at any GNU archive site, in case
36314c0a534Smrg         some other package would contain this missing \`$1' program."
36414c0a534Smrg    exit 1
36514c0a534Smrg    ;;
36614c0a534Smrgesac
36714c0a534Smrg
36814c0a534Smrgexit 0
36914c0a534Smrg
37014c0a534Smrg# Local variables:
37114c0a534Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37214c0a534Smrg# time-stamp-start: "scriptversion="
37314c0a534Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374bf2eeab3Smrg# time-stamp-time-zone: "UTC"
375bf2eeab3Smrg# time-stamp-end: "; # UTC"
37614c0a534Smrg# End:
377