missing revision b290cf36
1191cded7Smrg#! /bin/sh
2191cded7Smrg# Common stub for a few missing GNU programs while installing.
3191cded7Smrg
4b290cf36Smrgscriptversion=2006-05-10.23
5191cded7Smrg
6b290cf36Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
7191cded7Smrg#   Free Software Foundation, Inc.
8191cded7Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9191cded7Smrg
10191cded7Smrg# This program is free software; you can redistribute it and/or modify
11191cded7Smrg# it under the terms of the GNU General Public License as published by
12191cded7Smrg# the Free Software Foundation; either version 2, or (at your option)
13191cded7Smrg# any later version.
14191cded7Smrg
15191cded7Smrg# This program is distributed in the hope that it will be useful,
16191cded7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17191cded7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18191cded7Smrg# GNU General Public License for more details.
19191cded7Smrg
20191cded7Smrg# You should have received a copy of the GNU General Public License
21191cded7Smrg# along with this program; if not, write to the Free Software
22191cded7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23191cded7Smrg# 02110-1301, USA.
24191cded7Smrg
25191cded7Smrg# As a special exception to the GNU General Public License, if you
26191cded7Smrg# distribute this file as part of a program that contains a
27191cded7Smrg# configuration script generated by Autoconf, you may include it under
28191cded7Smrg# the same distribution terms that you use for the rest of that program.
29191cded7Smrg
30191cded7Smrgif test $# -eq 0; then
31191cded7Smrg  echo 1>&2 "Try \`$0 --help' for more information"
32191cded7Smrg  exit 1
33191cded7Smrgfi
34191cded7Smrg
35191cded7Smrgrun=:
36b290cf36Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37b290cf36Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
38191cded7Smrg
39191cded7Smrg# In the cases where this matters, `missing' is being run in the
40191cded7Smrg# srcdir already.
41191cded7Smrgif test -f configure.ac; then
42191cded7Smrg  configure_ac=configure.ac
43191cded7Smrgelse
44191cded7Smrg  configure_ac=configure.in
45191cded7Smrgfi
46191cded7Smrg
47191cded7Smrgmsg="missing on your system"
48191cded7Smrg
49b290cf36Smrgcase $1 in
50191cded7Smrg--run)
51191cded7Smrg  # Try to run requested program, and just exit if it succeeds.
52191cded7Smrg  run=
53191cded7Smrg  shift
54191cded7Smrg  "$@" && exit 0
55191cded7Smrg  # Exit code 63 means version mismatch.  This often happens
56191cded7Smrg  # when the user try to use an ancient version of a tool on
57191cded7Smrg  # a file that requires a minimum version.  In this case we
58191cded7Smrg  # we should proceed has if the program had been absent, or
59191cded7Smrg  # if --run hadn't been passed.
60191cded7Smrg  if test $? = 63; then
61191cded7Smrg    run=:
62191cded7Smrg    msg="probably too old"
63191cded7Smrg  fi
64191cded7Smrg  ;;
65191cded7Smrg
66191cded7Smrg  -h|--h|--he|--hel|--help)
67191cded7Smrg    echo "\
68191cded7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
69191cded7Smrg
70191cded7SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
71191cded7Smrgerror status if there is no known handling for PROGRAM.
72191cded7Smrg
73191cded7SmrgOptions:
74191cded7Smrg  -h, --help      display this help and exit
75191cded7Smrg  -v, --version   output version information and exit
76191cded7Smrg  --run           try to run the given command, and emulate it if it fails
77191cded7Smrg
78191cded7SmrgSupported PROGRAM values:
79191cded7Smrg  aclocal      touch file \`aclocal.m4'
80191cded7Smrg  autoconf     touch file \`configure'
81191cded7Smrg  autoheader   touch file \`config.h.in'
82b290cf36Smrg  autom4te     touch the output file, or create a stub one
83191cded7Smrg  automake     touch all \`Makefile.in' files
84191cded7Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
85191cded7Smrg  flex         create \`lex.yy.c', if possible, from existing .c
86191cded7Smrg  help2man     touch the output file
87191cded7Smrg  lex          create \`lex.yy.c', if possible, from existing .c
88191cded7Smrg  makeinfo     touch the output file
89191cded7Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
90191cded7Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
91191cded7Smrg
92191cded7SmrgSend bug reports to <bug-automake@gnu.org>."
93191cded7Smrg    exit $?
94191cded7Smrg    ;;
95191cded7Smrg
96191cded7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
97191cded7Smrg    echo "missing $scriptversion (GNU Automake)"
98191cded7Smrg    exit $?
99191cded7Smrg    ;;
100191cded7Smrg
101191cded7Smrg  -*)
102191cded7Smrg    echo 1>&2 "$0: Unknown \`$1' option"
103191cded7Smrg    echo 1>&2 "Try \`$0 --help' for more information"
104191cded7Smrg    exit 1
105191cded7Smrg    ;;
106191cded7Smrg
107191cded7Smrgesac
108191cded7Smrg
109191cded7Smrg# Now exit if we have it, but it failed.  Also exit now if we
110191cded7Smrg# don't have it and --version was passed (most likely to detect
111191cded7Smrg# the program).
112b290cf36Smrgcase $1 in
113191cded7Smrg  lex|yacc)
114191cded7Smrg    # Not GNU programs, they don't have --version.
115191cded7Smrg    ;;
116191cded7Smrg
117191cded7Smrg  tar)
118191cded7Smrg    if test -n "$run"; then
119191cded7Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
120191cded7Smrg       exit 1
121191cded7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
122191cded7Smrg       exit 1
123191cded7Smrg    fi
124191cded7Smrg    ;;
125191cded7Smrg
126191cded7Smrg  *)
127191cded7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
128191cded7Smrg       # We have it, but it failed.
129191cded7Smrg       exit 1
130191cded7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
131191cded7Smrg       # Could not run --version or --help.  This is probably someone
132191cded7Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
133191cded7Smrg       # $TOOL exists and not knowing $TOOL uses missing.
134191cded7Smrg       exit 1
135191cded7Smrg    fi
136191cded7Smrg    ;;
137191cded7Smrgesac
138191cded7Smrg
139191cded7Smrg# If it does not exist, or fails to run (possibly an outdated version),
140191cded7Smrg# try to emulate it.
141b290cf36Smrgcase $1 in
142191cded7Smrg  aclocal*)
143191cded7Smrg    echo 1>&2 "\
144191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
145191cded7Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
146191cded7Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
147191cded7Smrg         any GNU archive site."
148191cded7Smrg    touch aclocal.m4
149191cded7Smrg    ;;
150191cded7Smrg
151191cded7Smrg  autoconf)
152191cded7Smrg    echo 1>&2 "\
153191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
154191cded7Smrg         you modified \`${configure_ac}'.  You might want to install the
155191cded7Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
156191cded7Smrg         archive site."
157191cded7Smrg    touch configure
158191cded7Smrg    ;;
159191cded7Smrg
160191cded7Smrg  autoheader)
161191cded7Smrg    echo 1>&2 "\
162191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
163191cded7Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
164191cded7Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
165191cded7Smrg         from any GNU archive site."
166191cded7Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
167191cded7Smrg    test -z "$files" && files="config.h"
168191cded7Smrg    touch_files=
169191cded7Smrg    for f in $files; do
170b290cf36Smrg      case $f in
171191cded7Smrg      *:*) touch_files="$touch_files "`echo "$f" |
172191cded7Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
173191cded7Smrg      *) touch_files="$touch_files $f.in";;
174191cded7Smrg      esac
175191cded7Smrg    done
176191cded7Smrg    touch $touch_files
177191cded7Smrg    ;;
178191cded7Smrg
179191cded7Smrg  automake*)
180191cded7Smrg    echo 1>&2 "\
181191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
182191cded7Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
183191cded7Smrg         You might want to install the \`Automake' and \`Perl' packages.
184191cded7Smrg         Grab them from any GNU archive site."
185191cded7Smrg    find . -type f -name Makefile.am -print |
186191cded7Smrg	   sed 's/\.am$/.in/' |
187191cded7Smrg	   while read f; do touch "$f"; done
188191cded7Smrg    ;;
189191cded7Smrg
190191cded7Smrg  autom4te)
191191cded7Smrg    echo 1>&2 "\
192191cded7SmrgWARNING: \`$1' is needed, but is $msg.
193191cded7Smrg         You might have modified some files without having the
194191cded7Smrg         proper tools for further handling them.
195191cded7Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
196191cded7Smrg         archive site."
197191cded7Smrg
198b290cf36Smrg    file=`echo "$*" | sed -n "$sed_output"`
199b290cf36Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
200191cded7Smrg    if test -f "$file"; then
201191cded7Smrg	touch $file
202191cded7Smrg    else
203191cded7Smrg	test -z "$file" || exec >$file
204191cded7Smrg	echo "#! /bin/sh"
205191cded7Smrg	echo "# Created by GNU Automake missing as a replacement of"
206191cded7Smrg	echo "#  $ $@"
207191cded7Smrg	echo "exit 0"
208191cded7Smrg	chmod +x $file
209191cded7Smrg	exit 1
210191cded7Smrg    fi
211191cded7Smrg    ;;
212191cded7Smrg
213191cded7Smrg  bison|yacc)
214191cded7Smrg    echo 1>&2 "\
215191cded7SmrgWARNING: \`$1' $msg.  You should only need it if
216191cded7Smrg         you modified a \`.y' file.  You may need the \`Bison' package
217191cded7Smrg         in order for those modifications to take effect.  You can get
218191cded7Smrg         \`Bison' from any GNU archive site."
219191cded7Smrg    rm -f y.tab.c y.tab.h
220b290cf36Smrg    if test $# -ne 1; then
221191cded7Smrg        eval LASTARG="\${$#}"
222b290cf36Smrg	case $LASTARG in
223191cded7Smrg	*.y)
224191cded7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225b290cf36Smrg	    if test -f "$SRCFILE"; then
226191cded7Smrg	         cp "$SRCFILE" y.tab.c
227191cded7Smrg	    fi
228191cded7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229b290cf36Smrg	    if test -f "$SRCFILE"; then
230191cded7Smrg	         cp "$SRCFILE" y.tab.h
231191cded7Smrg	    fi
232191cded7Smrg	  ;;
233191cded7Smrg	esac
234191cded7Smrg    fi
235b290cf36Smrg    if test ! -f y.tab.h; then
236191cded7Smrg	echo >y.tab.h
237191cded7Smrg    fi
238b290cf36Smrg    if test ! -f y.tab.c; then
239191cded7Smrg	echo 'main() { return 0; }' >y.tab.c
240191cded7Smrg    fi
241191cded7Smrg    ;;
242191cded7Smrg
243191cded7Smrg  lex|flex)
244191cded7Smrg    echo 1>&2 "\
245191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
246191cded7Smrg         you modified a \`.l' file.  You may need the \`Flex' package
247191cded7Smrg         in order for those modifications to take effect.  You can get
248191cded7Smrg         \`Flex' from any GNU archive site."
249191cded7Smrg    rm -f lex.yy.c
250b290cf36Smrg    if test $# -ne 1; then
251191cded7Smrg        eval LASTARG="\${$#}"
252b290cf36Smrg	case $LASTARG in
253191cded7Smrg	*.l)
254191cded7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255b290cf36Smrg	    if test -f "$SRCFILE"; then
256191cded7Smrg	         cp "$SRCFILE" lex.yy.c
257191cded7Smrg	    fi
258191cded7Smrg	  ;;
259191cded7Smrg	esac
260191cded7Smrg    fi
261b290cf36Smrg    if test ! -f lex.yy.c; then
262191cded7Smrg	echo 'main() { return 0; }' >lex.yy.c
263191cded7Smrg    fi
264191cded7Smrg    ;;
265191cded7Smrg
266191cded7Smrg  help2man)
267191cded7Smrg    echo 1>&2 "\
268191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
269191cded7Smrg	 you modified a dependency of a manual page.  You may need the
270191cded7Smrg	 \`Help2man' package in order for those modifications to take
271191cded7Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
272191cded7Smrg
273b290cf36Smrg    file=`echo "$*" | sed -n "$sed_output"`
274b290cf36Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275b290cf36Smrg    if test -f "$file"; then
276191cded7Smrg	touch $file
277191cded7Smrg    else
278191cded7Smrg	test -z "$file" || exec >$file
279191cded7Smrg	echo ".ab help2man is required to generate this page"
280191cded7Smrg	exit 1
281191cded7Smrg    fi
282191cded7Smrg    ;;
283191cded7Smrg
284191cded7Smrg  makeinfo)
285191cded7Smrg    echo 1>&2 "\
286191cded7SmrgWARNING: \`$1' is $msg.  You should only need it if
287191cded7Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
288191cded7Smrg         indirectly affecting the aspect of the manual.  The spurious
289191cded7Smrg         call might also be the consequence of using a buggy \`make' (AIX,
290191cded7Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
291191cded7Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
292191cded7Smrg    # The file to touch is that specified with -o ...
293b290cf36Smrg    file=`echo "$*" | sed -n "$sed_output"`
294b290cf36Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
295191cded7Smrg    if test -z "$file"; then
296191cded7Smrg      # ... or it is the one specified with @setfilename ...
297191cded7Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298b290cf36Smrg      file=`sed -n '
299b290cf36Smrg	/^@setfilename/{
300b290cf36Smrg	  s/.* \([^ ]*\) *$/\1/
301b290cf36Smrg	  p
302b290cf36Smrg	  q
303b290cf36Smrg	}' $infile`
304191cded7Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
305191cded7Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
306191cded7Smrg    fi
307191cded7Smrg    # If the file does not exist, the user really needs makeinfo;
308191cded7Smrg    # let's fail without touching anything.
309191cded7Smrg    test -f $file || exit 1
310191cded7Smrg    touch $file
311191cded7Smrg    ;;
312191cded7Smrg
313191cded7Smrg  tar)
314191cded7Smrg    shift
315191cded7Smrg
316191cded7Smrg    # We have already tried tar in the generic part.
317191cded7Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
318191cded7Smrg    # messages.
319191cded7Smrg    if (gnutar --version > /dev/null 2>&1); then
320191cded7Smrg       gnutar "$@" && exit 0
321191cded7Smrg    fi
322191cded7Smrg    if (gtar --version > /dev/null 2>&1); then
323191cded7Smrg       gtar "$@" && exit 0
324191cded7Smrg    fi
325191cded7Smrg    firstarg="$1"
326191cded7Smrg    if shift; then
327b290cf36Smrg	case $firstarg in
328191cded7Smrg	*o*)
329191cded7Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
330191cded7Smrg	    tar "$firstarg" "$@" && exit 0
331191cded7Smrg	    ;;
332191cded7Smrg	esac
333b290cf36Smrg	case $firstarg in
334191cded7Smrg	*h*)
335191cded7Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
336191cded7Smrg	    tar "$firstarg" "$@" && exit 0
337191cded7Smrg	    ;;
338191cded7Smrg	esac
339191cded7Smrg    fi
340191cded7Smrg
341191cded7Smrg    echo 1>&2 "\
342191cded7SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
343191cded7Smrg         You may want to install GNU tar or Free paxutils, or check the
344191cded7Smrg         command line arguments."
345191cded7Smrg    exit 1
346191cded7Smrg    ;;
347191cded7Smrg
348191cded7Smrg  *)
349191cded7Smrg    echo 1>&2 "\
350191cded7SmrgWARNING: \`$1' is needed, and is $msg.
351191cded7Smrg         You might have modified some files without having the
352191cded7Smrg         proper tools for further handling them.  Check the \`README' file,
353191cded7Smrg         it often tells you about the needed prerequisites for installing
354191cded7Smrg         this package.  You may also peek at any GNU archive site, in case
355191cded7Smrg         some other package would contain this missing \`$1' program."
356191cded7Smrg    exit 1
357191cded7Smrg    ;;
358191cded7Smrgesac
359191cded7Smrg
360191cded7Smrgexit 0
361191cded7Smrg
362191cded7Smrg# Local variables:
363191cded7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
364191cded7Smrg# time-stamp-start: "scriptversion="
365191cded7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
366191cded7Smrg# time-stamp-end: "$"
367191cded7Smrg# End:
368