missing revision de78e416
115fb4814Smrg#! /bin/sh
215fb4814Smrg# Common stub for a few missing GNU programs while installing.
315fb4814Smrg
4de78e416Smrgscriptversion=2006-05-10.23
515fb4814Smrg
6de78e416Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
715fb4814Smrg#   Free Software Foundation, Inc.
815fb4814Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
915fb4814Smrg
1015fb4814Smrg# This program is free software; you can redistribute it and/or modify
1115fb4814Smrg# it under the terms of the GNU General Public License as published by
1215fb4814Smrg# the Free Software Foundation; either version 2, or (at your option)
1315fb4814Smrg# any later version.
1415fb4814Smrg
1515fb4814Smrg# This program is distributed in the hope that it will be useful,
1615fb4814Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1715fb4814Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1815fb4814Smrg# GNU General Public License for more details.
1915fb4814Smrg
2015fb4814Smrg# You should have received a copy of the GNU General Public License
2115fb4814Smrg# along with this program; if not, write to the Free Software
2215fb4814Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2315fb4814Smrg# 02110-1301, USA.
2415fb4814Smrg
2515fb4814Smrg# As a special exception to the GNU General Public License, if you
2615fb4814Smrg# distribute this file as part of a program that contains a
2715fb4814Smrg# configuration script generated by Autoconf, you may include it under
2815fb4814Smrg# the same distribution terms that you use for the rest of that program.
2915fb4814Smrg
3015fb4814Smrgif test $# -eq 0; then
3115fb4814Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3215fb4814Smrg  exit 1
3315fb4814Smrgfi
3415fb4814Smrg
3515fb4814Smrgrun=:
36de78e416Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37de78e416Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3815fb4814Smrg
3915fb4814Smrg# In the cases where this matters, `missing' is being run in the
4015fb4814Smrg# srcdir already.
4115fb4814Smrgif test -f configure.ac; then
4215fb4814Smrg  configure_ac=configure.ac
4315fb4814Smrgelse
4415fb4814Smrg  configure_ac=configure.in
4515fb4814Smrgfi
4615fb4814Smrg
4715fb4814Smrgmsg="missing on your system"
4815fb4814Smrg
49de78e416Smrgcase $1 in
5015fb4814Smrg--run)
5115fb4814Smrg  # Try to run requested program, and just exit if it succeeds.
5215fb4814Smrg  run=
5315fb4814Smrg  shift
5415fb4814Smrg  "$@" && exit 0
5515fb4814Smrg  # Exit code 63 means version mismatch.  This often happens
5615fb4814Smrg  # when the user try to use an ancient version of a tool on
5715fb4814Smrg  # a file that requires a minimum version.  In this case we
5815fb4814Smrg  # we should proceed has if the program had been absent, or
5915fb4814Smrg  # if --run hadn't been passed.
6015fb4814Smrg  if test $? = 63; then
6115fb4814Smrg    run=:
6215fb4814Smrg    msg="probably too old"
6315fb4814Smrg  fi
6415fb4814Smrg  ;;
6515fb4814Smrg
6615fb4814Smrg  -h|--h|--he|--hel|--help)
6715fb4814Smrg    echo "\
6815fb4814Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6915fb4814Smrg
7015fb4814SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7115fb4814Smrgerror status if there is no known handling for PROGRAM.
7215fb4814Smrg
7315fb4814SmrgOptions:
7415fb4814Smrg  -h, --help      display this help and exit
7515fb4814Smrg  -v, --version   output version information and exit
7615fb4814Smrg  --run           try to run the given command, and emulate it if it fails
7715fb4814Smrg
7815fb4814SmrgSupported PROGRAM values:
7915fb4814Smrg  aclocal      touch file \`aclocal.m4'
8015fb4814Smrg  autoconf     touch file \`configure'
8115fb4814Smrg  autoheader   touch file \`config.h.in'
82de78e416Smrg  autom4te     touch the output file, or create a stub one
8315fb4814Smrg  automake     touch all \`Makefile.in' files
8415fb4814Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8515fb4814Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8615fb4814Smrg  help2man     touch the output file
8715fb4814Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8815fb4814Smrg  makeinfo     touch the output file
8915fb4814Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9015fb4814Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9115fb4814Smrg
9215fb4814SmrgSend bug reports to <bug-automake@gnu.org>."
9315fb4814Smrg    exit $?
9415fb4814Smrg    ;;
9515fb4814Smrg
9615fb4814Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9715fb4814Smrg    echo "missing $scriptversion (GNU Automake)"
9815fb4814Smrg    exit $?
9915fb4814Smrg    ;;
10015fb4814Smrg
10115fb4814Smrg  -*)
10215fb4814Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10315fb4814Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10415fb4814Smrg    exit 1
10515fb4814Smrg    ;;
10615fb4814Smrg
10715fb4814Smrgesac
10815fb4814Smrg
10915fb4814Smrg# Now exit if we have it, but it failed.  Also exit now if we
11015fb4814Smrg# don't have it and --version was passed (most likely to detect
11115fb4814Smrg# the program).
112de78e416Smrgcase $1 in
11315fb4814Smrg  lex|yacc)
11415fb4814Smrg    # Not GNU programs, they don't have --version.
11515fb4814Smrg    ;;
11615fb4814Smrg
11715fb4814Smrg  tar)
11815fb4814Smrg    if test -n "$run"; then
11915fb4814Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12015fb4814Smrg       exit 1
12115fb4814Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12215fb4814Smrg       exit 1
12315fb4814Smrg    fi
12415fb4814Smrg    ;;
12515fb4814Smrg
12615fb4814Smrg  *)
12715fb4814Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12815fb4814Smrg       # We have it, but it failed.
12915fb4814Smrg       exit 1
13015fb4814Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13115fb4814Smrg       # Could not run --version or --help.  This is probably someone
13215fb4814Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13315fb4814Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13415fb4814Smrg       exit 1
13515fb4814Smrg    fi
13615fb4814Smrg    ;;
13715fb4814Smrgesac
13815fb4814Smrg
13915fb4814Smrg# If it does not exist, or fails to run (possibly an outdated version),
14015fb4814Smrg# try to emulate it.
141de78e416Smrgcase $1 in
14215fb4814Smrg  aclocal*)
14315fb4814Smrg    echo 1>&2 "\
14415fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
14515fb4814Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14615fb4814Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14715fb4814Smrg         any GNU archive site."
14815fb4814Smrg    touch aclocal.m4
14915fb4814Smrg    ;;
15015fb4814Smrg
15115fb4814Smrg  autoconf)
15215fb4814Smrg    echo 1>&2 "\
15315fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
15415fb4814Smrg         you modified \`${configure_ac}'.  You might want to install the
15515fb4814Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15615fb4814Smrg         archive site."
15715fb4814Smrg    touch configure
15815fb4814Smrg    ;;
15915fb4814Smrg
16015fb4814Smrg  autoheader)
16115fb4814Smrg    echo 1>&2 "\
16215fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
16315fb4814Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16415fb4814Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16515fb4814Smrg         from any GNU archive site."
16615fb4814Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16715fb4814Smrg    test -z "$files" && files="config.h"
16815fb4814Smrg    touch_files=
16915fb4814Smrg    for f in $files; do
170de78e416Smrg      case $f in
17115fb4814Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17215fb4814Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17315fb4814Smrg      *) touch_files="$touch_files $f.in";;
17415fb4814Smrg      esac
17515fb4814Smrg    done
17615fb4814Smrg    touch $touch_files
17715fb4814Smrg    ;;
17815fb4814Smrg
17915fb4814Smrg  automake*)
18015fb4814Smrg    echo 1>&2 "\
18115fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
18215fb4814Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18315fb4814Smrg         You might want to install the \`Automake' and \`Perl' packages.
18415fb4814Smrg         Grab them from any GNU archive site."
18515fb4814Smrg    find . -type f -name Makefile.am -print |
18615fb4814Smrg	   sed 's/\.am$/.in/' |
18715fb4814Smrg	   while read f; do touch "$f"; done
18815fb4814Smrg    ;;
18915fb4814Smrg
19015fb4814Smrg  autom4te)
19115fb4814Smrg    echo 1>&2 "\
19215fb4814SmrgWARNING: \`$1' is needed, but is $msg.
19315fb4814Smrg         You might have modified some files without having the
19415fb4814Smrg         proper tools for further handling them.
19515fb4814Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19615fb4814Smrg         archive site."
19715fb4814Smrg
198de78e416Smrg    file=`echo "$*" | sed -n "$sed_output"`
199de78e416Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20015fb4814Smrg    if test -f "$file"; then
20115fb4814Smrg	touch $file
20215fb4814Smrg    else
20315fb4814Smrg	test -z "$file" || exec >$file
20415fb4814Smrg	echo "#! /bin/sh"
20515fb4814Smrg	echo "# Created by GNU Automake missing as a replacement of"
20615fb4814Smrg	echo "#  $ $@"
20715fb4814Smrg	echo "exit 0"
20815fb4814Smrg	chmod +x $file
20915fb4814Smrg	exit 1
21015fb4814Smrg    fi
21115fb4814Smrg    ;;
21215fb4814Smrg
21315fb4814Smrg  bison|yacc)
21415fb4814Smrg    echo 1>&2 "\
21515fb4814SmrgWARNING: \`$1' $msg.  You should only need it if
21615fb4814Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21715fb4814Smrg         in order for those modifications to take effect.  You can get
21815fb4814Smrg         \`Bison' from any GNU archive site."
21915fb4814Smrg    rm -f y.tab.c y.tab.h
220de78e416Smrg    if test $# -ne 1; then
22115fb4814Smrg        eval LASTARG="\${$#}"
222de78e416Smrg	case $LASTARG in
22315fb4814Smrg	*.y)
22415fb4814Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225de78e416Smrg	    if test -f "$SRCFILE"; then
22615fb4814Smrg	         cp "$SRCFILE" y.tab.c
22715fb4814Smrg	    fi
22815fb4814Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229de78e416Smrg	    if test -f "$SRCFILE"; then
23015fb4814Smrg	         cp "$SRCFILE" y.tab.h
23115fb4814Smrg	    fi
23215fb4814Smrg	  ;;
23315fb4814Smrg	esac
23415fb4814Smrg    fi
235de78e416Smrg    if test ! -f y.tab.h; then
23615fb4814Smrg	echo >y.tab.h
23715fb4814Smrg    fi
238de78e416Smrg    if test ! -f y.tab.c; then
23915fb4814Smrg	echo 'main() { return 0; }' >y.tab.c
24015fb4814Smrg    fi
24115fb4814Smrg    ;;
24215fb4814Smrg
24315fb4814Smrg  lex|flex)
24415fb4814Smrg    echo 1>&2 "\
24515fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
24615fb4814Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24715fb4814Smrg         in order for those modifications to take effect.  You can get
24815fb4814Smrg         \`Flex' from any GNU archive site."
24915fb4814Smrg    rm -f lex.yy.c
250de78e416Smrg    if test $# -ne 1; then
25115fb4814Smrg        eval LASTARG="\${$#}"
252de78e416Smrg	case $LASTARG in
25315fb4814Smrg	*.l)
25415fb4814Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255de78e416Smrg	    if test -f "$SRCFILE"; then
25615fb4814Smrg	         cp "$SRCFILE" lex.yy.c
25715fb4814Smrg	    fi
25815fb4814Smrg	  ;;
25915fb4814Smrg	esac
26015fb4814Smrg    fi
261de78e416Smrg    if test ! -f lex.yy.c; then
26215fb4814Smrg	echo 'main() { return 0; }' >lex.yy.c
26315fb4814Smrg    fi
26415fb4814Smrg    ;;
26515fb4814Smrg
26615fb4814Smrg  help2man)
26715fb4814Smrg    echo 1>&2 "\
26815fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
26915fb4814Smrg	 you modified a dependency of a manual page.  You may need the
27015fb4814Smrg	 \`Help2man' package in order for those modifications to take
27115fb4814Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27215fb4814Smrg
273de78e416Smrg    file=`echo "$*" | sed -n "$sed_output"`
274de78e416Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275de78e416Smrg    if test -f "$file"; then
27615fb4814Smrg	touch $file
27715fb4814Smrg    else
27815fb4814Smrg	test -z "$file" || exec >$file
27915fb4814Smrg	echo ".ab help2man is required to generate this page"
28015fb4814Smrg	exit 1
28115fb4814Smrg    fi
28215fb4814Smrg    ;;
28315fb4814Smrg
28415fb4814Smrg  makeinfo)
28515fb4814Smrg    echo 1>&2 "\
28615fb4814SmrgWARNING: \`$1' is $msg.  You should only need it if
28715fb4814Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28815fb4814Smrg         indirectly affecting the aspect of the manual.  The spurious
28915fb4814Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29015fb4814Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29115fb4814Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29215fb4814Smrg    # The file to touch is that specified with -o ...
293de78e416Smrg    file=`echo "$*" | sed -n "$sed_output"`
294de78e416Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29515fb4814Smrg    if test -z "$file"; then
29615fb4814Smrg      # ... or it is the one specified with @setfilename ...
29715fb4814Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298de78e416Smrg      file=`sed -n '
299de78e416Smrg	/^@setfilename/{
300de78e416Smrg	  s/.* \([^ ]*\) *$/\1/
301de78e416Smrg	  p
302de78e416Smrg	  q
303de78e416Smrg	}' $infile`
30415fb4814Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30515fb4814Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30615fb4814Smrg    fi
30715fb4814Smrg    # If the file does not exist, the user really needs makeinfo;
30815fb4814Smrg    # let's fail without touching anything.
30915fb4814Smrg    test -f $file || exit 1
31015fb4814Smrg    touch $file
31115fb4814Smrg    ;;
31215fb4814Smrg
31315fb4814Smrg  tar)
31415fb4814Smrg    shift
31515fb4814Smrg
31615fb4814Smrg    # We have already tried tar in the generic part.
31715fb4814Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31815fb4814Smrg    # messages.
31915fb4814Smrg    if (gnutar --version > /dev/null 2>&1); then
32015fb4814Smrg       gnutar "$@" && exit 0
32115fb4814Smrg    fi
32215fb4814Smrg    if (gtar --version > /dev/null 2>&1); then
32315fb4814Smrg       gtar "$@" && exit 0
32415fb4814Smrg    fi
32515fb4814Smrg    firstarg="$1"
32615fb4814Smrg    if shift; then
327de78e416Smrg	case $firstarg in
32815fb4814Smrg	*o*)
32915fb4814Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33015fb4814Smrg	    tar "$firstarg" "$@" && exit 0
33115fb4814Smrg	    ;;
33215fb4814Smrg	esac
333de78e416Smrg	case $firstarg in
33415fb4814Smrg	*h*)
33515fb4814Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33615fb4814Smrg	    tar "$firstarg" "$@" && exit 0
33715fb4814Smrg	    ;;
33815fb4814Smrg	esac
33915fb4814Smrg    fi
34015fb4814Smrg
34115fb4814Smrg    echo 1>&2 "\
34215fb4814SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34315fb4814Smrg         You may want to install GNU tar or Free paxutils, or check the
34415fb4814Smrg         command line arguments."
34515fb4814Smrg    exit 1
34615fb4814Smrg    ;;
34715fb4814Smrg
34815fb4814Smrg  *)
34915fb4814Smrg    echo 1>&2 "\
35015fb4814SmrgWARNING: \`$1' is needed, and is $msg.
35115fb4814Smrg         You might have modified some files without having the
35215fb4814Smrg         proper tools for further handling them.  Check the \`README' file,
35315fb4814Smrg         it often tells you about the needed prerequisites for installing
35415fb4814Smrg         this package.  You may also peek at any GNU archive site, in case
35515fb4814Smrg         some other package would contain this missing \`$1' program."
35615fb4814Smrg    exit 1
35715fb4814Smrg    ;;
35815fb4814Smrgesac
35915fb4814Smrg
36015fb4814Smrgexit 0
36115fb4814Smrg
36215fb4814Smrg# Local variables:
36315fb4814Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36415fb4814Smrg# time-stamp-start: "scriptversion="
36515fb4814Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36615fb4814Smrg# time-stamp-end: "$"
36715fb4814Smrg# End:
368