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