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