154359Sroberto#! /bin/sh
254359Sroberto# Common stub for a few missing GNU programs while installing.
3182007Sroberto
4182007Srobertoscriptversion=2005-06-08.21
5182007Sroberto
6182007Sroberto# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7182007Sroberto#   Free Software Foundation, Inc.
856746Sroberto# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
954359Sroberto
1054359Sroberto# This program is free software; you can redistribute it and/or modify
1154359Sroberto# it under the terms of the GNU General Public License as published by
1254359Sroberto# the Free Software Foundation; either version 2, or (at your option)
1354359Sroberto# any later version.
1454359Sroberto
1554359Sroberto# This program is distributed in the hope that it will be useful,
1654359Sroberto# but WITHOUT ANY WARRANTY; without even the implied warranty of
1754359Sroberto# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1854359Sroberto# GNU General Public License for more details.
1954359Sroberto
2054359Sroberto# You should have received a copy of the GNU General Public License
2154359Sroberto# along with this program; if not, write to the Free Software
22182007Sroberto# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23182007Sroberto# 02110-1301, USA.
2454359Sroberto
25106424Sroberto# As a special exception to the GNU General Public License, if you
26106424Sroberto# distribute this file as part of a program that contains a
27106424Sroberto# configuration script generated by Autoconf, you may include it under
28106424Sroberto# the same distribution terms that you use for the rest of that program.
29106424Sroberto
3054359Srobertoif test $# -eq 0; then
3154359Sroberto  echo 1>&2 "Try \`$0 --help' for more information"
3254359Sroberto  exit 1
3354359Srobertofi
3454359Sroberto
3556746Srobertorun=:
3656746Sroberto
37106424Sroberto# In the cases where this matters, `missing' is being run in the
38106424Sroberto# srcdir already.
39106424Srobertoif test -f configure.ac; then
40106424Sroberto  configure_ac=configure.ac
41106424Srobertoelse
42106424Sroberto  configure_ac=configure.in
43106424Srobertofi
44106424Sroberto
45182007Srobertomsg="missing on your system"
46182007Sroberto
4754359Srobertocase "$1" in
4856746Sroberto--run)
4956746Sroberto  # Try to run requested program, and just exit if it succeeds.
5056746Sroberto  run=
5156746Sroberto  shift
5256746Sroberto  "$@" && exit 0
53182007Sroberto  # Exit code 63 means version mismatch.  This often happens
54182007Sroberto  # when the user try to use an ancient version of a tool on
55182007Sroberto  # a file that requires a minimum version.  In this case we
56182007Sroberto  # we should proceed has if the program had been absent, or
57182007Sroberto  # if --run hadn't been passed.
58182007Sroberto  if test $? = 63; then
59182007Sroberto    run=:
60182007Sroberto    msg="probably too old"
61182007Sroberto  fi
6256746Sroberto  ;;
6354359Sroberto
6454359Sroberto  -h|--h|--he|--hel|--help)
6554359Sroberto    echo "\
6654359Sroberto$0 [OPTION]... PROGRAM [ARGUMENT]...
6754359Sroberto
6854359SrobertoHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
6954359Srobertoerror status if there is no known handling for PROGRAM.
7054359Sroberto
7154359SrobertoOptions:
7254359Sroberto  -h, --help      display this help and exit
7354359Sroberto  -v, --version   output version information and exit
7456746Sroberto  --run           try to run the given command, and emulate it if it fails
7554359Sroberto
7654359SrobertoSupported PROGRAM values:
7754359Sroberto  aclocal      touch file \`aclocal.m4'
7854359Sroberto  autoconf     touch file \`configure'
7954359Sroberto  autoheader   touch file \`config.h.in'
8054359Sroberto  automake     touch all \`Makefile.in' files
8156746Sroberto  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
8256746Sroberto  flex         create \`lex.yy.c', if possible, from existing .c
8382498Sroberto  help2man     touch the output file
8456746Sroberto  lex          create \`lex.yy.c', if possible, from existing .c
8554359Sroberto  makeinfo     touch the output file
8656746Sroberto  tar          try tar, gnutar, gtar, then tar without non-portable flags
87182007Sroberto  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88182007Sroberto
89182007SrobertoSend bug reports to <bug-automake@gnu.org>."
90182007Sroberto    exit $?
9154359Sroberto    ;;
9254359Sroberto
9354359Sroberto  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94182007Sroberto    echo "missing $scriptversion (GNU Automake)"
95182007Sroberto    exit $?
9654359Sroberto    ;;
9754359Sroberto
9854359Sroberto  -*)
9954359Sroberto    echo 1>&2 "$0: Unknown \`$1' option"
10054359Sroberto    echo 1>&2 "Try \`$0 --help' for more information"
10154359Sroberto    exit 1
10254359Sroberto    ;;
10354359Sroberto
104182007Srobertoesac
105182007Sroberto
106182007Sroberto# Now exit if we have it, but it failed.  Also exit now if we
107182007Sroberto# don't have it and --version was passed (most likely to detect
108182007Sroberto# the program).
109182007Srobertocase "$1" in
110182007Sroberto  lex|yacc)
111182007Sroberto    # Not GNU programs, they don't have --version.
112182007Sroberto    ;;
113182007Sroberto
114182007Sroberto  tar)
115182007Sroberto    if test -n "$run"; then
116182007Sroberto       echo 1>&2 "ERROR: \`tar' requires --run"
117182007Sroberto       exit 1
118182007Sroberto    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119182007Sroberto       exit 1
120182007Sroberto    fi
121182007Sroberto    ;;
122182007Sroberto
123182007Sroberto  *)
124132451Sroberto    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125132451Sroberto       # We have it, but it failed.
126132451Sroberto       exit 1
127182007Sroberto    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128182007Sroberto       # Could not run --version or --help.  This is probably someone
129182007Sroberto       # running `$TOOL --version' or `$TOOL --help' to check whether
130182007Sroberto       # $TOOL exists and not knowing $TOOL uses missing.
131182007Sroberto       exit 1
132132451Sroberto    fi
133182007Sroberto    ;;
134182007Srobertoesac
135132451Sroberto
136182007Sroberto# If it does not exist, or fails to run (possibly an outdated version),
137182007Sroberto# try to emulate it.
138182007Srobertocase "$1" in
139182007Sroberto  aclocal*)
14054359Sroberto    echo 1>&2 "\
141182007SrobertoWARNING: \`$1' is $msg.  You should only need it if
142106424Sroberto         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
14354359Sroberto         to install the \`Automake' and \`Perl' packages.  Grab them from
14454359Sroberto         any GNU archive site."
14554359Sroberto    touch aclocal.m4
14654359Sroberto    ;;
14754359Sroberto
14854359Sroberto  autoconf)
14954359Sroberto    echo 1>&2 "\
150182007SrobertoWARNING: \`$1' is $msg.  You should only need it if
151106424Sroberto         you modified \`${configure_ac}'.  You might want to install the
15254359Sroberto         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
15354359Sroberto         archive site."
15454359Sroberto    touch configure
15554359Sroberto    ;;
15654359Sroberto
15754359Sroberto  autoheader)
15854359Sroberto    echo 1>&2 "\
159182007SrobertoWARNING: \`$1' is $msg.  You should only need it if
160106424Sroberto         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
16154359Sroberto         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
16254359Sroberto         from any GNU archive site."
163106424Sroberto    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
16456746Sroberto    test -z "$files" && files="config.h"
16556746Sroberto    touch_files=
16656746Sroberto    for f in $files; do
16756746Sroberto      case "$f" in
16856746Sroberto      *:*) touch_files="$touch_files "`echo "$f" |
16956746Sroberto				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
17056746Sroberto      *) touch_files="$touch_files $f.in";;
17156746Sroberto      esac
17256746Sroberto    done
17356746Sroberto    touch $touch_files
17454359Sroberto    ;;
17554359Sroberto
176132451Sroberto  automake*)
17754359Sroberto    echo 1>&2 "\
178182007SrobertoWARNING: \`$1' is $msg.  You should only need it if
179106424Sroberto         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
18054359Sroberto         You might want to install the \`Automake' and \`Perl' packages.
18154359Sroberto         Grab them from any GNU archive site."
18256746Sroberto    find . -type f -name Makefile.am -print |
18356746Sroberto	   sed 's/\.am$/.in/' |
18456746Sroberto	   while read f; do touch "$f"; done
18554359Sroberto    ;;
18654359Sroberto
187132451Sroberto  autom4te)
188132451Sroberto    echo 1>&2 "\
189182007SrobertoWARNING: \`$1' is needed, but is $msg.
190182007Sroberto         You might have modified some files without having the
191132451Sroberto         proper tools for further handling them.
192182007Sroberto         You can get \`$1' as part of \`Autoconf' from any GNU
193132451Sroberto         archive site."
194132451Sroberto
195132451Sroberto    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196132451Sroberto    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197132451Sroberto    if test -f "$file"; then
198132451Sroberto	touch $file
199132451Sroberto    else
200132451Sroberto	test -z "$file" || exec >$file
201132451Sroberto	echo "#! /bin/sh"
202132451Sroberto	echo "# Created by GNU Automake missing as a replacement of"
203132451Sroberto	echo "#  $ $@"
204132451Sroberto	echo "exit 0"
205132451Sroberto	chmod +x $file
206132451Sroberto	exit 1
207132451Sroberto    fi
208132451Sroberto    ;;
209132451Sroberto
21054359Sroberto  bison|yacc)
21154359Sroberto    echo 1>&2 "\
212182007SrobertoWARNING: \`$1' $msg.  You should only need it if
21354359Sroberto         you modified a \`.y' file.  You may need the \`Bison' package
21454359Sroberto         in order for those modifications to take effect.  You can get
21554359Sroberto         \`Bison' from any GNU archive site."
21656746Sroberto    rm -f y.tab.c y.tab.h
21756746Sroberto    if [ $# -ne 1 ]; then
21856746Sroberto        eval LASTARG="\${$#}"
21956746Sroberto	case "$LASTARG" in
22056746Sroberto	*.y)
22156746Sroberto	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
22256746Sroberto	    if [ -f "$SRCFILE" ]; then
22356746Sroberto	         cp "$SRCFILE" y.tab.c
22456746Sroberto	    fi
22556746Sroberto	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
22656746Sroberto	    if [ -f "$SRCFILE" ]; then
22756746Sroberto	         cp "$SRCFILE" y.tab.h
22856746Sroberto	    fi
22956746Sroberto	  ;;
23056746Sroberto	esac
23156746Sroberto    fi
23256746Sroberto    if [ ! -f y.tab.h ]; then
23356746Sroberto	echo >y.tab.h
23456746Sroberto    fi
23556746Sroberto    if [ ! -f y.tab.c ]; then
23656746Sroberto	echo 'main() { return 0; }' >y.tab.c
23756746Sroberto    fi
23854359Sroberto    ;;
23954359Sroberto
24056746Sroberto  lex|flex)
24156746Sroberto    echo 1>&2 "\
242182007SrobertoWARNING: \`$1' is $msg.  You should only need it if
24356746Sroberto         you modified a \`.l' file.  You may need the \`Flex' package
24456746Sroberto         in order for those modifications to take effect.  You can get
24556746Sroberto         \`Flex' from any GNU archive site."
24656746Sroberto    rm -f lex.yy.c
24756746Sroberto    if [ $# -ne 1 ]; then
24856746Sroberto        eval LASTARG="\${$#}"
24956746Sroberto	case "$LASTARG" in
25056746Sroberto	*.l)
25156746Sroberto	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
25256746Sroberto	    if [ -f "$SRCFILE" ]; then
25356746Sroberto	         cp "$SRCFILE" lex.yy.c
25456746Sroberto	    fi
25556746Sroberto	  ;;
25656746Sroberto	esac
25756746Sroberto    fi
25856746Sroberto    if [ ! -f lex.yy.c ]; then
25956746Sroberto	echo 'main() { return 0; }' >lex.yy.c
26056746Sroberto    fi
26156746Sroberto    ;;
26256746Sroberto
26382498Sroberto  help2man)
26482498Sroberto    echo 1>&2 "\
265182007SrobertoWARNING: \`$1' is $msg.  You should only need it if
26682498Sroberto	 you modified a dependency of a manual page.  You may need the
26782498Sroberto	 \`Help2man' package in order for those modifications to take
26882498Sroberto	 effect.  You can get \`Help2man' from any GNU archive site."
26982498Sroberto
27082498Sroberto    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
27182498Sroberto    if test -z "$file"; then
27282498Sroberto	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
27382498Sroberto    fi
27482498Sroberto    if [ -f "$file" ]; then
27582498Sroberto	touch $file
27682498Sroberto    else
27782498Sroberto	test -z "$file" || exec >$file
27882498Sroberto	echo ".ab help2man is required to generate this page"
27982498Sroberto	exit 1
28082498Sroberto    fi
28182498Sroberto    ;;
28282498Sroberto
28354359Sroberto  makeinfo)
28454359Sroberto    echo 1>&2 "\
285182007SrobertoWARNING: \`$1' is $msg.  You should only need it if
28654359Sroberto         you modified a \`.texi' or \`.texinfo' file, or any other file
28754359Sroberto         indirectly affecting the aspect of the manual.  The spurious
28854359Sroberto         call might also be the consequence of using a buggy \`make' (AIX,
28954359Sroberto         DU, IRIX).  You might want to install the \`Texinfo' package or
29054359Sroberto         the \`GNU make' package.  Grab either from any GNU archive site."
291182007Sroberto    # The file to touch is that specified with -o ...
29254359Sroberto    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
29354359Sroberto    if test -z "$file"; then
294182007Sroberto      # ... or it is the one specified with @setfilename ...
295182007Sroberto      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296182007Sroberto      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297182007Sroberto      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298182007Sroberto      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
29954359Sroberto    fi
300182007Sroberto    # If the file does not exist, the user really needs makeinfo;
301182007Sroberto    # let's fail without touching anything.
302182007Sroberto    test -f $file || exit 1
30354359Sroberto    touch $file
30454359Sroberto    ;;
30554359Sroberto
30656746Sroberto  tar)
30756746Sroberto    shift
30856746Sroberto
30956746Sroberto    # We have already tried tar in the generic part.
31056746Sroberto    # Look for gnutar/gtar before invocation to avoid ugly error
31156746Sroberto    # messages.
31256746Sroberto    if (gnutar --version > /dev/null 2>&1); then
313132451Sroberto       gnutar "$@" && exit 0
31456746Sroberto    fi
31556746Sroberto    if (gtar --version > /dev/null 2>&1); then
316132451Sroberto       gtar "$@" && exit 0
31756746Sroberto    fi
31856746Sroberto    firstarg="$1"
31956746Sroberto    if shift; then
32056746Sroberto	case "$firstarg" in
32156746Sroberto	*o*)
32256746Sroberto	    firstarg=`echo "$firstarg" | sed s/o//`
323132451Sroberto	    tar "$firstarg" "$@" && exit 0
32456746Sroberto	    ;;
32556746Sroberto	esac
32656746Sroberto	case "$firstarg" in
32756746Sroberto	*h*)
32856746Sroberto	    firstarg=`echo "$firstarg" | sed s/h//`
329132451Sroberto	    tar "$firstarg" "$@" && exit 0
33056746Sroberto	    ;;
33156746Sroberto	esac
33256746Sroberto    fi
33356746Sroberto
33456746Sroberto    echo 1>&2 "\
33556746SrobertoWARNING: I can't seem to be able to run \`tar' with the given arguments.
33656746Sroberto         You may want to install GNU tar or Free paxutils, or check the
33756746Sroberto         command line arguments."
33856746Sroberto    exit 1
33956746Sroberto    ;;
34056746Sroberto
34154359Sroberto  *)
34254359Sroberto    echo 1>&2 "\
343182007SrobertoWARNING: \`$1' is needed, and is $msg.
344182007Sroberto         You might have modified some files without having the
34554359Sroberto         proper tools for further handling them.  Check the \`README' file,
346182007Sroberto         it often tells you about the needed prerequisites for installing
34754359Sroberto         this package.  You may also peek at any GNU archive site, in case
34854359Sroberto         some other package would contain this missing \`$1' program."
34954359Sroberto    exit 1
35054359Sroberto    ;;
35154359Srobertoesac
35254359Sroberto
35354359Srobertoexit 0
354182007Sroberto
355182007Sroberto# Local variables:
356182007Sroberto# eval: (add-hook 'write-file-hooks 'time-stamp)
357182007Sroberto# time-stamp-start: "scriptversion="
358182007Sroberto# time-stamp-format: "%:y-%02m-%02d.%02H"
359182007Sroberto# time-stamp-end: "$"
360182007Sroberto# End:
361