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