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