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