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