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