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