missing revision 129be1b7
1129be1b7Smrg#! /bin/sh
2129be1b7Smrg# Common stub for a few missing GNU programs while installing.
3129be1b7Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
4129be1b7Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
5129be1b7Smrg
6129be1b7Smrg# This program is free software; you can redistribute it and/or modify
7129be1b7Smrg# it under the terms of the GNU General Public License as published by
8129be1b7Smrg# the Free Software Foundation; either version 2, or (at your option)
9129be1b7Smrg# any later version.
10129be1b7Smrg
11129be1b7Smrg# This program is distributed in the hope that it will be useful,
12129be1b7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13129be1b7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14129be1b7Smrg# GNU General Public License for more details.
15129be1b7Smrg
16129be1b7Smrg# You should have received a copy of the GNU General Public License
17129be1b7Smrg# along with this program; if not, write to the Free Software
18129be1b7Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19129be1b7Smrg# 02111-1307, USA.
20129be1b7Smrg
21129be1b7Smrg# As a special exception to the GNU General Public License, if you
22129be1b7Smrg# distribute this file as part of a program that contains a
23129be1b7Smrg# configuration script generated by Autoconf, you may include it under
24129be1b7Smrg# the same distribution terms that you use for the rest of that program.
25129be1b7Smrg
26129be1b7Smrgif test $# -eq 0; then
27129be1b7Smrg  echo 1>&2 "Try \`$0 --help' for more information"
28129be1b7Smrg  exit 1
29129be1b7Smrgfi
30129be1b7Smrg
31129be1b7Smrgrun=:
32129be1b7Smrg
33129be1b7Smrg# In the cases where this matters, `missing' is being run in the
34129be1b7Smrg# srcdir already.
35129be1b7Smrgif test -f configure.ac; then
36129be1b7Smrg  configure_ac=configure.ac
37129be1b7Smrgelse
38129be1b7Smrg  configure_ac=configure.in
39129be1b7Smrgfi
40129be1b7Smrg
41129be1b7Smrgcase "$1" in
42129be1b7Smrg--run)
43129be1b7Smrg  # Try to run requested program, and just exit if it succeeds.
44129be1b7Smrg  run=
45129be1b7Smrg  shift
46129be1b7Smrg  "$@" && exit 0
47129be1b7Smrg  ;;
48129be1b7Smrgesac
49129be1b7Smrg
50129be1b7Smrg# If it does not exist, or fails to run (possibly an outdated version),
51129be1b7Smrg# try to emulate it.
52129be1b7Smrgcase "$1" in
53129be1b7Smrg
54129be1b7Smrg  -h|--h|--he|--hel|--help)
55129be1b7Smrg    echo "\
56129be1b7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
57129be1b7Smrg
58129be1b7SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
59129be1b7Smrgerror status if there is no known handling for PROGRAM.
60129be1b7Smrg
61129be1b7SmrgOptions:
62129be1b7Smrg  -h, --help      display this help and exit
63129be1b7Smrg  -v, --version   output version information and exit
64129be1b7Smrg  --run           try to run the given command, and emulate it if it fails
65129be1b7Smrg
66129be1b7SmrgSupported PROGRAM values:
67129be1b7Smrg  aclocal      touch file \`aclocal.m4'
68129be1b7Smrg  autoconf     touch file \`configure'
69129be1b7Smrg  autoheader   touch file \`config.h.in'
70129be1b7Smrg  automake     touch all \`Makefile.in' files
71129be1b7Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
72129be1b7Smrg  flex         create \`lex.yy.c', if possible, from existing .c
73129be1b7Smrg  help2man     touch the output file
74129be1b7Smrg  lex          create \`lex.yy.c', if possible, from existing .c
75129be1b7Smrg  makeinfo     touch the output file
76129be1b7Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
77129be1b7Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
78129be1b7Smrg    ;;
79129be1b7Smrg
80129be1b7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
81129be1b7Smrg    echo "missing 0.4 - GNU automake"
82129be1b7Smrg    ;;
83129be1b7Smrg
84129be1b7Smrg  -*)
85129be1b7Smrg    echo 1>&2 "$0: Unknown \`$1' option"
86129be1b7Smrg    echo 1>&2 "Try \`$0 --help' for more information"
87129be1b7Smrg    exit 1
88129be1b7Smrg    ;;
89129be1b7Smrg
90129be1b7Smrg  aclocal*)
91129be1b7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
92129be1b7Smrg       # We have it, but it failed.
93129be1b7Smrg       exit 1
94129be1b7Smrg    fi
95129be1b7Smrg
96129be1b7Smrg    echo 1>&2 "\
97129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
98129be1b7Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
99129be1b7Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
100129be1b7Smrg         any GNU archive site."
101129be1b7Smrg    touch aclocal.m4
102129be1b7Smrg    ;;
103129be1b7Smrg
104129be1b7Smrg  autoconf)
105129be1b7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
106129be1b7Smrg       # We have it, but it failed.
107129be1b7Smrg       exit 1
108129be1b7Smrg    fi
109129be1b7Smrg
110129be1b7Smrg    echo 1>&2 "\
111129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
112129be1b7Smrg         you modified \`${configure_ac}'.  You might want to install the
113129be1b7Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
114129be1b7Smrg         archive site."
115129be1b7Smrg    touch configure
116129be1b7Smrg    ;;
117129be1b7Smrg
118129be1b7Smrg  autoheader)
119129be1b7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
120129be1b7Smrg       # We have it, but it failed.
121129be1b7Smrg       exit 1
122129be1b7Smrg    fi
123129be1b7Smrg
124129be1b7Smrg    echo 1>&2 "\
125129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
126129be1b7Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
127129be1b7Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
128129be1b7Smrg         from any GNU archive site."
129129be1b7Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
130129be1b7Smrg    test -z "$files" && files="config.h"
131129be1b7Smrg    touch_files=
132129be1b7Smrg    for f in $files; do
133129be1b7Smrg      case "$f" in
134129be1b7Smrg      *:*) touch_files="$touch_files "`echo "$f" |
135129be1b7Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
136129be1b7Smrg      *) touch_files="$touch_files $f.in";;
137129be1b7Smrg      esac
138129be1b7Smrg    done
139129be1b7Smrg    touch $touch_files
140129be1b7Smrg    ;;
141129be1b7Smrg
142129be1b7Smrg  automake*)
143129be1b7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
144129be1b7Smrg       # We have it, but it failed.
145129be1b7Smrg       exit 1
146129be1b7Smrg    fi
147129be1b7Smrg
148129be1b7Smrg    echo 1>&2 "\
149129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
150129be1b7Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
151129be1b7Smrg         You might want to install the \`Automake' and \`Perl' packages.
152129be1b7Smrg         Grab them from any GNU archive site."
153129be1b7Smrg    find . -type f -name Makefile.am -print |
154129be1b7Smrg	   sed 's/\.am$/.in/' |
155129be1b7Smrg	   while read f; do touch "$f"; done
156129be1b7Smrg    ;;
157129be1b7Smrg
158129be1b7Smrg  autom4te)
159129be1b7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
160129be1b7Smrg       # We have it, but it failed.
161129be1b7Smrg       exit 1
162129be1b7Smrg    fi
163129be1b7Smrg
164129be1b7Smrg    echo 1>&2 "\
165129be1b7SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
166129be1b7Smrg         system.  You might have modified some files without having the
167129be1b7Smrg         proper tools for further handling them.
168129be1b7Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
169129be1b7Smrg         archive site."
170129be1b7Smrg
171129be1b7Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
172129be1b7Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
173129be1b7Smrg    if test -f "$file"; then
174129be1b7Smrg	touch $file
175129be1b7Smrg    else
176129be1b7Smrg	test -z "$file" || exec >$file
177129be1b7Smrg	echo "#! /bin/sh"
178129be1b7Smrg	echo "# Created by GNU Automake missing as a replacement of"
179129be1b7Smrg	echo "#  $ $@"
180129be1b7Smrg	echo "exit 0"
181129be1b7Smrg	chmod +x $file
182129be1b7Smrg	exit 1
183129be1b7Smrg    fi
184129be1b7Smrg    ;;
185129be1b7Smrg
186129be1b7Smrg  bison|yacc)
187129be1b7Smrg    echo 1>&2 "\
188129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
189129be1b7Smrg         you modified a \`.y' file.  You may need the \`Bison' package
190129be1b7Smrg         in order for those modifications to take effect.  You can get
191129be1b7Smrg         \`Bison' from any GNU archive site."
192129be1b7Smrg    rm -f y.tab.c y.tab.h
193129be1b7Smrg    if [ $# -ne 1 ]; then
194129be1b7Smrg        eval LASTARG="\${$#}"
195129be1b7Smrg	case "$LASTARG" in
196129be1b7Smrg	*.y)
197129be1b7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
198129be1b7Smrg	    if [ -f "$SRCFILE" ]; then
199129be1b7Smrg	         cp "$SRCFILE" y.tab.c
200129be1b7Smrg	    fi
201129be1b7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
202129be1b7Smrg	    if [ -f "$SRCFILE" ]; then
203129be1b7Smrg	         cp "$SRCFILE" y.tab.h
204129be1b7Smrg	    fi
205129be1b7Smrg	  ;;
206129be1b7Smrg	esac
207129be1b7Smrg    fi
208129be1b7Smrg    if [ ! -f y.tab.h ]; then
209129be1b7Smrg	echo >y.tab.h
210129be1b7Smrg    fi
211129be1b7Smrg    if [ ! -f y.tab.c ]; then
212129be1b7Smrg	echo 'main() { return 0; }' >y.tab.c
213129be1b7Smrg    fi
214129be1b7Smrg    ;;
215129be1b7Smrg
216129be1b7Smrg  lex|flex)
217129be1b7Smrg    echo 1>&2 "\
218129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
219129be1b7Smrg         you modified a \`.l' file.  You may need the \`Flex' package
220129be1b7Smrg         in order for those modifications to take effect.  You can get
221129be1b7Smrg         \`Flex' from any GNU archive site."
222129be1b7Smrg    rm -f lex.yy.c
223129be1b7Smrg    if [ $# -ne 1 ]; then
224129be1b7Smrg        eval LASTARG="\${$#}"
225129be1b7Smrg	case "$LASTARG" in
226129be1b7Smrg	*.l)
227129be1b7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
228129be1b7Smrg	    if [ -f "$SRCFILE" ]; then
229129be1b7Smrg	         cp "$SRCFILE" lex.yy.c
230129be1b7Smrg	    fi
231129be1b7Smrg	  ;;
232129be1b7Smrg	esac
233129be1b7Smrg    fi
234129be1b7Smrg    if [ ! -f lex.yy.c ]; then
235129be1b7Smrg	echo 'main() { return 0; }' >lex.yy.c
236129be1b7Smrg    fi
237129be1b7Smrg    ;;
238129be1b7Smrg
239129be1b7Smrg  help2man)
240129be1b7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
241129be1b7Smrg       # We have it, but it failed.
242129be1b7Smrg       exit 1
243129be1b7Smrg    fi
244129be1b7Smrg
245129be1b7Smrg    echo 1>&2 "\
246129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
247129be1b7Smrg	 you modified a dependency of a manual page.  You may need the
248129be1b7Smrg	 \`Help2man' package in order for those modifications to take
249129be1b7Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
250129be1b7Smrg
251129be1b7Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
252129be1b7Smrg    if test -z "$file"; then
253129be1b7Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
254129be1b7Smrg    fi
255129be1b7Smrg    if [ -f "$file" ]; then
256129be1b7Smrg	touch $file
257129be1b7Smrg    else
258129be1b7Smrg	test -z "$file" || exec >$file
259129be1b7Smrg	echo ".ab help2man is required to generate this page"
260129be1b7Smrg	exit 1
261129be1b7Smrg    fi
262129be1b7Smrg    ;;
263129be1b7Smrg
264129be1b7Smrg  makeinfo)
265129be1b7Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
266129be1b7Smrg       # We have makeinfo, but it failed.
267129be1b7Smrg       exit 1
268129be1b7Smrg    fi
269129be1b7Smrg
270129be1b7Smrg    echo 1>&2 "\
271129be1b7SmrgWARNING: \`$1' is missing on your system.  You should only need it if
272129be1b7Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
273129be1b7Smrg         indirectly affecting the aspect of the manual.  The spurious
274129be1b7Smrg         call might also be the consequence of using a buggy \`make' (AIX,
275129be1b7Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
276129be1b7Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
277129be1b7Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
278129be1b7Smrg    if test -z "$file"; then
279129be1b7Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
280129be1b7Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
281129be1b7Smrg    fi
282129be1b7Smrg    touch $file
283129be1b7Smrg    ;;
284129be1b7Smrg
285129be1b7Smrg  tar)
286129be1b7Smrg    shift
287129be1b7Smrg    if test -n "$run"; then
288129be1b7Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
289129be1b7Smrg      exit 1
290129be1b7Smrg    fi
291129be1b7Smrg
292129be1b7Smrg    # We have already tried tar in the generic part.
293129be1b7Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
294129be1b7Smrg    # messages.
295129be1b7Smrg    if (gnutar --version > /dev/null 2>&1); then
296129be1b7Smrg       gnutar "$@" && exit 0
297129be1b7Smrg    fi
298129be1b7Smrg    if (gtar --version > /dev/null 2>&1); then
299129be1b7Smrg       gtar "$@" && exit 0
300129be1b7Smrg    fi
301129be1b7Smrg    firstarg="$1"
302129be1b7Smrg    if shift; then
303129be1b7Smrg	case "$firstarg" in
304129be1b7Smrg	*o*)
305129be1b7Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
306129be1b7Smrg	    tar "$firstarg" "$@" && exit 0
307129be1b7Smrg	    ;;
308129be1b7Smrg	esac
309129be1b7Smrg	case "$firstarg" in
310129be1b7Smrg	*h*)
311129be1b7Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
312129be1b7Smrg	    tar "$firstarg" "$@" && exit 0
313129be1b7Smrg	    ;;
314129be1b7Smrg	esac
315129be1b7Smrg    fi
316129be1b7Smrg
317129be1b7Smrg    echo 1>&2 "\
318129be1b7SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
319129be1b7Smrg         You may want to install GNU tar or Free paxutils, or check the
320129be1b7Smrg         command line arguments."
321129be1b7Smrg    exit 1
322129be1b7Smrg    ;;
323129be1b7Smrg
324129be1b7Smrg  *)
325129be1b7Smrg    echo 1>&2 "\
326129be1b7SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
327129be1b7Smrg         system.  You might have modified some files without having the
328129be1b7Smrg         proper tools for further handling them.  Check the \`README' file,
329129be1b7Smrg         it often tells you about the needed prerequisites for installing
330129be1b7Smrg         this package.  You may also peek at any GNU archive site, in case
331129be1b7Smrg         some other package would contain this missing \`$1' program."
332129be1b7Smrg    exit 1
333129be1b7Smrg    ;;
334129be1b7Smrgesac
335129be1b7Smrg
336129be1b7Smrgexit 0
337