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