missing revision 264fa531
1264fa531Smrg#! /bin/sh
2264fa531Smrg# Common stub for a few missing GNU programs while installing.
3264fa531Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
4264fa531Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
5264fa531Smrg
6264fa531Smrg# This program is free software; you can redistribute it and/or modify
7264fa531Smrg# it under the terms of the GNU General Public License as published by
8264fa531Smrg# the Free Software Foundation; either version 2, or (at your option)
9264fa531Smrg# any later version.
10264fa531Smrg
11264fa531Smrg# This program is distributed in the hope that it will be useful,
12264fa531Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13264fa531Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14264fa531Smrg# GNU General Public License for more details.
15264fa531Smrg
16264fa531Smrg# You should have received a copy of the GNU General Public License
17264fa531Smrg# along with this program; if not, write to the Free Software
18264fa531Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19264fa531Smrg# 02111-1307, USA.
20264fa531Smrg
21264fa531Smrg# As a special exception to the GNU General Public License, if you
22264fa531Smrg# distribute this file as part of a program that contains a
23264fa531Smrg# configuration script generated by Autoconf, you may include it under
24264fa531Smrg# the same distribution terms that you use for the rest of that program.
25264fa531Smrg
26264fa531Smrgif test $# -eq 0; then
27264fa531Smrg  echo 1>&2 "Try \`$0 --help' for more information"
28264fa531Smrg  exit 1
29264fa531Smrgfi
30264fa531Smrg
31264fa531Smrgrun=:
32264fa531Smrg
33264fa531Smrg# In the cases where this matters, `missing' is being run in the
34264fa531Smrg# srcdir already.
35264fa531Smrgif test -f configure.ac; then
36264fa531Smrg  configure_ac=configure.ac
37264fa531Smrgelse
38264fa531Smrg  configure_ac=configure.in
39264fa531Smrgfi
40264fa531Smrg
41264fa531Smrgcase "$1" in
42264fa531Smrg--run)
43264fa531Smrg  # Try to run requested program, and just exit if it succeeds.
44264fa531Smrg  run=
45264fa531Smrg  shift
46264fa531Smrg  "$@" && exit 0
47264fa531Smrg  ;;
48264fa531Smrgesac
49264fa531Smrg
50264fa531Smrg# If it does not exist, or fails to run (possibly an outdated version),
51264fa531Smrg# try to emulate it.
52264fa531Smrgcase "$1" in
53264fa531Smrg
54264fa531Smrg  -h|--h|--he|--hel|--help)
55264fa531Smrg    echo "\
56264fa531Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
57264fa531Smrg
58264fa531SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
59264fa531Smrgerror status if there is no known handling for PROGRAM.
60264fa531Smrg
61264fa531SmrgOptions:
62264fa531Smrg  -h, --help      display this help and exit
63264fa531Smrg  -v, --version   output version information and exit
64264fa531Smrg  --run           try to run the given command, and emulate it if it fails
65264fa531Smrg
66264fa531SmrgSupported PROGRAM values:
67264fa531Smrg  aclocal      touch file \`aclocal.m4'
68264fa531Smrg  autoconf     touch file \`configure'
69264fa531Smrg  autoheader   touch file \`config.h.in'
70264fa531Smrg  automake     touch all \`Makefile.in' files
71264fa531Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
72264fa531Smrg  flex         create \`lex.yy.c', if possible, from existing .c
73264fa531Smrg  help2man     touch the output file
74264fa531Smrg  lex          create \`lex.yy.c', if possible, from existing .c
75264fa531Smrg  makeinfo     touch the output file
76264fa531Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
77264fa531Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
78264fa531Smrg    ;;
79264fa531Smrg
80264fa531Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
81264fa531Smrg    echo "missing 0.4 - GNU automake"
82264fa531Smrg    ;;
83264fa531Smrg
84264fa531Smrg  -*)
85264fa531Smrg    echo 1>&2 "$0: Unknown \`$1' option"
86264fa531Smrg    echo 1>&2 "Try \`$0 --help' for more information"
87264fa531Smrg    exit 1
88264fa531Smrg    ;;
89264fa531Smrg
90264fa531Smrg  aclocal*)
91264fa531Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
92264fa531Smrg       # We have it, but it failed.
93264fa531Smrg       exit 1
94264fa531Smrg    fi
95264fa531Smrg
96264fa531Smrg    echo 1>&2 "\
97264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
98264fa531Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
99264fa531Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
100264fa531Smrg         any GNU archive site."
101264fa531Smrg    touch aclocal.m4
102264fa531Smrg    ;;
103264fa531Smrg
104264fa531Smrg  autoconf)
105264fa531Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
106264fa531Smrg       # We have it, but it failed.
107264fa531Smrg       exit 1
108264fa531Smrg    fi
109264fa531Smrg
110264fa531Smrg    echo 1>&2 "\
111264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
112264fa531Smrg         you modified \`${configure_ac}'.  You might want to install the
113264fa531Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
114264fa531Smrg         archive site."
115264fa531Smrg    touch configure
116264fa531Smrg    ;;
117264fa531Smrg
118264fa531Smrg  autoheader)
119264fa531Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
120264fa531Smrg       # We have it, but it failed.
121264fa531Smrg       exit 1
122264fa531Smrg    fi
123264fa531Smrg
124264fa531Smrg    echo 1>&2 "\
125264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
126264fa531Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
127264fa531Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
128264fa531Smrg         from any GNU archive site."
129264fa531Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
130264fa531Smrg    test -z "$files" && files="config.h"
131264fa531Smrg    touch_files=
132264fa531Smrg    for f in $files; do
133264fa531Smrg      case "$f" in
134264fa531Smrg      *:*) touch_files="$touch_files "`echo "$f" |
135264fa531Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
136264fa531Smrg      *) touch_files="$touch_files $f.in";;
137264fa531Smrg      esac
138264fa531Smrg    done
139264fa531Smrg    touch $touch_files
140264fa531Smrg    ;;
141264fa531Smrg
142264fa531Smrg  automake*)
143264fa531Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
144264fa531Smrg       # We have it, but it failed.
145264fa531Smrg       exit 1
146264fa531Smrg    fi
147264fa531Smrg
148264fa531Smrg    echo 1>&2 "\
149264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
150264fa531Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
151264fa531Smrg         You might want to install the \`Automake' and \`Perl' packages.
152264fa531Smrg         Grab them from any GNU archive site."
153264fa531Smrg    find . -type f -name Makefile.am -print |
154264fa531Smrg	   sed 's/\.am$/.in/' |
155264fa531Smrg	   while read f; do touch "$f"; done
156264fa531Smrg    ;;
157264fa531Smrg
158264fa531Smrg  autom4te)
159264fa531Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
160264fa531Smrg       # We have it, but it failed.
161264fa531Smrg       exit 1
162264fa531Smrg    fi
163264fa531Smrg
164264fa531Smrg    echo 1>&2 "\
165264fa531SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
166264fa531Smrg         system.  You might have modified some files without having the
167264fa531Smrg         proper tools for further handling them.
168264fa531Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
169264fa531Smrg         archive site."
170264fa531Smrg
171264fa531Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
172264fa531Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
173264fa531Smrg    if test -f "$file"; then
174264fa531Smrg	touch $file
175264fa531Smrg    else
176264fa531Smrg	test -z "$file" || exec >$file
177264fa531Smrg	echo "#! /bin/sh"
178264fa531Smrg	echo "# Created by GNU Automake missing as a replacement of"
179264fa531Smrg	echo "#  $ $@"
180264fa531Smrg	echo "exit 0"
181264fa531Smrg	chmod +x $file
182264fa531Smrg	exit 1
183264fa531Smrg    fi
184264fa531Smrg    ;;
185264fa531Smrg
186264fa531Smrg  bison|yacc)
187264fa531Smrg    echo 1>&2 "\
188264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
189264fa531Smrg         you modified a \`.y' file.  You may need the \`Bison' package
190264fa531Smrg         in order for those modifications to take effect.  You can get
191264fa531Smrg         \`Bison' from any GNU archive site."
192264fa531Smrg    rm -f y.tab.c y.tab.h
193264fa531Smrg    if [ $# -ne 1 ]; then
194264fa531Smrg        eval LASTARG="\${$#}"
195264fa531Smrg	case "$LASTARG" in
196264fa531Smrg	*.y)
197264fa531Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
198264fa531Smrg	    if [ -f "$SRCFILE" ]; then
199264fa531Smrg	         cp "$SRCFILE" y.tab.c
200264fa531Smrg	    fi
201264fa531Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
202264fa531Smrg	    if [ -f "$SRCFILE" ]; then
203264fa531Smrg	         cp "$SRCFILE" y.tab.h
204264fa531Smrg	    fi
205264fa531Smrg	  ;;
206264fa531Smrg	esac
207264fa531Smrg    fi
208264fa531Smrg    if [ ! -f y.tab.h ]; then
209264fa531Smrg	echo >y.tab.h
210264fa531Smrg    fi
211264fa531Smrg    if [ ! -f y.tab.c ]; then
212264fa531Smrg	echo 'main() { return 0; }' >y.tab.c
213264fa531Smrg    fi
214264fa531Smrg    ;;
215264fa531Smrg
216264fa531Smrg  lex|flex)
217264fa531Smrg    echo 1>&2 "\
218264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
219264fa531Smrg         you modified a \`.l' file.  You may need the \`Flex' package
220264fa531Smrg         in order for those modifications to take effect.  You can get
221264fa531Smrg         \`Flex' from any GNU archive site."
222264fa531Smrg    rm -f lex.yy.c
223264fa531Smrg    if [ $# -ne 1 ]; then
224264fa531Smrg        eval LASTARG="\${$#}"
225264fa531Smrg	case "$LASTARG" in
226264fa531Smrg	*.l)
227264fa531Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
228264fa531Smrg	    if [ -f "$SRCFILE" ]; then
229264fa531Smrg	         cp "$SRCFILE" lex.yy.c
230264fa531Smrg	    fi
231264fa531Smrg	  ;;
232264fa531Smrg	esac
233264fa531Smrg    fi
234264fa531Smrg    if [ ! -f lex.yy.c ]; then
235264fa531Smrg	echo 'main() { return 0; }' >lex.yy.c
236264fa531Smrg    fi
237264fa531Smrg    ;;
238264fa531Smrg
239264fa531Smrg  help2man)
240264fa531Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
241264fa531Smrg       # We have it, but it failed.
242264fa531Smrg       exit 1
243264fa531Smrg    fi
244264fa531Smrg
245264fa531Smrg    echo 1>&2 "\
246264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
247264fa531Smrg	 you modified a dependency of a manual page.  You may need the
248264fa531Smrg	 \`Help2man' package in order for those modifications to take
249264fa531Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
250264fa531Smrg
251264fa531Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
252264fa531Smrg    if test -z "$file"; then
253264fa531Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
254264fa531Smrg    fi
255264fa531Smrg    if [ -f "$file" ]; then
256264fa531Smrg	touch $file
257264fa531Smrg    else
258264fa531Smrg	test -z "$file" || exec >$file
259264fa531Smrg	echo ".ab help2man is required to generate this page"
260264fa531Smrg	exit 1
261264fa531Smrg    fi
262264fa531Smrg    ;;
263264fa531Smrg
264264fa531Smrg  makeinfo)
265264fa531Smrg    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
266264fa531Smrg       # We have makeinfo, but it failed.
267264fa531Smrg       exit 1
268264fa531Smrg    fi
269264fa531Smrg
270264fa531Smrg    echo 1>&2 "\
271264fa531SmrgWARNING: \`$1' is missing on your system.  You should only need it if
272264fa531Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
273264fa531Smrg         indirectly affecting the aspect of the manual.  The spurious
274264fa531Smrg         call might also be the consequence of using a buggy \`make' (AIX,
275264fa531Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
276264fa531Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
277264fa531Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
278264fa531Smrg    if test -z "$file"; then
279264fa531Smrg      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
280264fa531Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
281264fa531Smrg    fi
282264fa531Smrg    touch $file
283264fa531Smrg    ;;
284264fa531Smrg
285264fa531Smrg  tar)
286264fa531Smrg    shift
287264fa531Smrg    if test -n "$run"; then
288264fa531Smrg      echo 1>&2 "ERROR: \`tar' requires --run"
289264fa531Smrg      exit 1
290264fa531Smrg    fi
291264fa531Smrg
292264fa531Smrg    # We have already tried tar in the generic part.
293264fa531Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
294264fa531Smrg    # messages.
295264fa531Smrg    if (gnutar --version > /dev/null 2>&1); then
296264fa531Smrg       gnutar "$@" && exit 0
297264fa531Smrg    fi
298264fa531Smrg    if (gtar --version > /dev/null 2>&1); then
299264fa531Smrg       gtar "$@" && exit 0
300264fa531Smrg    fi
301264fa531Smrg    firstarg="$1"
302264fa531Smrg    if shift; then
303264fa531Smrg	case "$firstarg" in
304264fa531Smrg	*o*)
305264fa531Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
306264fa531Smrg	    tar "$firstarg" "$@" && exit 0
307264fa531Smrg	    ;;
308264fa531Smrg	esac
309264fa531Smrg	case "$firstarg" in
310264fa531Smrg	*h*)
311264fa531Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
312264fa531Smrg	    tar "$firstarg" "$@" && exit 0
313264fa531Smrg	    ;;
314264fa531Smrg	esac
315264fa531Smrg    fi
316264fa531Smrg
317264fa531Smrg    echo 1>&2 "\
318264fa531SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
319264fa531Smrg         You may want to install GNU tar or Free paxutils, or check the
320264fa531Smrg         command line arguments."
321264fa531Smrg    exit 1
322264fa531Smrg    ;;
323264fa531Smrg
324264fa531Smrg  *)
325264fa531Smrg    echo 1>&2 "\
326264fa531SmrgWARNING: \`$1' is needed, and you do not seem to have it handy on your
327264fa531Smrg         system.  You might have modified some files without having the
328264fa531Smrg         proper tools for further handling them.  Check the \`README' file,
329264fa531Smrg         it often tells you about the needed prerequisites for installing
330264fa531Smrg         this package.  You may also peek at any GNU archive site, in case
331264fa531Smrg         some other package would contain this missing \`$1' program."
332264fa531Smrg    exit 1
333264fa531Smrg    ;;
334264fa531Smrgesac
335264fa531Smrg
336264fa531Smrgexit 0
337