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