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