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