missing revision 64ce7165
164ce7165Smrg#! /bin/sh
264ce7165Smrg# Common stub for a few missing GNU programs while installing.
364ce7165Smrg
464ce7165Smrgscriptversion=2006-05-10.23
564ce7165Smrg
664ce7165Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
764ce7165Smrg#   Free Software Foundation, Inc.
864ce7165Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
964ce7165Smrg
1064ce7165Smrg# This program is free software; you can redistribute it and/or modify
1164ce7165Smrg# it under the terms of the GNU General Public License as published by
1264ce7165Smrg# the Free Software Foundation; either version 2, or (at your option)
1364ce7165Smrg# any later version.
1464ce7165Smrg
1564ce7165Smrg# This program is distributed in the hope that it will be useful,
1664ce7165Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1764ce7165Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1864ce7165Smrg# GNU General Public License for more details.
1964ce7165Smrg
2064ce7165Smrg# You should have received a copy of the GNU General Public License
2164ce7165Smrg# along with this program; if not, write to the Free Software
2264ce7165Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2364ce7165Smrg# 02110-1301, USA.
2464ce7165Smrg
2564ce7165Smrg# As a special exception to the GNU General Public License, if you
2664ce7165Smrg# distribute this file as part of a program that contains a
2764ce7165Smrg# configuration script generated by Autoconf, you may include it under
2864ce7165Smrg# the same distribution terms that you use for the rest of that program.
2964ce7165Smrg
3064ce7165Smrgif test $# -eq 0; then
3164ce7165Smrg  echo 1>&2 "Try \`$0 --help' for more information"
3264ce7165Smrg  exit 1
3364ce7165Smrgfi
3464ce7165Smrg
3564ce7165Smrgrun=:
3664ce7165Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3764ce7165Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
3864ce7165Smrg
3964ce7165Smrg# In the cases where this matters, `missing' is being run in the
4064ce7165Smrg# srcdir already.
4164ce7165Smrgif test -f configure.ac; then
4264ce7165Smrg  configure_ac=configure.ac
4364ce7165Smrgelse
4464ce7165Smrg  configure_ac=configure.in
4564ce7165Smrgfi
4664ce7165Smrg
4764ce7165Smrgmsg="missing on your system"
4864ce7165Smrg
4964ce7165Smrgcase $1 in
5064ce7165Smrg--run)
5164ce7165Smrg  # Try to run requested program, and just exit if it succeeds.
5264ce7165Smrg  run=
5364ce7165Smrg  shift
5464ce7165Smrg  "$@" && exit 0
5564ce7165Smrg  # Exit code 63 means version mismatch.  This often happens
5664ce7165Smrg  # when the user try to use an ancient version of a tool on
5764ce7165Smrg  # a file that requires a minimum version.  In this case we
5864ce7165Smrg  # we should proceed has if the program had been absent, or
5964ce7165Smrg  # if --run hadn't been passed.
6064ce7165Smrg  if test $? = 63; then
6164ce7165Smrg    run=:
6264ce7165Smrg    msg="probably too old"
6364ce7165Smrg  fi
6464ce7165Smrg  ;;
6564ce7165Smrg
6664ce7165Smrg  -h|--h|--he|--hel|--help)
6764ce7165Smrg    echo "\
6864ce7165Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
6964ce7165Smrg
7064ce7165SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
7164ce7165Smrgerror status if there is no known handling for PROGRAM.
7264ce7165Smrg
7364ce7165SmrgOptions:
7464ce7165Smrg  -h, --help      display this help and exit
7564ce7165Smrg  -v, --version   output version information and exit
7664ce7165Smrg  --run           try to run the given command, and emulate it if it fails
7764ce7165Smrg
7864ce7165SmrgSupported PROGRAM values:
7964ce7165Smrg  aclocal      touch file \`aclocal.m4'
8064ce7165Smrg  autoconf     touch file \`configure'
8164ce7165Smrg  autoheader   touch file \`config.h.in'
8264ce7165Smrg  autom4te     touch the output file, or create a stub one
8364ce7165Smrg  automake     touch all \`Makefile.in' files
8464ce7165Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8564ce7165Smrg  flex         create \`lex.yy.c', if possible, from existing .c
8664ce7165Smrg  help2man     touch the output file
8764ce7165Smrg  lex          create \`lex.yy.c', if possible, from existing .c
8864ce7165Smrg  makeinfo     touch the output file
8964ce7165Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
9064ce7165Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
9164ce7165Smrg
9264ce7165SmrgSend bug reports to <bug-automake@gnu.org>."
9364ce7165Smrg    exit $?
9464ce7165Smrg    ;;
9564ce7165Smrg
9664ce7165Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9764ce7165Smrg    echo "missing $scriptversion (GNU Automake)"
9864ce7165Smrg    exit $?
9964ce7165Smrg    ;;
10064ce7165Smrg
10164ce7165Smrg  -*)
10264ce7165Smrg    echo 1>&2 "$0: Unknown \`$1' option"
10364ce7165Smrg    echo 1>&2 "Try \`$0 --help' for more information"
10464ce7165Smrg    exit 1
10564ce7165Smrg    ;;
10664ce7165Smrg
10764ce7165Smrgesac
10864ce7165Smrg
10964ce7165Smrg# Now exit if we have it, but it failed.  Also exit now if we
11064ce7165Smrg# don't have it and --version was passed (most likely to detect
11164ce7165Smrg# the program).
11264ce7165Smrgcase $1 in
11364ce7165Smrg  lex|yacc)
11464ce7165Smrg    # Not GNU programs, they don't have --version.
11564ce7165Smrg    ;;
11664ce7165Smrg
11764ce7165Smrg  tar)
11864ce7165Smrg    if test -n "$run"; then
11964ce7165Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
12064ce7165Smrg       exit 1
12164ce7165Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
12264ce7165Smrg       exit 1
12364ce7165Smrg    fi
12464ce7165Smrg    ;;
12564ce7165Smrg
12664ce7165Smrg  *)
12764ce7165Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12864ce7165Smrg       # We have it, but it failed.
12964ce7165Smrg       exit 1
13064ce7165Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13164ce7165Smrg       # Could not run --version or --help.  This is probably someone
13264ce7165Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
13364ce7165Smrg       # $TOOL exists and not knowing $TOOL uses missing.
13464ce7165Smrg       exit 1
13564ce7165Smrg    fi
13664ce7165Smrg    ;;
13764ce7165Smrgesac
13864ce7165Smrg
13964ce7165Smrg# If it does not exist, or fails to run (possibly an outdated version),
14064ce7165Smrg# try to emulate it.
14164ce7165Smrgcase $1 in
14264ce7165Smrg  aclocal*)
14364ce7165Smrg    echo 1>&2 "\
14464ce7165SmrgWARNING: \`$1' is $msg.  You should only need it if
14564ce7165Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14664ce7165Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
14764ce7165Smrg         any GNU archive site."
14864ce7165Smrg    touch aclocal.m4
14964ce7165Smrg    ;;
15064ce7165Smrg
15164ce7165Smrg  autoconf)
15264ce7165Smrg    echo 1>&2 "\
15364ce7165SmrgWARNING: \`$1' is $msg.  You should only need it if
15464ce7165Smrg         you modified \`${configure_ac}'.  You might want to install the
15564ce7165Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15664ce7165Smrg         archive site."
15764ce7165Smrg    touch configure
15864ce7165Smrg    ;;
15964ce7165Smrg
16064ce7165Smrg  autoheader)
16164ce7165Smrg    echo 1>&2 "\
16264ce7165SmrgWARNING: \`$1' is $msg.  You should only need it if
16364ce7165Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16464ce7165Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16564ce7165Smrg         from any GNU archive site."
16664ce7165Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16764ce7165Smrg    test -z "$files" && files="config.h"
16864ce7165Smrg    touch_files=
16964ce7165Smrg    for f in $files; do
17064ce7165Smrg      case $f in
17164ce7165Smrg      *:*) touch_files="$touch_files "`echo "$f" |
17264ce7165Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17364ce7165Smrg      *) touch_files="$touch_files $f.in";;
17464ce7165Smrg      esac
17564ce7165Smrg    done
17664ce7165Smrg    touch $touch_files
17764ce7165Smrg    ;;
17864ce7165Smrg
17964ce7165Smrg  automake*)
18064ce7165Smrg    echo 1>&2 "\
18164ce7165SmrgWARNING: \`$1' is $msg.  You should only need it if
18264ce7165Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18364ce7165Smrg         You might want to install the \`Automake' and \`Perl' packages.
18464ce7165Smrg         Grab them from any GNU archive site."
18564ce7165Smrg    find . -type f -name Makefile.am -print |
18664ce7165Smrg	   sed 's/\.am$/.in/' |
18764ce7165Smrg	   while read f; do touch "$f"; done
18864ce7165Smrg    ;;
18964ce7165Smrg
19064ce7165Smrg  autom4te)
19164ce7165Smrg    echo 1>&2 "\
19264ce7165SmrgWARNING: \`$1' is needed, but is $msg.
19364ce7165Smrg         You might have modified some files without having the
19464ce7165Smrg         proper tools for further handling them.
19564ce7165Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
19664ce7165Smrg         archive site."
19764ce7165Smrg
19864ce7165Smrg    file=`echo "$*" | sed -n "$sed_output"`
19964ce7165Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
20064ce7165Smrg    if test -f "$file"; then
20164ce7165Smrg	touch $file
20264ce7165Smrg    else
20364ce7165Smrg	test -z "$file" || exec >$file
20464ce7165Smrg	echo "#! /bin/sh"
20564ce7165Smrg	echo "# Created by GNU Automake missing as a replacement of"
20664ce7165Smrg	echo "#  $ $@"
20764ce7165Smrg	echo "exit 0"
20864ce7165Smrg	chmod +x $file
20964ce7165Smrg	exit 1
21064ce7165Smrg    fi
21164ce7165Smrg    ;;
21264ce7165Smrg
21364ce7165Smrg  bison|yacc)
21464ce7165Smrg    echo 1>&2 "\
21564ce7165SmrgWARNING: \`$1' $msg.  You should only need it if
21664ce7165Smrg         you modified a \`.y' file.  You may need the \`Bison' package
21764ce7165Smrg         in order for those modifications to take effect.  You can get
21864ce7165Smrg         \`Bison' from any GNU archive site."
21964ce7165Smrg    rm -f y.tab.c y.tab.h
22064ce7165Smrg    if test $# -ne 1; then
22164ce7165Smrg        eval LASTARG="\${$#}"
22264ce7165Smrg	case $LASTARG in
22364ce7165Smrg	*.y)
22464ce7165Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22564ce7165Smrg	    if test -f "$SRCFILE"; then
22664ce7165Smrg	         cp "$SRCFILE" y.tab.c
22764ce7165Smrg	    fi
22864ce7165Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22964ce7165Smrg	    if test -f "$SRCFILE"; then
23064ce7165Smrg	         cp "$SRCFILE" y.tab.h
23164ce7165Smrg	    fi
23264ce7165Smrg	  ;;
23364ce7165Smrg	esac
23464ce7165Smrg    fi
23564ce7165Smrg    if test ! -f y.tab.h; then
23664ce7165Smrg	echo >y.tab.h
23764ce7165Smrg    fi
23864ce7165Smrg    if test ! -f y.tab.c; then
23964ce7165Smrg	echo 'main() { return 0; }' >y.tab.c
24064ce7165Smrg    fi
24164ce7165Smrg    ;;
24264ce7165Smrg
24364ce7165Smrg  lex|flex)
24464ce7165Smrg    echo 1>&2 "\
24564ce7165SmrgWARNING: \`$1' is $msg.  You should only need it if
24664ce7165Smrg         you modified a \`.l' file.  You may need the \`Flex' package
24764ce7165Smrg         in order for those modifications to take effect.  You can get
24864ce7165Smrg         \`Flex' from any GNU archive site."
24964ce7165Smrg    rm -f lex.yy.c
25064ce7165Smrg    if test $# -ne 1; then
25164ce7165Smrg        eval LASTARG="\${$#}"
25264ce7165Smrg	case $LASTARG in
25364ce7165Smrg	*.l)
25464ce7165Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25564ce7165Smrg	    if test -f "$SRCFILE"; then
25664ce7165Smrg	         cp "$SRCFILE" lex.yy.c
25764ce7165Smrg	    fi
25864ce7165Smrg	  ;;
25964ce7165Smrg	esac
26064ce7165Smrg    fi
26164ce7165Smrg    if test ! -f lex.yy.c; then
26264ce7165Smrg	echo 'main() { return 0; }' >lex.yy.c
26364ce7165Smrg    fi
26464ce7165Smrg    ;;
26564ce7165Smrg
26664ce7165Smrg  help2man)
26764ce7165Smrg    echo 1>&2 "\
26864ce7165SmrgWARNING: \`$1' is $msg.  You should only need it if
26964ce7165Smrg	 you modified a dependency of a manual page.  You may need the
27064ce7165Smrg	 \`Help2man' package in order for those modifications to take
27164ce7165Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
27264ce7165Smrg
27364ce7165Smrg    file=`echo "$*" | sed -n "$sed_output"`
27464ce7165Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
27564ce7165Smrg    if test -f "$file"; then
27664ce7165Smrg	touch $file
27764ce7165Smrg    else
27864ce7165Smrg	test -z "$file" || exec >$file
27964ce7165Smrg	echo ".ab help2man is required to generate this page"
28064ce7165Smrg	exit 1
28164ce7165Smrg    fi
28264ce7165Smrg    ;;
28364ce7165Smrg
28464ce7165Smrg  makeinfo)
28564ce7165Smrg    echo 1>&2 "\
28664ce7165SmrgWARNING: \`$1' is $msg.  You should only need it if
28764ce7165Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
28864ce7165Smrg         indirectly affecting the aspect of the manual.  The spurious
28964ce7165Smrg         call might also be the consequence of using a buggy \`make' (AIX,
29064ce7165Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
29164ce7165Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
29264ce7165Smrg    # The file to touch is that specified with -o ...
29364ce7165Smrg    file=`echo "$*" | sed -n "$sed_output"`
29464ce7165Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
29564ce7165Smrg    if test -z "$file"; then
29664ce7165Smrg      # ... or it is the one specified with @setfilename ...
29764ce7165Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
29864ce7165Smrg      file=`sed -n '
29964ce7165Smrg	/^@setfilename/{
30064ce7165Smrg	  s/.* \([^ ]*\) *$/\1/
30164ce7165Smrg	  p
30264ce7165Smrg	  q
30364ce7165Smrg	}' $infile`
30464ce7165Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
30564ce7165Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
30664ce7165Smrg    fi
30764ce7165Smrg    # If the file does not exist, the user really needs makeinfo;
30864ce7165Smrg    # let's fail without touching anything.
30964ce7165Smrg    test -f $file || exit 1
31064ce7165Smrg    touch $file
31164ce7165Smrg    ;;
31264ce7165Smrg
31364ce7165Smrg  tar)
31464ce7165Smrg    shift
31564ce7165Smrg
31664ce7165Smrg    # We have already tried tar in the generic part.
31764ce7165Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
31864ce7165Smrg    # messages.
31964ce7165Smrg    if (gnutar --version > /dev/null 2>&1); then
32064ce7165Smrg       gnutar "$@" && exit 0
32164ce7165Smrg    fi
32264ce7165Smrg    if (gtar --version > /dev/null 2>&1); then
32364ce7165Smrg       gtar "$@" && exit 0
32464ce7165Smrg    fi
32564ce7165Smrg    firstarg="$1"
32664ce7165Smrg    if shift; then
32764ce7165Smrg	case $firstarg in
32864ce7165Smrg	*o*)
32964ce7165Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
33064ce7165Smrg	    tar "$firstarg" "$@" && exit 0
33164ce7165Smrg	    ;;
33264ce7165Smrg	esac
33364ce7165Smrg	case $firstarg in
33464ce7165Smrg	*h*)
33564ce7165Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
33664ce7165Smrg	    tar "$firstarg" "$@" && exit 0
33764ce7165Smrg	    ;;
33864ce7165Smrg	esac
33964ce7165Smrg    fi
34064ce7165Smrg
34164ce7165Smrg    echo 1>&2 "\
34264ce7165SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
34364ce7165Smrg         You may want to install GNU tar or Free paxutils, or check the
34464ce7165Smrg         command line arguments."
34564ce7165Smrg    exit 1
34664ce7165Smrg    ;;
34764ce7165Smrg
34864ce7165Smrg  *)
34964ce7165Smrg    echo 1>&2 "\
35064ce7165SmrgWARNING: \`$1' is needed, and is $msg.
35164ce7165Smrg         You might have modified some files without having the
35264ce7165Smrg         proper tools for further handling them.  Check the \`README' file,
35364ce7165Smrg         it often tells you about the needed prerequisites for installing
35464ce7165Smrg         this package.  You may also peek at any GNU archive site, in case
35564ce7165Smrg         some other package would contain this missing \`$1' program."
35664ce7165Smrg    exit 1
35764ce7165Smrg    ;;
35864ce7165Smrgesac
35964ce7165Smrg
36064ce7165Smrgexit 0
36164ce7165Smrg
36264ce7165Smrg# Local variables:
36364ce7165Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
36464ce7165Smrg# time-stamp-start: "scriptversion="
36564ce7165Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
36664ce7165Smrg# time-stamp-end: "$"
36764ce7165Smrg# End:
368