missing revision 98049353
198049353Smrg#! /bin/sh
298049353Smrg# Common stub for a few missing GNU programs while installing.
398049353Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
498049353Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
598049353Smrg
698049353Smrg# This program is free software; you can redistribute it and/or modify
798049353Smrg# it under the terms of the GNU General Public License as published by
898049353Smrg# the Free Software Foundation; either version 2, or (at your option)
998049353Smrg# any later version.
1098049353Smrg
1198049353Smrg# This program is distributed in the hope that it will be useful,
1298049353Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1398049353Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1498049353Smrg# GNU General Public License for more details.
1598049353Smrg
1698049353Smrg# You should have received a copy of the GNU General Public License
1798049353Smrg# along with this program; if not, write to the Free Software
1898049353Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1998049353Smrg# 02111-1307, USA.
2098049353Smrg
2198049353Smrg# As a special exception to the GNU General Public License, if you
2298049353Smrg# distribute this file as part of a program that contains a
2398049353Smrg# configuration script generated by Autoconf, you may include it under
2498049353Smrg# the same distribution terms that you use for the rest of that program.
2598049353Smrg
2698049353Smrgif test $# -eq 0; then
2798049353Smrg  echo 1>&2 "Try \`$0 --help' for more information"
2898049353Smrg  exit 1
2998049353Smrgfi
3098049353Smrg
3198049353Smrgrun=:
3298049353Smrg
3398049353Smrg# In the cases where this matters, `missing' is being run in the
3498049353Smrg# srcdir already.
3598049353Smrgif test -f configure.ac; then
3698049353Smrg  configure_ac=configure.ac
3798049353Smrgelse
3898049353Smrg  configure_ac=configure.in
3998049353Smrgfi
4098049353Smrg
4198049353Smrgcase "$1" in
4298049353Smrg--run)
4398049353Smrg  # Try to run requested program, and just exit if it succeeds.
4498049353Smrg  run=
4598049353Smrg  shift
4698049353Smrg  "$@" && exit 0
4798049353Smrg  ;;
4898049353Smrgesac
4998049353Smrg
5098049353Smrg# If it does not exist, or fails to run (possibly an outdated version),
5198049353Smrg# try to emulate it.
5298049353Smrgcase "$1" in
5398049353Smrg
5498049353Smrg  -h|--h|--he|--hel|--help)
5598049353Smrg    echo "\
5698049353Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
5798049353Smrg
5898049353SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
5998049353Smrgerror status if there is no known handling for PROGRAM.
6098049353Smrg
6198049353SmrgOptions:
6298049353Smrg  -h, --help      display this help and exit
6398049353Smrg  -v, --version   output version information and exit
6498049353Smrg  --run           try to run the given command, and emulate it if it fails
6598049353Smrg
6698049353SmrgSupported PROGRAM values:
6798049353Smrg  aclocal      touch file \`aclocal.m4'
6898049353Smrg  autoconf     touch file \`configure'
6998049353Smrg  autoheader   touch file \`config.h.in'
7098049353Smrg  automake     touch all \`Makefile.in' files
7198049353Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
7298049353Smrg  flex         create \`lex.yy.c', if possible, from existing .c
7398049353Smrg  help2man     touch the output file
7498049353Smrg  lex          create \`lex.yy.c', if possible, from existing .c
7598049353Smrg  makeinfo     touch the output file
7698049353Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
7798049353Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
7898049353Smrg    ;;
7998049353Smrg
8098049353Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
8198049353Smrg    echo "missing 0.4 - GNU automake"
8298049353Smrg    ;;
8398049353Smrg
8498049353Smrg  -*)
8598049353Smrg    echo 1>&2 "$0: Unknown \`$1' option"
8698049353Smrg    echo 1>&2 "Try \`$0 --help' for more information"
8798049353Smrg    exit 1
8898049353Smrg    ;;
8998049353Smrg
9098049353Smrg  aclocal*)
9198049353Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
9298049353Smrg       # We have it, but it failed.
9398049353Smrg       exit 1
9498049353Smrg    fi
9598049353Smrg
9698049353Smrg    echo 1>&2 "\
9798049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
9898049353Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
9998049353Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
10098049353Smrg         any GNU archive site."
10198049353Smrg    touch aclocal.m4
10298049353Smrg    ;;
10398049353Smrg
10498049353Smrg  autoconf)
10598049353Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
10698049353Smrg       # We have it, but it failed.
10798049353Smrg       exit 1
10898049353Smrg    fi
10998049353Smrg
11098049353Smrg    echo 1>&2 "\
11198049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
11298049353Smrg         you modified \`${configure_ac}'.  You might want to install the
11398049353Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
11498049353Smrg         archive site."
11598049353Smrg    touch configure
11698049353Smrg    ;;
11798049353Smrg
11898049353Smrg  autoheader)
11998049353Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
12098049353Smrg       # We have it, but it failed.
12198049353Smrg       exit 1
12298049353Smrg    fi
12398049353Smrg
12498049353Smrg    echo 1>&2 "\
12598049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
12698049353Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
12798049353Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
12898049353Smrg         from any GNU archive site."
12998049353Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
13098049353Smrg    test -z "$files" && files="config.h"
13198049353Smrg    touch_files=
13298049353Smrg    for f in $files; do
13398049353Smrg      case "$f" in
13498049353Smrg      *:*) touch_files="$touch_files "`echo "$f" |
13598049353Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
13698049353Smrg      *) touch_files="$touch_files $f.in";;
13798049353Smrg      esac
13898049353Smrg    done
13998049353Smrg    touch $touch_files
14098049353Smrg    ;;
14198049353Smrg
14298049353Smrg  automake*)
14398049353Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
14498049353Smrg       # We have it, but it failed.
14598049353Smrg       exit 1
14698049353Smrg    fi
14798049353Smrg
14898049353Smrg    echo 1>&2 "\
14998049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
15098049353Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
15198049353Smrg         You might want to install the \`Automake' and \`Perl' packages.
15298049353Smrg         Grab them from any GNU archive site."
15398049353Smrg    find . -type f -name Makefile.am -print |
15498049353Smrg	   sed 's/\.am$/.in/' |
15598049353Smrg	   while read f; do touch "$f"; done
15698049353Smrg    ;;
15798049353Smrg
15898049353Smrg  autom4te)
15998049353Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
16098049353Smrg       # We have it, but it failed.
16198049353Smrg       exit 1
16298049353Smrg    fi
16398049353Smrg
16498049353Smrg    echo 1>&2 "\
16598049353SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
16698049353Smrg         system.  You might have modified some files without having the
16798049353Smrg         proper tools for further handling them.
16898049353Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
16998049353Smrg         archive site."
17098049353Smrg
17198049353Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
17298049353Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
17398049353Smrg    if test -f "$file"; then
17498049353Smrg	touch $file
17598049353Smrg    else
17698049353Smrg	test -z "$file" || exec >$file
17798049353Smrg	echo "#! /bin/sh"
17898049353Smrg	echo "# Created by GNU Automake missing as a replacement of"
17998049353Smrg	echo "#  $ $@"
18098049353Smrg	echo "exit 0"
18198049353Smrg	chmod +x $file
18298049353Smrg	exit 1
18398049353Smrg    fi
18498049353Smrg    ;;
18598049353Smrg
18698049353Smrg  bison|yacc)
18798049353Smrg    echo 1>&2 "\
18898049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
18998049353Smrg         you modified a \`.y' file.  You may need the \`Bison' package
19098049353Smrg         in order for those modifications to take effect.  You can get
19198049353Smrg         \`Bison' from any GNU archive site."
19298049353Smrg    rm -f y.tab.c y.tab.h
19398049353Smrg    if [ $# -ne 1 ]; then
19498049353Smrg        eval LASTARG="\${$#}"
19598049353Smrg	case "$LASTARG" in
19698049353Smrg	*.y)
19798049353Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
19898049353Smrg	    if [ -f "$SRCFILE" ]; then
19998049353Smrg	         cp "$SRCFILE" y.tab.c
20098049353Smrg	    fi
20198049353Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
20298049353Smrg	    if [ -f "$SRCFILE" ]; then
20398049353Smrg	         cp "$SRCFILE" y.tab.h
20498049353Smrg	    fi
20598049353Smrg	  ;;
20698049353Smrg	esac
20798049353Smrg    fi
20898049353Smrg    if [ ! -f y.tab.h ]; then
20998049353Smrg	echo >y.tab.h
21098049353Smrg    fi
21198049353Smrg    if [ ! -f y.tab.c ]; then
21298049353Smrg	echo 'main() { return 0; }' >y.tab.c
21398049353Smrg    fi
21498049353Smrg    ;;
21598049353Smrg
21698049353Smrg  lex|flex)
21798049353Smrg    echo 1>&2 "\
21898049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
21998049353Smrg         you modified a \`.l' file.  You may need the \`Flex' package
22098049353Smrg         in order for those modifications to take effect.  You can get
22198049353Smrg         \`Flex' from any GNU archive site."
22298049353Smrg    rm -f lex.yy.c
22398049353Smrg    if [ $# -ne 1 ]; then
22498049353Smrg        eval LASTARG="\${$#}"
22598049353Smrg	case "$LASTARG" in
22698049353Smrg	*.l)
22798049353Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
22898049353Smrg	    if [ -f "$SRCFILE" ]; then
22998049353Smrg	         cp "$SRCFILE" lex.yy.c
23098049353Smrg	    fi
23198049353Smrg	  ;;
23298049353Smrg	esac
23398049353Smrg    fi
23498049353Smrg    if [ ! -f lex.yy.c ]; then
23598049353Smrg	echo 'main() { return 0; }' >lex.yy.c
23698049353Smrg    fi
23798049353Smrg    ;;
23898049353Smrg
23998049353Smrg  help2man)
24098049353Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
24198049353Smrg       # We have it, but it failed.
24298049353Smrg       exit 1
24398049353Smrg    fi
24498049353Smrg
24598049353Smrg    echo 1>&2 "\
24698049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
24798049353Smrg	 you modified a dependency of a manual page.  You may need the
24898049353Smrg	 \`Help2man' package in order for those modifications to take
24998049353Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
25098049353Smrg
25198049353Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
25298049353Smrg    if test -z "$file"; then
25398049353Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
25498049353Smrg    fi
25598049353Smrg    if [ -f "$file" ]; then
25698049353Smrg	touch $file
25798049353Smrg    else
25898049353Smrg	test -z "$file" || exec >$file
25998049353Smrg	echo ".ab help2man is required to generate this page"
26098049353Smrg	exit 1
26198049353Smrg    fi
26298049353Smrg    ;;
26398049353Smrg
26498049353Smrg  makeinfo)
26598049353Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
26698049353Smrg       # We have makeinfo, but it failed.
26798049353Smrg       exit 1
26898049353Smrg    fi
26998049353Smrg
27098049353Smrg    echo 1>&2 "\
27198049353SmrgWARNING: \`$1' is missing on your system.  You should only need it if
27298049353Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
27398049353Smrg         indirectly affecting the aspect of the manual.  The spurious
27498049353Smrg         call might also be the consequence of using a buggy \`make' (AIX,
27598049353Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
27698049353Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
27798049353Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27898049353Smrg    if test -z "$file"; then
27998049353Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
28098049353Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
28198049353Smrg    fi
28298049353Smrg    touch $file
28398049353Smrg    ;;
28498049353Smrg
28598049353Smrg  tar)
28698049353Smrg    shift
28798049353Smrg    if test -n "$run"; then
28898049353Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
28998049353Smrg      exit 1
29098049353Smrg    fi
29198049353Smrg
29298049353Smrg    # We have already tried tar in the generic part.
29398049353Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
29498049353Smrg    # messages.
29598049353Smrg    if (gnutar --version > /dev/null 2>&1); then
29698049353Smrg       gnutar "$@" && exit 0
29798049353Smrg    fi
29898049353Smrg    if (gtar --version > /dev/null 2>&1); then
29998049353Smrg       gtar "$@" && exit 0
30098049353Smrg    fi
30198049353Smrg    firstarg="$1"
30298049353Smrg    if shift; then
30398049353Smrg	case "$firstarg" in
30498049353Smrg	*o*)
30598049353Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
30698049353Smrg	    tar "$firstarg" "$@" && exit 0
30798049353Smrg	    ;;
30898049353Smrg	esac
30998049353Smrg	case "$firstarg" in
31098049353Smrg	*h*)
31198049353Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
31298049353Smrg	    tar "$firstarg" "$@" && exit 0
31398049353Smrg	    ;;
31498049353Smrg	esac
31598049353Smrg    fi
31698049353Smrg
31798049353Smrg    echo 1>&2 "\
31898049353SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
31998049353Smrg         You may want to install GNU tar or Free paxutils, or check the
32098049353Smrg         command line arguments."
32198049353Smrg    exit 1
32298049353Smrg    ;;
32398049353Smrg
32498049353Smrg  *)
32598049353Smrg    echo 1>&2 "\
32698049353SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
32798049353Smrg         system.  You might have modified some files without having the
32898049353Smrg         proper tools for further handling them.  Check the \`README' file,
32998049353Smrg         it often tells you about the needed prerequisites for installing
33098049353Smrg         this package.  You may also peek at any GNU archive site, in case
33198049353Smrg         some other package would contain this missing \`$1' program."
33298049353Smrg    exit 1
33398049353Smrg    ;;
33498049353Smrgesac
33598049353Smrg
33698049353Smrgexit 0
337