1219820Sjeff#! /bin/sh
2219820Sjeff# Common stub for a few missing GNU programs while installing.
3219820Sjeff
4219820Sjeffscriptversion=2005-06-08.21
5219820Sjeff
6219820Sjeff# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7219820Sjeff#   Free Software Foundation, Inc.
8219820Sjeff# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9219820Sjeff
10219820Sjeff# This program is free software; you can redistribute it and/or modify
11219820Sjeff# it under the terms of the GNU General Public License as published by
12219820Sjeff# the Free Software Foundation; either version 2, or (at your option)
13219820Sjeff# any later version.
14219820Sjeff
15219820Sjeff# This program is distributed in the hope that it will be useful,
16219820Sjeff# but WITHOUT ANY WARRANTY; without even the implied warranty of
17219820Sjeff# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18219820Sjeff# GNU General Public License for more details.
19219820Sjeff
20219820Sjeff# You should have received a copy of the GNU General Public License
21219820Sjeff# along with this program; if not, write to the Free Software
22219820Sjeff# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23219820Sjeff# 02110-1301, USA.
24219820Sjeff
25219820Sjeff# As a special exception to the GNU General Public License, if you
26219820Sjeff# distribute this file as part of a program that contains a
27219820Sjeff# configuration script generated by Autoconf, you may include it under
28219820Sjeff# the same distribution terms that you use for the rest of that program.
29219820Sjeff
30219820Sjeffif test $# -eq 0; then
31219820Sjeff  echo 1>&2 "Try \`$0 --help' for more information"
32219820Sjeff  exit 1
33219820Sjefffi
34219820Sjeff
35219820Sjeffrun=:
36219820Sjeff
37219820Sjeff# In the cases where this matters, `missing' is being run in the
38219820Sjeff# srcdir already.
39219820Sjeffif test -f configure.ac; then
40219820Sjeff  configure_ac=configure.ac
41219820Sjeffelse
42219820Sjeff  configure_ac=configure.in
43219820Sjefffi
44219820Sjeff
45219820Sjeffmsg="missing on your system"
46219820Sjeff
47219820Sjeffcase "$1" in
48219820Sjeff--run)
49219820Sjeff  # Try to run requested program, and just exit if it succeeds.
50219820Sjeff  run=
51219820Sjeff  shift
52219820Sjeff  "$@" && exit 0
53219820Sjeff  # Exit code 63 means version mismatch.  This often happens
54219820Sjeff  # when the user try to use an ancient version of a tool on
55219820Sjeff  # a file that requires a minimum version.  In this case we
56219820Sjeff  # we should proceed has if the program had been absent, or
57219820Sjeff  # if --run hadn't been passed.
58219820Sjeff  if test $? = 63; then
59219820Sjeff    run=:
60219820Sjeff    msg="probably too old"
61219820Sjeff  fi
62219820Sjeff  ;;
63219820Sjeff
64219820Sjeff  -h|--h|--he|--hel|--help)
65219820Sjeff    echo "\
66219820Sjeff$0 [OPTION]... PROGRAM [ARGUMENT]...
67219820Sjeff
68219820SjeffHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69219820Sjefferror status if there is no known handling for PROGRAM.
70219820Sjeff
71219820SjeffOptions:
72219820Sjeff  -h, --help      display this help and exit
73219820Sjeff  -v, --version   output version information and exit
74219820Sjeff  --run           try to run the given command, and emulate it if it fails
75219820Sjeff
76219820SjeffSupported PROGRAM values:
77219820Sjeff  aclocal      touch file \`aclocal.m4'
78219820Sjeff  autoconf     touch file \`configure'
79219820Sjeff  autoheader   touch file \`config.h.in'
80219820Sjeff  automake     touch all \`Makefile.in' files
81219820Sjeff  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
82219820Sjeff  flex         create \`lex.yy.c', if possible, from existing .c
83219820Sjeff  help2man     touch the output file
84219820Sjeff  lex          create \`lex.yy.c', if possible, from existing .c
85219820Sjeff  makeinfo     touch the output file
86219820Sjeff  tar          try tar, gnutar, gtar, then tar without non-portable flags
87219820Sjeff  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88219820Sjeff
89219820SjeffSend bug reports to <bug-automake@gnu.org>."
90219820Sjeff    exit $?
91219820Sjeff    ;;
92219820Sjeff
93219820Sjeff  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94219820Sjeff    echo "missing $scriptversion (GNU Automake)"
95219820Sjeff    exit $?
96219820Sjeff    ;;
97219820Sjeff
98219820Sjeff  -*)
99219820Sjeff    echo 1>&2 "$0: Unknown \`$1' option"
100219820Sjeff    echo 1>&2 "Try \`$0 --help' for more information"
101219820Sjeff    exit 1
102219820Sjeff    ;;
103219820Sjeff
104219820Sjeffesac
105219820Sjeff
106219820Sjeff# Now exit if we have it, but it failed.  Also exit now if we
107219820Sjeff# don't have it and --version was passed (most likely to detect
108219820Sjeff# the program).
109219820Sjeffcase "$1" in
110219820Sjeff  lex|yacc)
111219820Sjeff    # Not GNU programs, they don't have --version.
112219820Sjeff    ;;
113219820Sjeff
114219820Sjeff  tar)
115219820Sjeff    if test -n "$run"; then
116219820Sjeff       echo 1>&2 "ERROR: \`tar' requires --run"
117219820Sjeff       exit 1
118219820Sjeff    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119219820Sjeff       exit 1
120219820Sjeff    fi
121219820Sjeff    ;;
122219820Sjeff
123219820Sjeff  *)
124219820Sjeff    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125219820Sjeff       # We have it, but it failed.
126219820Sjeff       exit 1
127219820Sjeff    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128219820Sjeff       # Could not run --version or --help.  This is probably someone
129219820Sjeff       # running `$TOOL --version' or `$TOOL --help' to check whether
130219820Sjeff       # $TOOL exists and not knowing $TOOL uses missing.
131219820Sjeff       exit 1
132219820Sjeff    fi
133219820Sjeff    ;;
134219820Sjeffesac
135219820Sjeff
136219820Sjeff# If it does not exist, or fails to run (possibly an outdated version),
137219820Sjeff# try to emulate it.
138219820Sjeffcase "$1" in
139219820Sjeff  aclocal*)
140219820Sjeff    echo 1>&2 "\
141219820SjeffWARNING: \`$1' is $msg.  You should only need it if
142219820Sjeff         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143219820Sjeff         to install the \`Automake' and \`Perl' packages.  Grab them from
144219820Sjeff         any GNU archive site."
145219820Sjeff    touch aclocal.m4
146219820Sjeff    ;;
147219820Sjeff
148219820Sjeff  autoconf)
149219820Sjeff    echo 1>&2 "\
150219820SjeffWARNING: \`$1' is $msg.  You should only need it if
151219820Sjeff         you modified \`${configure_ac}'.  You might want to install the
152219820Sjeff         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153219820Sjeff         archive site."
154219820Sjeff    touch configure
155219820Sjeff    ;;
156219820Sjeff
157219820Sjeff  autoheader)
158219820Sjeff    echo 1>&2 "\
159219820SjeffWARNING: \`$1' is $msg.  You should only need it if
160219820Sjeff         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161219820Sjeff         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162219820Sjeff         from any GNU archive site."
163219820Sjeff    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164219820Sjeff    test -z "$files" && files="config.h"
165219820Sjeff    touch_files=
166219820Sjeff    for f in $files; do
167219820Sjeff      case "$f" in
168219820Sjeff      *:*) touch_files="$touch_files "`echo "$f" |
169219820Sjeff				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170219820Sjeff      *) touch_files="$touch_files $f.in";;
171219820Sjeff      esac
172219820Sjeff    done
173219820Sjeff    touch $touch_files
174219820Sjeff    ;;
175219820Sjeff
176219820Sjeff  automake*)
177219820Sjeff    echo 1>&2 "\
178219820SjeffWARNING: \`$1' is $msg.  You should only need it if
179219820Sjeff         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180219820Sjeff         You might want to install the \`Automake' and \`Perl' packages.
181219820Sjeff         Grab them from any GNU archive site."
182219820Sjeff    find . -type f -name Makefile.am -print |
183219820Sjeff	   sed 's/\.am$/.in/' |
184219820Sjeff	   while read f; do touch "$f"; done
185219820Sjeff    ;;
186219820Sjeff
187219820Sjeff  autom4te)
188219820Sjeff    echo 1>&2 "\
189219820SjeffWARNING: \`$1' is needed, but is $msg.
190219820Sjeff         You might have modified some files without having the
191219820Sjeff         proper tools for further handling them.
192219820Sjeff         You can get \`$1' as part of \`Autoconf' from any GNU
193219820Sjeff         archive site."
194219820Sjeff
195219820Sjeff    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196219820Sjeff    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197219820Sjeff    if test -f "$file"; then
198219820Sjeff	touch $file
199219820Sjeff    else
200219820Sjeff	test -z "$file" || exec >$file
201219820Sjeff	echo "#! /bin/sh"
202219820Sjeff	echo "# Created by GNU Automake missing as a replacement of"
203219820Sjeff	echo "#  $ $@"
204219820Sjeff	echo "exit 0"
205219820Sjeff	chmod +x $file
206219820Sjeff	exit 1
207219820Sjeff    fi
208219820Sjeff    ;;
209219820Sjeff
210219820Sjeff  bison|yacc)
211219820Sjeff    echo 1>&2 "\
212219820SjeffWARNING: \`$1' $msg.  You should only need it if
213219820Sjeff         you modified a \`.y' file.  You may need the \`Bison' package
214219820Sjeff         in order for those modifications to take effect.  You can get
215219820Sjeff         \`Bison' from any GNU archive site."
216219820Sjeff    rm -f y.tab.c y.tab.h
217219820Sjeff    if [ $# -ne 1 ]; then
218219820Sjeff        eval LASTARG="\${$#}"
219219820Sjeff	case "$LASTARG" in
220219820Sjeff	*.y)
221219820Sjeff	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222219820Sjeff	    if [ -f "$SRCFILE" ]; then
223219820Sjeff	         cp "$SRCFILE" y.tab.c
224219820Sjeff	    fi
225219820Sjeff	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226219820Sjeff	    if [ -f "$SRCFILE" ]; then
227219820Sjeff	         cp "$SRCFILE" y.tab.h
228219820Sjeff	    fi
229219820Sjeff	  ;;
230219820Sjeff	esac
231219820Sjeff    fi
232219820Sjeff    if [ ! -f y.tab.h ]; then
233219820Sjeff	echo >y.tab.h
234219820Sjeff    fi
235219820Sjeff    if [ ! -f y.tab.c ]; then
236219820Sjeff	echo 'main() { return 0; }' >y.tab.c
237219820Sjeff    fi
238219820Sjeff    ;;
239219820Sjeff
240219820Sjeff  lex|flex)
241219820Sjeff    echo 1>&2 "\
242219820SjeffWARNING: \`$1' is $msg.  You should only need it if
243219820Sjeff         you modified a \`.l' file.  You may need the \`Flex' package
244219820Sjeff         in order for those modifications to take effect.  You can get
245219820Sjeff         \`Flex' from any GNU archive site."
246219820Sjeff    rm -f lex.yy.c
247219820Sjeff    if [ $# -ne 1 ]; then
248219820Sjeff        eval LASTARG="\${$#}"
249219820Sjeff	case "$LASTARG" in
250219820Sjeff	*.l)
251219820Sjeff	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252219820Sjeff	    if [ -f "$SRCFILE" ]; then
253219820Sjeff	         cp "$SRCFILE" lex.yy.c
254219820Sjeff	    fi
255219820Sjeff	  ;;
256219820Sjeff	esac
257219820Sjeff    fi
258219820Sjeff    if [ ! -f lex.yy.c ]; then
259219820Sjeff	echo 'main() { return 0; }' >lex.yy.c
260219820Sjeff    fi
261219820Sjeff    ;;
262219820Sjeff
263219820Sjeff  help2man)
264219820Sjeff    echo 1>&2 "\
265219820SjeffWARNING: \`$1' is $msg.  You should only need it if
266219820Sjeff	 you modified a dependency of a manual page.  You may need the
267219820Sjeff	 \`Help2man' package in order for those modifications to take
268219820Sjeff	 effect.  You can get \`Help2man' from any GNU archive site."
269219820Sjeff
270219820Sjeff    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271219820Sjeff    if test -z "$file"; then
272219820Sjeff	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273219820Sjeff    fi
274219820Sjeff    if [ -f "$file" ]; then
275219820Sjeff	touch $file
276219820Sjeff    else
277219820Sjeff	test -z "$file" || exec >$file
278219820Sjeff	echo ".ab help2man is required to generate this page"
279219820Sjeff	exit 1
280219820Sjeff    fi
281219820Sjeff    ;;
282219820Sjeff
283219820Sjeff  makeinfo)
284219820Sjeff    echo 1>&2 "\
285219820SjeffWARNING: \`$1' is $msg.  You should only need it if
286219820Sjeff         you modified a \`.texi' or \`.texinfo' file, or any other file
287219820Sjeff         indirectly affecting the aspect of the manual.  The spurious
288219820Sjeff         call might also be the consequence of using a buggy \`make' (AIX,
289219820Sjeff         DU, IRIX).  You might want to install the \`Texinfo' package or
290219820Sjeff         the \`GNU make' package.  Grab either from any GNU archive site."
291219820Sjeff    # The file to touch is that specified with -o ...
292219820Sjeff    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
293219820Sjeff    if test -z "$file"; then
294219820Sjeff      # ... or it is the one specified with @setfilename ...
295219820Sjeff      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296219820Sjeff      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297219820Sjeff      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298219820Sjeff      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
299219820Sjeff    fi
300219820Sjeff    # If the file does not exist, the user really needs makeinfo;
301219820Sjeff    # let's fail without touching anything.
302219820Sjeff    test -f $file || exit 1
303219820Sjeff    touch $file
304219820Sjeff    ;;
305219820Sjeff
306219820Sjeff  tar)
307219820Sjeff    shift
308219820Sjeff
309219820Sjeff    # We have already tried tar in the generic part.
310219820Sjeff    # Look for gnutar/gtar before invocation to avoid ugly error
311219820Sjeff    # messages.
312219820Sjeff    if (gnutar --version > /dev/null 2>&1); then
313219820Sjeff       gnutar "$@" && exit 0
314219820Sjeff    fi
315219820Sjeff    if (gtar --version > /dev/null 2>&1); then
316219820Sjeff       gtar "$@" && exit 0
317219820Sjeff    fi
318219820Sjeff    firstarg="$1"
319219820Sjeff    if shift; then
320219820Sjeff	case "$firstarg" in
321219820Sjeff	*o*)
322219820Sjeff	    firstarg=`echo "$firstarg" | sed s/o//`
323219820Sjeff	    tar "$firstarg" "$@" && exit 0
324219820Sjeff	    ;;
325219820Sjeff	esac
326219820Sjeff	case "$firstarg" in
327219820Sjeff	*h*)
328219820Sjeff	    firstarg=`echo "$firstarg" | sed s/h//`
329219820Sjeff	    tar "$firstarg" "$@" && exit 0
330219820Sjeff	    ;;
331219820Sjeff	esac
332219820Sjeff    fi
333219820Sjeff
334219820Sjeff    echo 1>&2 "\
335219820SjeffWARNING: I can't seem to be able to run \`tar' with the given arguments.
336219820Sjeff         You may want to install GNU tar or Free paxutils, or check the
337219820Sjeff         command line arguments."
338219820Sjeff    exit 1
339219820Sjeff    ;;
340219820Sjeff
341219820Sjeff  *)
342219820Sjeff    echo 1>&2 "\
343219820SjeffWARNING: \`$1' is needed, and is $msg.
344219820Sjeff         You might have modified some files without having the
345219820Sjeff         proper tools for further handling them.  Check the \`README' file,
346219820Sjeff         it often tells you about the needed prerequisites for installing
347219820Sjeff         this package.  You may also peek at any GNU archive site, in case
348219820Sjeff         some other package would contain this missing \`$1' program."
349219820Sjeff    exit 1
350219820Sjeff    ;;
351219820Sjeffesac
352219820Sjeff
353219820Sjeffexit 0
354219820Sjeff
355219820Sjeff# Local variables:
356219820Sjeff# eval: (add-hook 'write-file-hooks 'time-stamp)
357219820Sjeff# time-stamp-start: "scriptversion="
358219820Sjeff# time-stamp-format: "%:y-%02m-%02d.%02H"
359219820Sjeff# time-stamp-end: "$"
360219820Sjeff# End:
361