missing revision d9c7fc6c
1d9c7fc6cSmrg#! /bin/sh
2d9c7fc6cSmrg# Common stub for a few missing GNU programs while installing.
3d9c7fc6cSmrg
4d9c7fc6cSmrgscriptversion=2005-06-08.21
5d9c7fc6cSmrg
6d9c7fc6cSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7d9c7fc6cSmrg#   Free Software Foundation, Inc.
8d9c7fc6cSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9d9c7fc6cSmrg
10d9c7fc6cSmrg# This program is free software; you can redistribute it and/or modify
11d9c7fc6cSmrg# it under the terms of the GNU General Public License as published by
12d9c7fc6cSmrg# the Free Software Foundation; either version 2, or (at your option)
13d9c7fc6cSmrg# any later version.
14d9c7fc6cSmrg
15d9c7fc6cSmrg# This program is distributed in the hope that it will be useful,
16d9c7fc6cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17d9c7fc6cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18d9c7fc6cSmrg# GNU General Public License for more details.
19d9c7fc6cSmrg
20d9c7fc6cSmrg# You should have received a copy of the GNU General Public License
21d9c7fc6cSmrg# along with this program; if not, write to the Free Software
22d9c7fc6cSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23d9c7fc6cSmrg# 02110-1301, USA.
24d9c7fc6cSmrg
25d9c7fc6cSmrg# As a special exception to the GNU General Public License, if you
26d9c7fc6cSmrg# distribute this file as part of a program that contains a
27d9c7fc6cSmrg# configuration script generated by Autoconf, you may include it under
28d9c7fc6cSmrg# the same distribution terms that you use for the rest of that program.
29d9c7fc6cSmrg
30d9c7fc6cSmrgif test $# -eq 0; then
31d9c7fc6cSmrg  echo 1>&2 "Try \`$0 --help' for more information"
32d9c7fc6cSmrg  exit 1
33d9c7fc6cSmrgfi
34d9c7fc6cSmrg
35d9c7fc6cSmrgrun=:
36d9c7fc6cSmrg
37d9c7fc6cSmrg# In the cases where this matters, `missing' is being run in the
38d9c7fc6cSmrg# srcdir already.
39d9c7fc6cSmrgif test -f configure.ac; then
40d9c7fc6cSmrg  configure_ac=configure.ac
41d9c7fc6cSmrgelse
42d9c7fc6cSmrg  configure_ac=configure.in
43d9c7fc6cSmrgfi
44d9c7fc6cSmrg
45d9c7fc6cSmrgmsg="missing on your system"
46d9c7fc6cSmrg
47d9c7fc6cSmrgcase "$1" in
48d9c7fc6cSmrg--run)
49d9c7fc6cSmrg  # Try to run requested program, and just exit if it succeeds.
50d9c7fc6cSmrg  run=
51d9c7fc6cSmrg  shift
52d9c7fc6cSmrg  "$@" && exit 0
53d9c7fc6cSmrg  # Exit code 63 means version mismatch.  This often happens
54d9c7fc6cSmrg  # when the user try to use an ancient version of a tool on
55d9c7fc6cSmrg  # a file that requires a minimum version.  In this case we
56d9c7fc6cSmrg  # we should proceed has if the program had been absent, or
57d9c7fc6cSmrg  # if --run hadn't been passed.
58d9c7fc6cSmrg  if test $? = 63; then
59d9c7fc6cSmrg    run=:
60d9c7fc6cSmrg    msg="probably too old"
61d9c7fc6cSmrg  fi
62d9c7fc6cSmrg  ;;
63d9c7fc6cSmrg
64d9c7fc6cSmrg  -h|--h|--he|--hel|--help)
65d9c7fc6cSmrg    echo "\
66d9c7fc6cSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67d9c7fc6cSmrg
68d9c7fc6cSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69d9c7fc6cSmrgerror status if there is no known handling for PROGRAM.
70d9c7fc6cSmrg
71d9c7fc6cSmrgOptions:
72d9c7fc6cSmrg  -h, --help      display this help and exit
73d9c7fc6cSmrg  -v, --version   output version information and exit
74d9c7fc6cSmrg  --run           try to run the given command, and emulate it if it fails
75d9c7fc6cSmrg
76d9c7fc6cSmrgSupported PROGRAM values:
77d9c7fc6cSmrg  aclocal      touch file \`aclocal.m4'
78d9c7fc6cSmrg  autoconf     touch file \`configure'
79d9c7fc6cSmrg  autoheader   touch file \`config.h.in'
80d9c7fc6cSmrg  automake     touch all \`Makefile.in' files
81d9c7fc6cSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
82d9c7fc6cSmrg  flex         create \`lex.yy.c', if possible, from existing .c
83d9c7fc6cSmrg  help2man     touch the output file
84d9c7fc6cSmrg  lex          create \`lex.yy.c', if possible, from existing .c
85d9c7fc6cSmrg  makeinfo     touch the output file
86d9c7fc6cSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
87d9c7fc6cSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88d9c7fc6cSmrg
89d9c7fc6cSmrgSend bug reports to <bug-automake@gnu.org>."
90d9c7fc6cSmrg    exit $?
91d9c7fc6cSmrg    ;;
92d9c7fc6cSmrg
93d9c7fc6cSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94d9c7fc6cSmrg    echo "missing $scriptversion (GNU Automake)"
95d9c7fc6cSmrg    exit $?
96d9c7fc6cSmrg    ;;
97d9c7fc6cSmrg
98d9c7fc6cSmrg  -*)
99d9c7fc6cSmrg    echo 1>&2 "$0: Unknown \`$1' option"
100d9c7fc6cSmrg    echo 1>&2 "Try \`$0 --help' for more information"
101d9c7fc6cSmrg    exit 1
102d9c7fc6cSmrg    ;;
103d9c7fc6cSmrg
104d9c7fc6cSmrgesac
105d9c7fc6cSmrg
106d9c7fc6cSmrg# Now exit if we have it, but it failed.  Also exit now if we
107d9c7fc6cSmrg# don't have it and --version was passed (most likely to detect
108d9c7fc6cSmrg# the program).
109d9c7fc6cSmrgcase "$1" in
110d9c7fc6cSmrg  lex|yacc)
111d9c7fc6cSmrg    # Not GNU programs, they don't have --version.
112d9c7fc6cSmrg    ;;
113d9c7fc6cSmrg
114d9c7fc6cSmrg  tar)
115d9c7fc6cSmrg    if test -n "$run"; then
116d9c7fc6cSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
117d9c7fc6cSmrg       exit 1
118d9c7fc6cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119d9c7fc6cSmrg       exit 1
120d9c7fc6cSmrg    fi
121d9c7fc6cSmrg    ;;
122d9c7fc6cSmrg
123d9c7fc6cSmrg  *)
124d9c7fc6cSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125d9c7fc6cSmrg       # We have it, but it failed.
126d9c7fc6cSmrg       exit 1
127d9c7fc6cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128d9c7fc6cSmrg       # Could not run --version or --help.  This is probably someone
129d9c7fc6cSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
130d9c7fc6cSmrg       # $TOOL exists and not knowing $TOOL uses missing.
131d9c7fc6cSmrg       exit 1
132d9c7fc6cSmrg    fi
133d9c7fc6cSmrg    ;;
134d9c7fc6cSmrgesac
135d9c7fc6cSmrg
136d9c7fc6cSmrg# If it does not exist, or fails to run (possibly an outdated version),
137d9c7fc6cSmrg# try to emulate it.
138d9c7fc6cSmrgcase "$1" in
139d9c7fc6cSmrg  aclocal*)
140d9c7fc6cSmrg    echo 1>&2 "\
141d9c7fc6cSmrgWARNING: \`$1' is $msg.  You should only need it if
142d9c7fc6cSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143d9c7fc6cSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
144d9c7fc6cSmrg         any GNU archive site."
145d9c7fc6cSmrg    touch aclocal.m4
146d9c7fc6cSmrg    ;;
147d9c7fc6cSmrg
148d9c7fc6cSmrg  autoconf)
149d9c7fc6cSmrg    echo 1>&2 "\
150d9c7fc6cSmrgWARNING: \`$1' is $msg.  You should only need it if
151d9c7fc6cSmrg         you modified \`${configure_ac}'.  You might want to install the
152d9c7fc6cSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153d9c7fc6cSmrg         archive site."
154d9c7fc6cSmrg    touch configure
155d9c7fc6cSmrg    ;;
156d9c7fc6cSmrg
157d9c7fc6cSmrg  autoheader)
158d9c7fc6cSmrg    echo 1>&2 "\
159d9c7fc6cSmrgWARNING: \`$1' is $msg.  You should only need it if
160d9c7fc6cSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161d9c7fc6cSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162d9c7fc6cSmrg         from any GNU archive site."
163d9c7fc6cSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164d9c7fc6cSmrg    test -z "$files" && files="config.h"
165d9c7fc6cSmrg    touch_files=
166d9c7fc6cSmrg    for f in $files; do
167d9c7fc6cSmrg      case "$f" in
168d9c7fc6cSmrg      *:*) touch_files="$touch_files "`echo "$f" |
169d9c7fc6cSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170d9c7fc6cSmrg      *) touch_files="$touch_files $f.in";;
171d9c7fc6cSmrg      esac
172d9c7fc6cSmrg    done
173d9c7fc6cSmrg    touch $touch_files
174d9c7fc6cSmrg    ;;
175d9c7fc6cSmrg
176d9c7fc6cSmrg  automake*)
177d9c7fc6cSmrg    echo 1>&2 "\
178d9c7fc6cSmrgWARNING: \`$1' is $msg.  You should only need it if
179d9c7fc6cSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180d9c7fc6cSmrg         You might want to install the \`Automake' and \`Perl' packages.
181d9c7fc6cSmrg         Grab them from any GNU archive site."
182d9c7fc6cSmrg    find . -type f -name Makefile.am -print |
183d9c7fc6cSmrg	   sed 's/\.am$/.in/' |
184d9c7fc6cSmrg	   while read f; do touch "$f"; done
185d9c7fc6cSmrg    ;;
186d9c7fc6cSmrg
187d9c7fc6cSmrg  autom4te)
188d9c7fc6cSmrg    echo 1>&2 "\
189d9c7fc6cSmrgWARNING: \`$1' is needed, but is $msg.
190d9c7fc6cSmrg         You might have modified some files without having the
191d9c7fc6cSmrg         proper tools for further handling them.
192d9c7fc6cSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
193d9c7fc6cSmrg         archive site."
194d9c7fc6cSmrg
195d9c7fc6cSmrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196d9c7fc6cSmrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197d9c7fc6cSmrg    if test -f "$file"; then
198d9c7fc6cSmrg	touch $file
199d9c7fc6cSmrg    else
200d9c7fc6cSmrg	test -z "$file" || exec >$file
201d9c7fc6cSmrg	echo "#! /bin/sh"
202d9c7fc6cSmrg	echo "# Created by GNU Automake missing as a replacement of"
203d9c7fc6cSmrg	echo "#  $ $@"
204d9c7fc6cSmrg	echo "exit 0"
205d9c7fc6cSmrg	chmod +x $file
206d9c7fc6cSmrg	exit 1
207d9c7fc6cSmrg    fi
208d9c7fc6cSmrg    ;;
209d9c7fc6cSmrg
210d9c7fc6cSmrg  bison|yacc)
211d9c7fc6cSmrg    echo 1>&2 "\
212d9c7fc6cSmrgWARNING: \`$1' $msg.  You should only need it if
213d9c7fc6cSmrg         you modified a \`.y' file.  You may need the \`Bison' package
214d9c7fc6cSmrg         in order for those modifications to take effect.  You can get
215d9c7fc6cSmrg         \`Bison' from any GNU archive site."
216d9c7fc6cSmrg    rm -f y.tab.c y.tab.h
217d9c7fc6cSmrg    if [ $# -ne 1 ]; then
218d9c7fc6cSmrg        eval LASTARG="\${$#}"
219d9c7fc6cSmrg	case "$LASTARG" in
220d9c7fc6cSmrg	*.y)
221d9c7fc6cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222d9c7fc6cSmrg	    if [ -f "$SRCFILE" ]; then
223d9c7fc6cSmrg	         cp "$SRCFILE" y.tab.c
224d9c7fc6cSmrg	    fi
225d9c7fc6cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226d9c7fc6cSmrg	    if [ -f "$SRCFILE" ]; then
227d9c7fc6cSmrg	         cp "$SRCFILE" y.tab.h
228d9c7fc6cSmrg	    fi
229d9c7fc6cSmrg	  ;;
230d9c7fc6cSmrg	esac
231d9c7fc6cSmrg    fi
232d9c7fc6cSmrg    if [ ! -f y.tab.h ]; then
233d9c7fc6cSmrg	echo >y.tab.h
234d9c7fc6cSmrg    fi
235d9c7fc6cSmrg    if [ ! -f y.tab.c ]; then
236d9c7fc6cSmrg	echo 'main() { return 0; }' >y.tab.c
237d9c7fc6cSmrg    fi
238d9c7fc6cSmrg    ;;
239d9c7fc6cSmrg
240d9c7fc6cSmrg  lex|flex)
241d9c7fc6cSmrg    echo 1>&2 "\
242d9c7fc6cSmrgWARNING: \`$1' is $msg.  You should only need it if
243d9c7fc6cSmrg         you modified a \`.l' file.  You may need the \`Flex' package
244d9c7fc6cSmrg         in order for those modifications to take effect.  You can get
245d9c7fc6cSmrg         \`Flex' from any GNU archive site."
246d9c7fc6cSmrg    rm -f lex.yy.c
247d9c7fc6cSmrg    if [ $# -ne 1 ]; then
248d9c7fc6cSmrg        eval LASTARG="\${$#}"
249d9c7fc6cSmrg	case "$LASTARG" in
250d9c7fc6cSmrg	*.l)
251d9c7fc6cSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252d9c7fc6cSmrg	    if [ -f "$SRCFILE" ]; then
253d9c7fc6cSmrg	         cp "$SRCFILE" lex.yy.c
254d9c7fc6cSmrg	    fi
255d9c7fc6cSmrg	  ;;
256d9c7fc6cSmrg	esac
257d9c7fc6cSmrg    fi
258d9c7fc6cSmrg    if [ ! -f lex.yy.c ]; then
259d9c7fc6cSmrg	echo 'main() { return 0; }' >lex.yy.c
260d9c7fc6cSmrg    fi
261d9c7fc6cSmrg    ;;
262d9c7fc6cSmrg
263d9c7fc6cSmrg  help2man)
264d9c7fc6cSmrg    echo 1>&2 "\
265d9c7fc6cSmrgWARNING: \`$1' is $msg.  You should only need it if
266d9c7fc6cSmrg	 you modified a dependency of a manual page.  You may need the
267d9c7fc6cSmrg	 \`Help2man' package in order for those modifications to take
268d9c7fc6cSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
269d9c7fc6cSmrg
270d9c7fc6cSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271d9c7fc6cSmrg    if test -z "$file"; then
272d9c7fc6cSmrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273d9c7fc6cSmrg    fi
274d9c7fc6cSmrg    if [ -f "$file" ]; then
275d9c7fc6cSmrg	touch $file
276d9c7fc6cSmrg    else
277d9c7fc6cSmrg	test -z "$file" || exec >$file
278d9c7fc6cSmrg	echo ".ab help2man is required to generate this page"
279d9c7fc6cSmrg	exit 1
280d9c7fc6cSmrg    fi
281d9c7fc6cSmrg    ;;
282d9c7fc6cSmrg
283d9c7fc6cSmrg  makeinfo)
284d9c7fc6cSmrg    echo 1>&2 "\
285d9c7fc6cSmrgWARNING: \`$1' is $msg.  You should only need it if
286d9c7fc6cSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
287d9c7fc6cSmrg         indirectly affecting the aspect of the manual.  The spurious
288d9c7fc6cSmrg         call might also be the consequence of using a buggy \`make' (AIX,
289d9c7fc6cSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
290d9c7fc6cSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
291d9c7fc6cSmrg    # The file to touch is that specified with -o ...
292d9c7fc6cSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
293d9c7fc6cSmrg    if test -z "$file"; then
294d9c7fc6cSmrg      # ... or it is the one specified with @setfilename ...
295d9c7fc6cSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296d9c7fc6cSmrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297d9c7fc6cSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298d9c7fc6cSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
299d9c7fc6cSmrg    fi
300d9c7fc6cSmrg    # If the file does not exist, the user really needs makeinfo;
301d9c7fc6cSmrg    # let's fail without touching anything.
302d9c7fc6cSmrg    test -f $file || exit 1
303d9c7fc6cSmrg    touch $file
304d9c7fc6cSmrg    ;;
305d9c7fc6cSmrg
306d9c7fc6cSmrg  tar)
307d9c7fc6cSmrg    shift
308d9c7fc6cSmrg
309d9c7fc6cSmrg    # We have already tried tar in the generic part.
310d9c7fc6cSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
311d9c7fc6cSmrg    # messages.
312d9c7fc6cSmrg    if (gnutar --version > /dev/null 2>&1); then
313d9c7fc6cSmrg       gnutar "$@" && exit 0
314d9c7fc6cSmrg    fi
315d9c7fc6cSmrg    if (gtar --version > /dev/null 2>&1); then
316d9c7fc6cSmrg       gtar "$@" && exit 0
317d9c7fc6cSmrg    fi
318d9c7fc6cSmrg    firstarg="$1"
319d9c7fc6cSmrg    if shift; then
320d9c7fc6cSmrg	case "$firstarg" in
321d9c7fc6cSmrg	*o*)
322d9c7fc6cSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
323d9c7fc6cSmrg	    tar "$firstarg" "$@" && exit 0
324d9c7fc6cSmrg	    ;;
325d9c7fc6cSmrg	esac
326d9c7fc6cSmrg	case "$firstarg" in
327d9c7fc6cSmrg	*h*)
328d9c7fc6cSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
329d9c7fc6cSmrg	    tar "$firstarg" "$@" && exit 0
330d9c7fc6cSmrg	    ;;
331d9c7fc6cSmrg	esac
332d9c7fc6cSmrg    fi
333d9c7fc6cSmrg
334d9c7fc6cSmrg    echo 1>&2 "\
335d9c7fc6cSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
336d9c7fc6cSmrg         You may want to install GNU tar or Free paxutils, or check the
337d9c7fc6cSmrg         command line arguments."
338d9c7fc6cSmrg    exit 1
339d9c7fc6cSmrg    ;;
340d9c7fc6cSmrg
341d9c7fc6cSmrg  *)
342d9c7fc6cSmrg    echo 1>&2 "\
343d9c7fc6cSmrgWARNING: \`$1' is needed, and is $msg.
344d9c7fc6cSmrg         You might have modified some files without having the
345d9c7fc6cSmrg         proper tools for further handling them.  Check the \`README' file,
346d9c7fc6cSmrg         it often tells you about the needed prerequisites for installing
347d9c7fc6cSmrg         this package.  You may also peek at any GNU archive site, in case
348d9c7fc6cSmrg         some other package would contain this missing \`$1' program."
349d9c7fc6cSmrg    exit 1
350d9c7fc6cSmrg    ;;
351d9c7fc6cSmrgesac
352d9c7fc6cSmrg
353d9c7fc6cSmrgexit 0
354d9c7fc6cSmrg
355d9c7fc6cSmrg# Local variables:
356d9c7fc6cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
357d9c7fc6cSmrg# time-stamp-start: "scriptversion="
358d9c7fc6cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
359d9c7fc6cSmrg# time-stamp-end: "$"
360d9c7fc6cSmrg# End:
361