missing revision fbed5abf
117a48c7cSmrg#! /bin/sh
217a48c7cSmrg# Common stub for a few missing GNU programs while installing.
317a48c7cSmrg
4fbed5abfSmrgscriptversion=2009-04-28.21; # UTC
517a48c7cSmrg
6fbed5abfSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7fbed5abfSmrg# 2008, 2009 Free Software Foundation, Inc.
817a48c7cSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
917a48c7cSmrg
1017a48c7cSmrg# This program is free software; you can redistribute it and/or modify
1117a48c7cSmrg# it under the terms of the GNU General Public License as published by
1217a48c7cSmrg# the Free Software Foundation; either version 2, or (at your option)
1317a48c7cSmrg# any later version.
1417a48c7cSmrg
1517a48c7cSmrg# This program is distributed in the hope that it will be useful,
1617a48c7cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1717a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1817a48c7cSmrg# GNU General Public License for more details.
1917a48c7cSmrg
2017a48c7cSmrg# You should have received a copy of the GNU General Public License
21fbed5abfSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2217a48c7cSmrg
2317a48c7cSmrg# As a special exception to the GNU General Public License, if you
2417a48c7cSmrg# distribute this file as part of a program that contains a
2517a48c7cSmrg# configuration script generated by Autoconf, you may include it under
2617a48c7cSmrg# the same distribution terms that you use for the rest of that program.
2717a48c7cSmrg
2817a48c7cSmrgif test $# -eq 0; then
2917a48c7cSmrg  echo 1>&2 "Try \`$0 --help' for more information"
3017a48c7cSmrg  exit 1
3117a48c7cSmrgfi
3217a48c7cSmrg
3317a48c7cSmrgrun=:
348e0ed500Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
358e0ed500Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3617a48c7cSmrg
3717a48c7cSmrg# In the cases where this matters, `missing' is being run in the
3817a48c7cSmrg# srcdir already.
3917a48c7cSmrgif test -f configure.ac; then
4017a48c7cSmrg  configure_ac=configure.ac
4117a48c7cSmrgelse
4217a48c7cSmrg  configure_ac=configure.in
4317a48c7cSmrgfi
4417a48c7cSmrg
4517a48c7cSmrgmsg="missing on your system"
4617a48c7cSmrg
478e0ed500Smrgcase $1 in
4817a48c7cSmrg--run)
4917a48c7cSmrg  # Try to run requested program, and just exit if it succeeds.
5017a48c7cSmrg  run=
5117a48c7cSmrg  shift
5217a48c7cSmrg  "$@" && exit 0
5317a48c7cSmrg  # Exit code 63 means version mismatch.  This often happens
5417a48c7cSmrg  # when the user try to use an ancient version of a tool on
5517a48c7cSmrg  # a file that requires a minimum version.  In this case we
5617a48c7cSmrg  # we should proceed has if the program had been absent, or
5717a48c7cSmrg  # if --run hadn't been passed.
5817a48c7cSmrg  if test $? = 63; then
5917a48c7cSmrg    run=:
6017a48c7cSmrg    msg="probably too old"
6117a48c7cSmrg  fi
6217a48c7cSmrg  ;;
6317a48c7cSmrg
6417a48c7cSmrg  -h|--h|--he|--hel|--help)
6517a48c7cSmrg    echo "\
6617a48c7cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6717a48c7cSmrg
6817a48c7cSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6917a48c7cSmrgerror status if there is no known handling for PROGRAM.
7017a48c7cSmrg
7117a48c7cSmrgOptions:
7217a48c7cSmrg  -h, --help      display this help and exit
7317a48c7cSmrg  -v, --version   output version information and exit
7417a48c7cSmrg  --run           try to run the given command, and emulate it if it fails
7517a48c7cSmrg
7617a48c7cSmrgSupported PROGRAM values:
7717a48c7cSmrg  aclocal      touch file \`aclocal.m4'
7817a48c7cSmrg  autoconf     touch file \`configure'
7917a48c7cSmrg  autoheader   touch file \`config.h.in'
808e0ed500Smrg  autom4te     touch the output file, or create a stub one
8117a48c7cSmrg  automake     touch all \`Makefile.in' files
8217a48c7cSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8317a48c7cSmrg  flex         create \`lex.yy.c', if possible, from existing .c
8417a48c7cSmrg  help2man     touch the output file
8517a48c7cSmrg  lex          create \`lex.yy.c', if possible, from existing .c
8617a48c7cSmrg  makeinfo     touch the output file
8717a48c7cSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8817a48c7cSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8917a48c7cSmrg
90fbed5abfSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91fbed5abfSmrg\`g' are ignored when checking the name.
92fbed5abfSmrg
9317a48c7cSmrgSend bug reports to <bug-automake@gnu.org>."
9417a48c7cSmrg    exit $?
9517a48c7cSmrg    ;;
9617a48c7cSmrg
9717a48c7cSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9817a48c7cSmrg    echo "missing $scriptversion (GNU Automake)"
9917a48c7cSmrg    exit $?
10017a48c7cSmrg    ;;
10117a48c7cSmrg
10217a48c7cSmrg  -*)
10317a48c7cSmrg    echo 1>&2 "$0: Unknown \`$1' option"
10417a48c7cSmrg    echo 1>&2 "Try \`$0 --help' for more information"
10517a48c7cSmrg    exit 1
10617a48c7cSmrg    ;;
10717a48c7cSmrg
10817a48c7cSmrgesac
10917a48c7cSmrg
110fbed5abfSmrg# normalize program name to check for.
111fbed5abfSmrgprogram=`echo "$1" | sed '
112fbed5abfSmrg  s/^gnu-//; t
113fbed5abfSmrg  s/^gnu//; t
114fbed5abfSmrg  s/^g//; t'`
115fbed5abfSmrg
11617a48c7cSmrg# Now exit if we have it, but it failed.  Also exit now if we
11717a48c7cSmrg# don't have it and --version was passed (most likely to detect
118fbed5abfSmrg# the program).  This is about non-GNU programs, so use $1 not
119fbed5abfSmrg# $program.
1208e0ed500Smrgcase $1 in
121fbed5abfSmrg  lex*|yacc*)
12217a48c7cSmrg    # Not GNU programs, they don't have --version.
12317a48c7cSmrg    ;;
12417a48c7cSmrg
125fbed5abfSmrg  tar*)
12617a48c7cSmrg    if test -n "$run"; then
12717a48c7cSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
12817a48c7cSmrg       exit 1
12917a48c7cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13017a48c7cSmrg       exit 1
13117a48c7cSmrg    fi
13217a48c7cSmrg    ;;
13317a48c7cSmrg
13417a48c7cSmrg  *)
13517a48c7cSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
13617a48c7cSmrg       # We have it, but it failed.
13717a48c7cSmrg       exit 1
13817a48c7cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13917a48c7cSmrg       # Could not run --version or --help.  This is probably someone
14017a48c7cSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14117a48c7cSmrg       # $TOOL exists and not knowing $TOOL uses missing.
14217a48c7cSmrg       exit 1
14317a48c7cSmrg    fi
14417a48c7cSmrg    ;;
14517a48c7cSmrgesac
14617a48c7cSmrg
14717a48c7cSmrg# If it does not exist, or fails to run (possibly an outdated version),
14817a48c7cSmrg# try to emulate it.
149fbed5abfSmrgcase $program in
15017a48c7cSmrg  aclocal*)
15117a48c7cSmrg    echo 1>&2 "\
15217a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
15317a48c7cSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
15417a48c7cSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
15517a48c7cSmrg         any GNU archive site."
15617a48c7cSmrg    touch aclocal.m4
15717a48c7cSmrg    ;;
15817a48c7cSmrg
159fbed5abfSmrg  autoconf*)
16017a48c7cSmrg    echo 1>&2 "\
16117a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
16217a48c7cSmrg         you modified \`${configure_ac}'.  You might want to install the
16317a48c7cSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
16417a48c7cSmrg         archive site."
16517a48c7cSmrg    touch configure
16617a48c7cSmrg    ;;
16717a48c7cSmrg
168fbed5abfSmrg  autoheader*)
16917a48c7cSmrg    echo 1>&2 "\
17017a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
17117a48c7cSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
17217a48c7cSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
17317a48c7cSmrg         from any GNU archive site."
17417a48c7cSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
17517a48c7cSmrg    test -z "$files" && files="config.h"
17617a48c7cSmrg    touch_files=
17717a48c7cSmrg    for f in $files; do
1788e0ed500Smrg      case $f in
17917a48c7cSmrg      *:*) touch_files="$touch_files "`echo "$f" |
18017a48c7cSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
18117a48c7cSmrg      *) touch_files="$touch_files $f.in";;
18217a48c7cSmrg      esac
18317a48c7cSmrg    done
18417a48c7cSmrg    touch $touch_files
18517a48c7cSmrg    ;;
18617a48c7cSmrg
18717a48c7cSmrg  automake*)
18817a48c7cSmrg    echo 1>&2 "\
18917a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
19017a48c7cSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
19117a48c7cSmrg         You might want to install the \`Automake' and \`Perl' packages.
19217a48c7cSmrg         Grab them from any GNU archive site."
19317a48c7cSmrg    find . -type f -name Makefile.am -print |
19417a48c7cSmrg	   sed 's/\.am$/.in/' |
19517a48c7cSmrg	   while read f; do touch "$f"; done
19617a48c7cSmrg    ;;
19717a48c7cSmrg
198fbed5abfSmrg  autom4te*)
19917a48c7cSmrg    echo 1>&2 "\
20017a48c7cSmrgWARNING: \`$1' is needed, but is $msg.
20117a48c7cSmrg         You might have modified some files without having the
20217a48c7cSmrg         proper tools for further handling them.
20317a48c7cSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
20417a48c7cSmrg         archive site."
20517a48c7cSmrg
2068e0ed500Smrg    file=`echo "$*" | sed -n "$sed_output"`
2078e0ed500Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20817a48c7cSmrg    if test -f "$file"; then
20917a48c7cSmrg	touch $file
21017a48c7cSmrg    else
21117a48c7cSmrg	test -z "$file" || exec >$file
21217a48c7cSmrg	echo "#! /bin/sh"
21317a48c7cSmrg	echo "# Created by GNU Automake missing as a replacement of"
21417a48c7cSmrg	echo "#  $ $@"
21517a48c7cSmrg	echo "exit 0"
21617a48c7cSmrg	chmod +x $file
21717a48c7cSmrg	exit 1
21817a48c7cSmrg    fi
21917a48c7cSmrg    ;;
22017a48c7cSmrg
221fbed5abfSmrg  bison*|yacc*)
22217a48c7cSmrg    echo 1>&2 "\
22317a48c7cSmrgWARNING: \`$1' $msg.  You should only need it if
22417a48c7cSmrg         you modified a \`.y' file.  You may need the \`Bison' package
22517a48c7cSmrg         in order for those modifications to take effect.  You can get
22617a48c7cSmrg         \`Bison' from any GNU archive site."
22717a48c7cSmrg    rm -f y.tab.c y.tab.h
2288e0ed500Smrg    if test $# -ne 1; then
22917a48c7cSmrg        eval LASTARG="\${$#}"
2308e0ed500Smrg	case $LASTARG in
23117a48c7cSmrg	*.y)
23217a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2338e0ed500Smrg	    if test -f "$SRCFILE"; then
23417a48c7cSmrg	         cp "$SRCFILE" y.tab.c
23517a48c7cSmrg	    fi
23617a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2378e0ed500Smrg	    if test -f "$SRCFILE"; then
23817a48c7cSmrg	         cp "$SRCFILE" y.tab.h
23917a48c7cSmrg	    fi
24017a48c7cSmrg	  ;;
24117a48c7cSmrg	esac
24217a48c7cSmrg    fi
2438e0ed500Smrg    if test ! -f y.tab.h; then
24417a48c7cSmrg	echo >y.tab.h
24517a48c7cSmrg    fi
2468e0ed500Smrg    if test ! -f y.tab.c; then
24717a48c7cSmrg	echo 'main() { return 0; }' >y.tab.c
24817a48c7cSmrg    fi
24917a48c7cSmrg    ;;
25017a48c7cSmrg
251fbed5abfSmrg  lex*|flex*)
25217a48c7cSmrg    echo 1>&2 "\
25317a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
25417a48c7cSmrg         you modified a \`.l' file.  You may need the \`Flex' package
25517a48c7cSmrg         in order for those modifications to take effect.  You can get
25617a48c7cSmrg         \`Flex' from any GNU archive site."
25717a48c7cSmrg    rm -f lex.yy.c
2588e0ed500Smrg    if test $# -ne 1; then
25917a48c7cSmrg        eval LASTARG="\${$#}"
2608e0ed500Smrg	case $LASTARG in
26117a48c7cSmrg	*.l)
26217a48c7cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2638e0ed500Smrg	    if test -f "$SRCFILE"; then
26417a48c7cSmrg	         cp "$SRCFILE" lex.yy.c
26517a48c7cSmrg	    fi
26617a48c7cSmrg	  ;;
26717a48c7cSmrg	esac
26817a48c7cSmrg    fi
2698e0ed500Smrg    if test ! -f lex.yy.c; then
27017a48c7cSmrg	echo 'main() { return 0; }' >lex.yy.c
27117a48c7cSmrg    fi
27217a48c7cSmrg    ;;
27317a48c7cSmrg
274fbed5abfSmrg  help2man*)
27517a48c7cSmrg    echo 1>&2 "\
27617a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
27717a48c7cSmrg	 you modified a dependency of a manual page.  You may need the
27817a48c7cSmrg	 \`Help2man' package in order for those modifications to take
27917a48c7cSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
28017a48c7cSmrg
2818e0ed500Smrg    file=`echo "$*" | sed -n "$sed_output"`
2828e0ed500Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2838e0ed500Smrg    if test -f "$file"; then
28417a48c7cSmrg	touch $file
28517a48c7cSmrg    else
28617a48c7cSmrg	test -z "$file" || exec >$file
28717a48c7cSmrg	echo ".ab help2man is required to generate this page"
288fbed5abfSmrg	exit $?
28917a48c7cSmrg    fi
29017a48c7cSmrg    ;;
29117a48c7cSmrg
292fbed5abfSmrg  makeinfo*)
29317a48c7cSmrg    echo 1>&2 "\
29417a48c7cSmrgWARNING: \`$1' is $msg.  You should only need it if
29517a48c7cSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
29617a48c7cSmrg         indirectly affecting the aspect of the manual.  The spurious
29717a48c7cSmrg         call might also be the consequence of using a buggy \`make' (AIX,
29817a48c7cSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29917a48c7cSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
30017a48c7cSmrg    # The file to touch is that specified with -o ...
3018e0ed500Smrg    file=`echo "$*" | sed -n "$sed_output"`
3028e0ed500Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
30317a48c7cSmrg    if test -z "$file"; then
30417a48c7cSmrg      # ... or it is the one specified with @setfilename ...
30517a48c7cSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3068e0ed500Smrg      file=`sed -n '
3078e0ed500Smrg	/^@setfilename/{
3088e0ed500Smrg	  s/.* \([^ ]*\) *$/\1/
3098e0ed500Smrg	  p
3108e0ed500Smrg	  q
3118e0ed500Smrg	}' $infile`
31217a48c7cSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31317a48c7cSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
31417a48c7cSmrg    fi
31517a48c7cSmrg    # If the file does not exist, the user really needs makeinfo;
31617a48c7cSmrg    # let's fail without touching anything.
31717a48c7cSmrg    test -f $file || exit 1
31817a48c7cSmrg    touch $file
31917a48c7cSmrg    ;;
32017a48c7cSmrg
321fbed5abfSmrg  tar*)
32217a48c7cSmrg    shift
32317a48c7cSmrg
32417a48c7cSmrg    # We have already tried tar in the generic part.
32517a48c7cSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
32617a48c7cSmrg    # messages.
32717a48c7cSmrg    if (gnutar --version > /dev/null 2>&1); then
32817a48c7cSmrg       gnutar "$@" && exit 0
32917a48c7cSmrg    fi
33017a48c7cSmrg    if (gtar --version > /dev/null 2>&1); then
33117a48c7cSmrg       gtar "$@" && exit 0
33217a48c7cSmrg    fi
33317a48c7cSmrg    firstarg="$1"
33417a48c7cSmrg    if shift; then
3358e0ed500Smrg	case $firstarg in
33617a48c7cSmrg	*o*)
33717a48c7cSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
33817a48c7cSmrg	    tar "$firstarg" "$@" && exit 0
33917a48c7cSmrg	    ;;
34017a48c7cSmrg	esac
3418e0ed500Smrg	case $firstarg in
34217a48c7cSmrg	*h*)
34317a48c7cSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
34417a48c7cSmrg	    tar "$firstarg" "$@" && exit 0
34517a48c7cSmrg	    ;;
34617a48c7cSmrg	esac
34717a48c7cSmrg    fi
34817a48c7cSmrg
34917a48c7cSmrg    echo 1>&2 "\
35017a48c7cSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
35117a48c7cSmrg         You may want to install GNU tar or Free paxutils, or check the
35217a48c7cSmrg         command line arguments."
35317a48c7cSmrg    exit 1
35417a48c7cSmrg    ;;
35517a48c7cSmrg
35617a48c7cSmrg  *)
35717a48c7cSmrg    echo 1>&2 "\
35817a48c7cSmrgWARNING: \`$1' is needed, and is $msg.
35917a48c7cSmrg         You might have modified some files without having the
36017a48c7cSmrg         proper tools for further handling them.  Check the \`README' file,
36117a48c7cSmrg         it often tells you about the needed prerequisites for installing
36217a48c7cSmrg         this package.  You may also peek at any GNU archive site, in case
36317a48c7cSmrg         some other package would contain this missing \`$1' program."
36417a48c7cSmrg    exit 1
36517a48c7cSmrg    ;;
36617a48c7cSmrgesac
36717a48c7cSmrg
36817a48c7cSmrgexit 0
36917a48c7cSmrg
37017a48c7cSmrg# Local variables:
37117a48c7cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37217a48c7cSmrg# time-stamp-start: "scriptversion="
37317a48c7cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374fbed5abfSmrg# time-stamp-time-zone: "UTC"
375fbed5abfSmrg# time-stamp-end: "; # UTC"
37617a48c7cSmrg# End:
377