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