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