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