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