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