missing revision dd77ae96
172b4363aSmrg#! /bin/sh
272b4363aSmrg# Common stub for a few missing GNU programs while installing.
372b4363aSmrg
4dd77ae96Smrgscriptversion=2009-04-28.21; # UTC
572b4363aSmrg
6dd77ae96Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7dd77ae96Smrg# 2008, 2009 Free Software Foundation, Inc.
872b4363aSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
972b4363aSmrg
1072b4363aSmrg# This program is free software; you can redistribute it and/or modify
1172b4363aSmrg# it under the terms of the GNU General Public License as published by
1272b4363aSmrg# the Free Software Foundation; either version 2, or (at your option)
1372b4363aSmrg# any later version.
1472b4363aSmrg
1572b4363aSmrg# This program is distributed in the hope that it will be useful,
1672b4363aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1772b4363aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1872b4363aSmrg# GNU General Public License for more details.
1972b4363aSmrg
2072b4363aSmrg# You should have received a copy of the GNU General Public License
21dd77ae96Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2272b4363aSmrg
2372b4363aSmrg# As a special exception to the GNU General Public License, if you
2472b4363aSmrg# distribute this file as part of a program that contains a
2572b4363aSmrg# configuration script generated by Autoconf, you may include it under
2672b4363aSmrg# the same distribution terms that you use for the rest of that program.
2772b4363aSmrg
2872b4363aSmrgif test $# -eq 0; then
2972b4363aSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3072b4363aSmrg  exit 1
3172b4363aSmrgfi
3272b4363aSmrg
3372b4363aSmrgrun=:
3472b4363aSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3572b4363aSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3672b4363aSmrg
3772b4363aSmrg# In the cases where this matters, `missing' is being run in the
3872b4363aSmrg# srcdir already.
3972b4363aSmrgif test -f configure.ac; then
4072b4363aSmrg  configure_ac=configure.ac
4172b4363aSmrgelse
4272b4363aSmrg  configure_ac=configure.in
4372b4363aSmrgfi
4472b4363aSmrg
4572b4363aSmrgmsg="missing on your system"
4672b4363aSmrg
4772b4363aSmrgcase $1 in
4872b4363aSmrg--run)
4972b4363aSmrg  # Try to run requested program, and just exit if it succeeds.
5072b4363aSmrg  run=
5172b4363aSmrg  shift
5272b4363aSmrg  "$@" && exit 0
5372b4363aSmrg  # Exit code 63 means version mismatch.  This often happens
5472b4363aSmrg  # when the user try to use an ancient version of a tool on
5572b4363aSmrg  # a file that requires a minimum version.  In this case we
5672b4363aSmrg  # we should proceed has if the program had been absent, or
5772b4363aSmrg  # if --run hadn't been passed.
5872b4363aSmrg  if test $? = 63; then
5972b4363aSmrg    run=:
6072b4363aSmrg    msg="probably too old"
6172b4363aSmrg  fi
6272b4363aSmrg  ;;
6372b4363aSmrg
6472b4363aSmrg  -h|--h|--he|--hel|--help)
6572b4363aSmrg    echo "\
6672b4363aSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6772b4363aSmrg
6872b4363aSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6972b4363aSmrgerror status if there is no known handling for PROGRAM.
7072b4363aSmrg
7172b4363aSmrgOptions:
7272b4363aSmrg  -h, --help      display this help and exit
7372b4363aSmrg  -v, --version   output version information and exit
7472b4363aSmrg  --run           try to run the given command, and emulate it if it fails
7572b4363aSmrg
7672b4363aSmrgSupported PROGRAM values:
7772b4363aSmrg  aclocal      touch file \`aclocal.m4'
7872b4363aSmrg  autoconf     touch file \`configure'
7972b4363aSmrg  autoheader   touch file \`config.h.in'
8072b4363aSmrg  autom4te     touch the output file, or create a stub one
8172b4363aSmrg  automake     touch all \`Makefile.in' files
8272b4363aSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8372b4363aSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8472b4363aSmrg  help2man     touch the output file
8572b4363aSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8672b4363aSmrg  makeinfo     touch the output file
8772b4363aSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8872b4363aSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8972b4363aSmrg
90dd77ae96SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91dd77ae96Smrg\`g' are ignored when checking the name.
92dd77ae96Smrg
9372b4363aSmrgSend bug reports to <bug-automake@gnu.org>."
9472b4363aSmrg    exit $?
9572b4363aSmrg    ;;
9672b4363aSmrg
9772b4363aSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9872b4363aSmrg    echo "missing $scriptversion (GNU Automake)"
9972b4363aSmrg    exit $?
10072b4363aSmrg    ;;
10172b4363aSmrg
10272b4363aSmrg  -*)
10372b4363aSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10472b4363aSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10572b4363aSmrg    exit 1
10672b4363aSmrg    ;;
10772b4363aSmrg
10872b4363aSmrgesac
10972b4363aSmrg
110dd77ae96Smrg# normalize program name to check for.
111dd77ae96Smrgprogram=`echo "$1" | sed '
112dd77ae96Smrg  s/^gnu-//; t
113dd77ae96Smrg  s/^gnu//; t
114dd77ae96Smrg  s/^g//; t'`
115dd77ae96Smrg
11672b4363aSmrg# Now exit if we have it, but it failed.  Also exit now if we
11772b4363aSmrg# don't have it and --version was passed (most likely to detect
118dd77ae96Smrg# the program).  This is about non-GNU programs, so use $1 not
119dd77ae96Smrg# $program.
12072b4363aSmrgcase $1 in
121dd77ae96Smrg  lex*|yacc*)
12272b4363aSmrg    # Not GNU programs, they don't have --version.
12372b4363aSmrg    ;;
12472b4363aSmrg
125dd77ae96Smrg  tar*)
12672b4363aSmrg    if test -n "$run"; then
12772b4363aSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
12872b4363aSmrg       exit 1
12972b4363aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13072b4363aSmrg       exit 1
13172b4363aSmrg    fi
13272b4363aSmrg    ;;
13372b4363aSmrg
13472b4363aSmrg  *)
13572b4363aSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13672b4363aSmrg       # We have it, but it failed.
13772b4363aSmrg       exit 1
13872b4363aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13972b4363aSmrg       # Could not run --version or --help.  This is probably someone
14072b4363aSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14172b4363aSmrg       # $TOOL exists and not knowing $TOOL uses missing.
14272b4363aSmrg       exit 1
14372b4363aSmrg    fi
14472b4363aSmrg    ;;
14572b4363aSmrgesac
14672b4363aSmrg
14772b4363aSmrg# If it does not exist, or fails to run (possibly an outdated version),
14872b4363aSmrg# try to emulate it.
149dd77ae96Smrgcase $program in
15072b4363aSmrg  aclocal*)
15172b4363aSmrg    echo 1>&2 "\
15272b4363aSmrgWARNING: \`$1' is $msg.  You should only need it if
15372b4363aSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15472b4363aSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15572b4363aSmrg         any GNU archive site."
15672b4363aSmrg    touch aclocal.m4
15772b4363aSmrg    ;;
15872b4363aSmrg
159dd77ae96Smrg  autoconf*)
16072b4363aSmrg    echo 1>&2 "\
16172b4363aSmrgWARNING: \`$1' is $msg.  You should only need it if
16272b4363aSmrg         you modified \`${configure_ac}'.  You might want to install the
16372b4363aSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16472b4363aSmrg         archive site."
16572b4363aSmrg    touch configure
16672b4363aSmrg    ;;
16772b4363aSmrg
168dd77ae96Smrg  autoheader*)
16972b4363aSmrg    echo 1>&2 "\
17072b4363aSmrgWARNING: \`$1' is $msg.  You should only need it if
17172b4363aSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17272b4363aSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17372b4363aSmrg         from any GNU archive site."
17472b4363aSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17572b4363aSmrg    test -z "$files" && files="config.h"
17672b4363aSmrg    touch_files=
17772b4363aSmrg    for f in $files; do
17872b4363aSmrg      case $f in
17972b4363aSmrg      *:*) touch_files="$touch_files "`echo "$f" |
18072b4363aSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18172b4363aSmrg      *) touch_files="$touch_files $f.in";;
18272b4363aSmrg      esac
18372b4363aSmrg    done
18472b4363aSmrg    touch $touch_files
18572b4363aSmrg    ;;
18672b4363aSmrg
18772b4363aSmrg  automake*)
18872b4363aSmrg    echo 1>&2 "\
18972b4363aSmrgWARNING: \`$1' is $msg.  You should only need it if
19072b4363aSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19172b4363aSmrg         You might want to install the \`Automake' and \`Perl' packages.
19272b4363aSmrg         Grab them from any GNU archive site."
19372b4363aSmrg    find . -type f -name Makefile.am -print |
19472b4363aSmrg	   sed 's/\.am$/.in/' |
19572b4363aSmrg	   while read f; do touch "$f"; done
19672b4363aSmrg    ;;
19772b4363aSmrg
198dd77ae96Smrg  autom4te*)
19972b4363aSmrg    echo 1>&2 "\
20072b4363aSmrgWARNING: \`$1' is needed, but is $msg.
20172b4363aSmrg         You might have modified some files without having the
20272b4363aSmrg         proper tools for further handling them.
20372b4363aSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
20472b4363aSmrg         archive site."
20572b4363aSmrg
20672b4363aSmrg    file=`echo "$*" | sed -n "$sed_output"`
20772b4363aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20872b4363aSmrg    if test -f "$file"; then
20972b4363aSmrg	touch $file
21072b4363aSmrg    else
21172b4363aSmrg	test -z "$file" || exec >$file
21272b4363aSmrg	echo "#! /bin/sh"
21372b4363aSmrg	echo "# Created by GNU Automake missing as a replacement of"
21472b4363aSmrg	echo "#  $ $@"
21572b4363aSmrg	echo "exit 0"
21672b4363aSmrg	chmod +x $file
21772b4363aSmrg	exit 1
21872b4363aSmrg    fi
21972b4363aSmrg    ;;
22072b4363aSmrg
221dd77ae96Smrg  bison*|yacc*)
22272b4363aSmrg    echo 1>&2 "\
22372b4363aSmrgWARNING: \`$1' $msg.  You should only need it if
22472b4363aSmrg         you modified a \`.y' file.  You may need the \`Bison' package
22572b4363aSmrg         in order for those modifications to take effect.  You can get
22672b4363aSmrg         \`Bison' from any GNU archive site."
22772b4363aSmrg    rm -f y.tab.c y.tab.h
22872b4363aSmrg    if test $# -ne 1; then
22972b4363aSmrg        eval LASTARG="\${$#}"
23072b4363aSmrg	case $LASTARG in
23172b4363aSmrg	*.y)
23272b4363aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
23372b4363aSmrg	    if test -f "$SRCFILE"; then
23472b4363aSmrg	         cp "$SRCFILE" y.tab.c
23572b4363aSmrg	    fi
23672b4363aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
23772b4363aSmrg	    if test -f "$SRCFILE"; then
23872b4363aSmrg	         cp "$SRCFILE" y.tab.h
23972b4363aSmrg	    fi
24072b4363aSmrg	  ;;
24172b4363aSmrg	esac
24272b4363aSmrg    fi
24372b4363aSmrg    if test ! -f y.tab.h; then
24472b4363aSmrg	echo >y.tab.h
24572b4363aSmrg    fi
24672b4363aSmrg    if test ! -f y.tab.c; then
24772b4363aSmrg	echo 'main() { return 0; }' >y.tab.c
24872b4363aSmrg    fi
24972b4363aSmrg    ;;
25072b4363aSmrg
251dd77ae96Smrg  lex*|flex*)
25272b4363aSmrg    echo 1>&2 "\
25372b4363aSmrgWARNING: \`$1' is $msg.  You should only need it if
25472b4363aSmrg         you modified a \`.l' file.  You may need the \`Flex' package
25572b4363aSmrg         in order for those modifications to take effect.  You can get
25672b4363aSmrg         \`Flex' from any GNU archive site."
25772b4363aSmrg    rm -f lex.yy.c
25872b4363aSmrg    if test $# -ne 1; then
25972b4363aSmrg        eval LASTARG="\${$#}"
26072b4363aSmrg	case $LASTARG in
26172b4363aSmrg	*.l)
26272b4363aSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
26372b4363aSmrg	    if test -f "$SRCFILE"; then
26472b4363aSmrg	         cp "$SRCFILE" lex.yy.c
26572b4363aSmrg	    fi
26672b4363aSmrg	  ;;
26772b4363aSmrg	esac
26872b4363aSmrg    fi
26972b4363aSmrg    if test ! -f lex.yy.c; then
27072b4363aSmrg	echo 'main() { return 0; }' >lex.yy.c
27172b4363aSmrg    fi
27272b4363aSmrg    ;;
27372b4363aSmrg
274dd77ae96Smrg  help2man*)
27572b4363aSmrg    echo 1>&2 "\
27672b4363aSmrgWARNING: \`$1' is $msg.  You should only need it if
27772b4363aSmrg	 you modified a dependency of a manual page.  You may need the
27872b4363aSmrg	 \`Help2man' package in order for those modifications to take
27972b4363aSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
28072b4363aSmrg
28172b4363aSmrg    file=`echo "$*" | sed -n "$sed_output"`
28272b4363aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
28372b4363aSmrg    if test -f "$file"; then
28472b4363aSmrg	touch $file
28572b4363aSmrg    else
28672b4363aSmrg	test -z "$file" || exec >$file
28772b4363aSmrg	echo ".ab help2man is required to generate this page"
288dd77ae96Smrg	exit $?
28972b4363aSmrg    fi
29072b4363aSmrg    ;;
29172b4363aSmrg
292dd77ae96Smrg  makeinfo*)
29372b4363aSmrg    echo 1>&2 "\
29472b4363aSmrgWARNING: \`$1' is $msg.  You should only need it if
29572b4363aSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29672b4363aSmrg         indirectly affecting the aspect of the manual.  The spurious
29772b4363aSmrg         call might also be the consequence of using a buggy \`make' (AIX,
29872b4363aSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29972b4363aSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
30072b4363aSmrg    # The file to touch is that specified with -o ...
30172b4363aSmrg    file=`echo "$*" | sed -n "$sed_output"`
30272b4363aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30372b4363aSmrg    if test -z "$file"; then
30472b4363aSmrg      # ... or it is the one specified with @setfilename ...
30572b4363aSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
30672b4363aSmrg      file=`sed -n '
30772b4363aSmrg	/^@setfilename/{
30872b4363aSmrg	  s/.* \([^ ]*\) *$/\1/
30972b4363aSmrg	  p
31072b4363aSmrg	  q
31172b4363aSmrg	}' $infile`
31272b4363aSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31372b4363aSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31472b4363aSmrg    fi
31572b4363aSmrg    # If the file does not exist, the user really needs makeinfo;
31672b4363aSmrg    # let's fail without touching anything.
31772b4363aSmrg    test -f $file || exit 1
31872b4363aSmrg    touch $file
31972b4363aSmrg    ;;
32072b4363aSmrg
321dd77ae96Smrg  tar*)
32272b4363aSmrg    shift
32372b4363aSmrg
32472b4363aSmrg    # We have already tried tar in the generic part.
32572b4363aSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
32672b4363aSmrg    # messages.
32772b4363aSmrg    if (gnutar --version > /dev/null 2>&1); then
32872b4363aSmrg       gnutar "$@" && exit 0
32972b4363aSmrg    fi
33072b4363aSmrg    if (gtar --version > /dev/null 2>&1); then
33172b4363aSmrg       gtar "$@" && exit 0
33272b4363aSmrg    fi
33372b4363aSmrg    firstarg="$1"
33472b4363aSmrg    if shift; then
33572b4363aSmrg	case $firstarg in
33672b4363aSmrg	*o*)
33772b4363aSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
33872b4363aSmrg	    tar "$firstarg" "$@" && exit 0
33972b4363aSmrg	    ;;
34072b4363aSmrg	esac
34172b4363aSmrg	case $firstarg in
34272b4363aSmrg	*h*)
34372b4363aSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
34472b4363aSmrg	    tar "$firstarg" "$@" && exit 0
34572b4363aSmrg	    ;;
34672b4363aSmrg	esac
34772b4363aSmrg    fi
34872b4363aSmrg
34972b4363aSmrg    echo 1>&2 "\
35072b4363aSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35172b4363aSmrg         You may want to install GNU tar or Free paxutils, or check the
35272b4363aSmrg         command line arguments."
35372b4363aSmrg    exit 1
35472b4363aSmrg    ;;
35572b4363aSmrg
35672b4363aSmrg  *)
35772b4363aSmrg    echo 1>&2 "\
35872b4363aSmrgWARNING: \`$1' is needed, and is $msg.
35972b4363aSmrg         You might have modified some files without having the
36072b4363aSmrg         proper tools for further handling them.  Check the \`README' file,
36172b4363aSmrg         it often tells you about the needed prerequisites for installing
36272b4363aSmrg         this package.  You may also peek at any GNU archive site, in case
36372b4363aSmrg         some other package would contain this missing \`$1' program."
36472b4363aSmrg    exit 1
36572b4363aSmrg    ;;
36672b4363aSmrgesac
36772b4363aSmrg
36872b4363aSmrgexit 0
36972b4363aSmrg
37072b4363aSmrg# Local variables:
37172b4363aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37272b4363aSmrg# time-stamp-start: "scriptversion="
37372b4363aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374dd77ae96Smrg# time-stamp-time-zone: "UTC"
375dd77ae96Smrg# time-stamp-end: "; # UTC"
37672b4363aSmrg# End:
377