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