missing revision 659607e0
1659607e0Smrg#! /bin/sh
2659607e0Smrg# Common stub for a few missing GNU programs while installing.
3659607e0Smrg
4659607e0Smrgscriptversion=2006-05-10.23
5659607e0Smrg
6659607e0Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
7659607e0Smrg#   Free Software Foundation, Inc.
8659607e0Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9659607e0Smrg
10659607e0Smrg# This program is free software; you can redistribute it and/or modify
11659607e0Smrg# it under the terms of the GNU General Public License as published by
12659607e0Smrg# the Free Software Foundation; either version 2, or (at your option)
13659607e0Smrg# any later version.
14659607e0Smrg
15659607e0Smrg# This program is distributed in the hope that it will be useful,
16659607e0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17659607e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18659607e0Smrg# GNU General Public License for more details.
19659607e0Smrg
20659607e0Smrg# You should have received a copy of the GNU General Public License
21659607e0Smrg# along with this program; if not, write to the Free Software
22659607e0Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23659607e0Smrg# 02110-1301, USA.
24659607e0Smrg
25659607e0Smrg# As a special exception to the GNU General Public License, if you
26659607e0Smrg# distribute this file as part of a program that contains a
27659607e0Smrg# configuration script generated by Autoconf, you may include it under
28659607e0Smrg# the same distribution terms that you use for the rest of that program.
29659607e0Smrg
30659607e0Smrgif test $# -eq 0; then
31659607e0Smrg  echo 1>&2 "Try \`$0 --help' for more information"
32659607e0Smrg  exit 1
33659607e0Smrgfi
34659607e0Smrg
35659607e0Smrgrun=:
36659607e0Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37659607e0Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
38659607e0Smrg
39659607e0Smrg# In the cases where this matters, `missing' is being run in the
40659607e0Smrg# srcdir already.
41659607e0Smrgif test -f configure.ac; then
42659607e0Smrg  configure_ac=configure.ac
43659607e0Smrgelse
44659607e0Smrg  configure_ac=configure.in
45659607e0Smrgfi
46659607e0Smrg
47659607e0Smrgmsg="missing on your system"
48659607e0Smrg
49659607e0Smrgcase $1 in
50659607e0Smrg--run)
51659607e0Smrg  # Try to run requested program, and just exit if it succeeds.
52659607e0Smrg  run=
53659607e0Smrg  shift
54659607e0Smrg  "$@" && exit 0
55659607e0Smrg  # Exit code 63 means version mismatch.  This often happens
56659607e0Smrg  # when the user try to use an ancient version of a tool on
57659607e0Smrg  # a file that requires a minimum version.  In this case we
58659607e0Smrg  # we should proceed has if the program had been absent, or
59659607e0Smrg  # if --run hadn't been passed.
60659607e0Smrg  if test $? = 63; then
61659607e0Smrg    run=:
62659607e0Smrg    msg="probably too old"
63659607e0Smrg  fi
64659607e0Smrg  ;;
65659607e0Smrg
66659607e0Smrg  -h|--h|--he|--hel|--help)
67659607e0Smrg    echo "\
68659607e0Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
69659607e0Smrg
70659607e0SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
71659607e0Smrgerror status if there is no known handling for PROGRAM.
72659607e0Smrg
73659607e0SmrgOptions:
74659607e0Smrg  -h, --help      display this help and exit
75659607e0Smrg  -v, --version   output version information and exit
76659607e0Smrg  --run           try to run the given command, and emulate it if it fails
77659607e0Smrg
78659607e0SmrgSupported PROGRAM values:
79659607e0Smrg  aclocal      touch file \`aclocal.m4'
80659607e0Smrg  autoconf     touch file \`configure'
81659607e0Smrg  autoheader   touch file \`config.h.in'
82659607e0Smrg  autom4te     touch the output file, or create a stub one
83659607e0Smrg  automake     touch all \`Makefile.in' files
84659607e0Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
85659607e0Smrg  flex         create \`lex.yy.c', if possible, from existing .c
86659607e0Smrg  help2man     touch the output file
87659607e0Smrg  lex          create \`lex.yy.c', if possible, from existing .c
88659607e0Smrg  makeinfo     touch the output file
89659607e0Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
90659607e0Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
91659607e0Smrg
92659607e0SmrgSend bug reports to <bug-automake@gnu.org>."
93659607e0Smrg    exit $?
94659607e0Smrg    ;;
95659607e0Smrg
96659607e0Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
97659607e0Smrg    echo "missing $scriptversion (GNU Automake)"
98659607e0Smrg    exit $?
99659607e0Smrg    ;;
100659607e0Smrg
101659607e0Smrg  -*)
102659607e0Smrg    echo 1>&2 "$0: Unknown \`$1' option"
103659607e0Smrg    echo 1>&2 "Try \`$0 --help' for more information"
104659607e0Smrg    exit 1
105659607e0Smrg    ;;
106659607e0Smrg
107659607e0Smrgesac
108659607e0Smrg
109659607e0Smrg# Now exit if we have it, but it failed.  Also exit now if we
110659607e0Smrg# don't have it and --version was passed (most likely to detect
111659607e0Smrg# the program).
112659607e0Smrgcase $1 in
113659607e0Smrg  lex|yacc)
114659607e0Smrg    # Not GNU programs, they don't have --version.
115659607e0Smrg    ;;
116659607e0Smrg
117659607e0Smrg  tar)
118659607e0Smrg    if test -n "$run"; then
119659607e0Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
120659607e0Smrg       exit 1
121659607e0Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
122659607e0Smrg       exit 1
123659607e0Smrg    fi
124659607e0Smrg    ;;
125659607e0Smrg
126659607e0Smrg  *)
127659607e0Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
128659607e0Smrg       # We have it, but it failed.
129659607e0Smrg       exit 1
130659607e0Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
131659607e0Smrg       # Could not run --version or --help.  This is probably someone
132659607e0Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
133659607e0Smrg       # $TOOL exists and not knowing $TOOL uses missing.
134659607e0Smrg       exit 1
135659607e0Smrg    fi
136659607e0Smrg    ;;
137659607e0Smrgesac
138659607e0Smrg
139659607e0Smrg# If it does not exist, or fails to run (possibly an outdated version),
140659607e0Smrg# try to emulate it.
141659607e0Smrgcase $1 in
142659607e0Smrg  aclocal*)
143659607e0Smrg    echo 1>&2 "\
144659607e0SmrgWARNING: \`$1' is $msg.  You should only need it if
145659607e0Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
146659607e0Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
147659607e0Smrg         any GNU archive site."
148659607e0Smrg    touch aclocal.m4
149659607e0Smrg    ;;
150659607e0Smrg
151659607e0Smrg  autoconf)
152659607e0Smrg    echo 1>&2 "\
153659607e0SmrgWARNING: \`$1' is $msg.  You should only need it if
154659607e0Smrg         you modified \`${configure_ac}'.  You might want to install the
155659607e0Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
156659607e0Smrg         archive site."
157659607e0Smrg    touch configure
158659607e0Smrg    ;;
159659607e0Smrg
160659607e0Smrg  autoheader)
161659607e0Smrg    echo 1>&2 "\
162659607e0SmrgWARNING: \`$1' is $msg.  You should only need it if
163659607e0Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
164659607e0Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
165659607e0Smrg         from any GNU archive site."
166659607e0Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
167659607e0Smrg    test -z "$files" && files="config.h"
168659607e0Smrg    touch_files=
169659607e0Smrg    for f in $files; do
170659607e0Smrg      case $f in
171659607e0Smrg      *:*) touch_files="$touch_files "`echo "$f" |
172659607e0Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
173659607e0Smrg      *) touch_files="$touch_files $f.in";;
174659607e0Smrg      esac
175659607e0Smrg    done
176659607e0Smrg    touch $touch_files
177659607e0Smrg    ;;
178659607e0Smrg
179659607e0Smrg  automake*)
180659607e0Smrg    echo 1>&2 "\
181659607e0SmrgWARNING: \`$1' is $msg.  You should only need it if
182659607e0Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
183659607e0Smrg         You might want to install the \`Automake' and \`Perl' packages.
184659607e0Smrg         Grab them from any GNU archive site."
185659607e0Smrg    find . -type f -name Makefile.am -print |
186659607e0Smrg	   sed 's/\.am$/.in/' |
187659607e0Smrg	   while read f; do touch "$f"; done
188659607e0Smrg    ;;
189659607e0Smrg
190659607e0Smrg  autom4te)
191659607e0Smrg    echo 1>&2 "\
192659607e0SmrgWARNING: \`$1' is needed, but is $msg.
193659607e0Smrg         You might have modified some files without having the
194659607e0Smrg         proper tools for further handling them.
195659607e0Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
196659607e0Smrg         archive site."
197659607e0Smrg
198659607e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
199659607e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
200659607e0Smrg    if test -f "$file"; then
201659607e0Smrg	touch $file
202659607e0Smrg    else
203659607e0Smrg	test -z "$file" || exec >$file
204659607e0Smrg	echo "#! /bin/sh"
205659607e0Smrg	echo "# Created by GNU Automake missing as a replacement of"
206659607e0Smrg	echo "#  $ $@"
207659607e0Smrg	echo "exit 0"
208659607e0Smrg	chmod +x $file
209659607e0Smrg	exit 1
210659607e0Smrg    fi
211659607e0Smrg    ;;
212659607e0Smrg
213659607e0Smrg  bison|yacc)
214659607e0Smrg    echo 1>&2 "\
215659607e0SmrgWARNING: \`$1' $msg.  You should only need it if
216659607e0Smrg         you modified a \`.y' file.  You may need the \`Bison' package
217659607e0Smrg         in order for those modifications to take effect.  You can get
218659607e0Smrg         \`Bison' from any GNU archive site."
219659607e0Smrg    rm -f y.tab.c y.tab.h
220659607e0Smrg    if test $# -ne 1; then
221659607e0Smrg        eval LASTARG="\${$#}"
222659607e0Smrg	case $LASTARG in
223659607e0Smrg	*.y)
224659607e0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225659607e0Smrg	    if test -f "$SRCFILE"; then
226659607e0Smrg	         cp "$SRCFILE" y.tab.c
227659607e0Smrg	    fi
228659607e0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229659607e0Smrg	    if test -f "$SRCFILE"; then
230659607e0Smrg	         cp "$SRCFILE" y.tab.h
231659607e0Smrg	    fi
232659607e0Smrg	  ;;
233659607e0Smrg	esac
234659607e0Smrg    fi
235659607e0Smrg    if test ! -f y.tab.h; then
236659607e0Smrg	echo >y.tab.h
237659607e0Smrg    fi
238659607e0Smrg    if test ! -f y.tab.c; then
239659607e0Smrg	echo 'main() { return 0; }' >y.tab.c
240659607e0Smrg    fi
241659607e0Smrg    ;;
242659607e0Smrg
243659607e0Smrg  lex|flex)
244659607e0Smrg    echo 1>&2 "\
245659607e0SmrgWARNING: \`$1' is $msg.  You should only need it if
246659607e0Smrg         you modified a \`.l' file.  You may need the \`Flex' package
247659607e0Smrg         in order for those modifications to take effect.  You can get
248659607e0Smrg         \`Flex' from any GNU archive site."
249659607e0Smrg    rm -f lex.yy.c
250659607e0Smrg    if test $# -ne 1; then
251659607e0Smrg        eval LASTARG="\${$#}"
252659607e0Smrg	case $LASTARG in
253659607e0Smrg	*.l)
254659607e0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255659607e0Smrg	    if test -f "$SRCFILE"; then
256659607e0Smrg	         cp "$SRCFILE" lex.yy.c
257659607e0Smrg	    fi
258659607e0Smrg	  ;;
259659607e0Smrg	esac
260659607e0Smrg    fi
261659607e0Smrg    if test ! -f lex.yy.c; then
262659607e0Smrg	echo 'main() { return 0; }' >lex.yy.c
263659607e0Smrg    fi
264659607e0Smrg    ;;
265659607e0Smrg
266659607e0Smrg  help2man)
267659607e0Smrg    echo 1>&2 "\
268659607e0SmrgWARNING: \`$1' is $msg.  You should only need it if
269659607e0Smrg	 you modified a dependency of a manual page.  You may need the
270659607e0Smrg	 \`Help2man' package in order for those modifications to take
271659607e0Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
272659607e0Smrg
273659607e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
274659607e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275659607e0Smrg    if test -f "$file"; then
276659607e0Smrg	touch $file
277659607e0Smrg    else
278659607e0Smrg	test -z "$file" || exec >$file
279659607e0Smrg	echo ".ab help2man is required to generate this page"
280659607e0Smrg	exit 1
281659607e0Smrg    fi
282659607e0Smrg    ;;
283659607e0Smrg
284659607e0Smrg  makeinfo)
285659607e0Smrg    echo 1>&2 "\
286659607e0SmrgWARNING: \`$1' is $msg.  You should only need it if
287659607e0Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
288659607e0Smrg         indirectly affecting the aspect of the manual.  The spurious
289659607e0Smrg         call might also be the consequence of using a buggy \`make' (AIX,
290659607e0Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
291659607e0Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
292659607e0Smrg    # The file to touch is that specified with -o ...
293659607e0Smrg    file=`echo "$*" | sed -n "$sed_output"`
294659607e0Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
295659607e0Smrg    if test -z "$file"; then
296659607e0Smrg      # ... or it is the one specified with @setfilename ...
297659607e0Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298659607e0Smrg      file=`sed -n '
299659607e0Smrg	/^@setfilename/{
300659607e0Smrg	  s/.* \([^ ]*\) *$/\1/
301659607e0Smrg	  p
302659607e0Smrg	  q
303659607e0Smrg	}' $infile`
304659607e0Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
305659607e0Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
306659607e0Smrg    fi
307659607e0Smrg    # If the file does not exist, the user really needs makeinfo;
308659607e0Smrg    # let's fail without touching anything.
309659607e0Smrg    test -f $file || exit 1
310659607e0Smrg    touch $file
311659607e0Smrg    ;;
312659607e0Smrg
313659607e0Smrg  tar)
314659607e0Smrg    shift
315659607e0Smrg
316659607e0Smrg    # We have already tried tar in the generic part.
317659607e0Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
318659607e0Smrg    # messages.
319659607e0Smrg    if (gnutar --version > /dev/null 2>&1); then
320659607e0Smrg       gnutar "$@" && exit 0
321659607e0Smrg    fi
322659607e0Smrg    if (gtar --version > /dev/null 2>&1); then
323659607e0Smrg       gtar "$@" && exit 0
324659607e0Smrg    fi
325659607e0Smrg    firstarg="$1"
326659607e0Smrg    if shift; then
327659607e0Smrg	case $firstarg in
328659607e0Smrg	*o*)
329659607e0Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
330659607e0Smrg	    tar "$firstarg" "$@" && exit 0
331659607e0Smrg	    ;;
332659607e0Smrg	esac
333659607e0Smrg	case $firstarg in
334659607e0Smrg	*h*)
335659607e0Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
336659607e0Smrg	    tar "$firstarg" "$@" && exit 0
337659607e0Smrg	    ;;
338659607e0Smrg	esac
339659607e0Smrg    fi
340659607e0Smrg
341659607e0Smrg    echo 1>&2 "\
342659607e0SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
343659607e0Smrg         You may want to install GNU tar or Free paxutils, or check the
344659607e0Smrg         command line arguments."
345659607e0Smrg    exit 1
346659607e0Smrg    ;;
347659607e0Smrg
348659607e0Smrg  *)
349659607e0Smrg    echo 1>&2 "\
350659607e0SmrgWARNING: \`$1' is needed, and is $msg.
351659607e0Smrg         You might have modified some files without having the
352659607e0Smrg         proper tools for further handling them.  Check the \`README' file,
353659607e0Smrg         it often tells you about the needed prerequisites for installing
354659607e0Smrg         this package.  You may also peek at any GNU archive site, in case
355659607e0Smrg         some other package would contain this missing \`$1' program."
356659607e0Smrg    exit 1
357659607e0Smrg    ;;
358659607e0Smrgesac
359659607e0Smrg
360659607e0Smrgexit 0
361659607e0Smrg
362659607e0Smrg# Local variables:
363659607e0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
364659607e0Smrg# time-stamp-start: "scriptversion="
365659607e0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
366659607e0Smrg# time-stamp-end: "$"
367659607e0Smrg# End:
368