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