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