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