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