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