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