missing revision 692f60a7
1692f60a7Smrg#! /bin/sh
2692f60a7Smrg# Common stub for a few missing GNU programs while installing.
3692f60a7Smrg
4692f60a7Smrgscriptversion=2005-06-08.21
5692f60a7Smrg
6692f60a7Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7692f60a7Smrg#   Free Software Foundation, Inc.
8692f60a7Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9692f60a7Smrg
10692f60a7Smrg# This program is free software; you can redistribute it and/or modify
11692f60a7Smrg# it under the terms of the GNU General Public License as published by
12692f60a7Smrg# the Free Software Foundation; either version 2, or (at your option)
13692f60a7Smrg# any later version.
14692f60a7Smrg
15692f60a7Smrg# This program is distributed in the hope that it will be useful,
16692f60a7Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17692f60a7Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18692f60a7Smrg# GNU General Public License for more details.
19692f60a7Smrg
20692f60a7Smrg# You should have received a copy of the GNU General Public License
21692f60a7Smrg# along with this program; if not, write to the Free Software
22692f60a7Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23692f60a7Smrg# 02110-1301, USA.
24692f60a7Smrg
25692f60a7Smrg# As a special exception to the GNU General Public License, if you
26692f60a7Smrg# distribute this file as part of a program that contains a
27692f60a7Smrg# configuration script generated by Autoconf, you may include it under
28692f60a7Smrg# the same distribution terms that you use for the rest of that program.
29692f60a7Smrg
30692f60a7Smrgif test $# -eq 0; then
31692f60a7Smrg  echo 1>&2 "Try \`$0 --help' for more information"
32692f60a7Smrg  exit 1
33692f60a7Smrgfi
34692f60a7Smrg
35692f60a7Smrgrun=:
36692f60a7Smrg
37692f60a7Smrg# In the cases where this matters, `missing' is being run in the
38692f60a7Smrg# srcdir already.
39692f60a7Smrgif test -f configure.ac; then
40692f60a7Smrg  configure_ac=configure.ac
41692f60a7Smrgelse
42692f60a7Smrg  configure_ac=configure.in
43692f60a7Smrgfi
44692f60a7Smrg
45692f60a7Smrgmsg="missing on your system"
46692f60a7Smrg
47692f60a7Smrgcase "$1" in
48692f60a7Smrg--run)
49692f60a7Smrg  # Try to run requested program, and just exit if it succeeds.
50692f60a7Smrg  run=
51692f60a7Smrg  shift
52692f60a7Smrg  "$@" && exit 0
53692f60a7Smrg  # Exit code 63 means version mismatch.  This often happens
54692f60a7Smrg  # when the user try to use an ancient version of a tool on
55692f60a7Smrg  # a file that requires a minimum version.  In this case we
56692f60a7Smrg  # we should proceed has if the program had been absent, or
57692f60a7Smrg  # if --run hadn't been passed.
58692f60a7Smrg  if test $? = 63; then
59692f60a7Smrg    run=:
60692f60a7Smrg    msg="probably too old"
61692f60a7Smrg  fi
62692f60a7Smrg  ;;
63692f60a7Smrg
64692f60a7Smrg  -h|--h|--he|--hel|--help)
65692f60a7Smrg    echo "\
66692f60a7Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67692f60a7Smrg
68692f60a7SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69692f60a7Smrgerror status if there is no known handling for PROGRAM.
70692f60a7Smrg
71692f60a7SmrgOptions:
72692f60a7Smrg  -h, --help      display this help and exit
73692f60a7Smrg  -v, --version   output version information and exit
74692f60a7Smrg  --run           try to run the given command, and emulate it if it fails
75692f60a7Smrg
76692f60a7SmrgSupported PROGRAM values:
77692f60a7Smrg  aclocal      touch file \`aclocal.m4'
78692f60a7Smrg  autoconf     touch file \`configure'
79692f60a7Smrg  autoheader   touch file \`config.h.in'
80692f60a7Smrg  automake     touch all \`Makefile.in' files
81692f60a7Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
82692f60a7Smrg  flex         create \`lex.yy.c', if possible, from existing .c
83692f60a7Smrg  help2man     touch the output file
84692f60a7Smrg  lex          create \`lex.yy.c', if possible, from existing .c
85692f60a7Smrg  makeinfo     touch the output file
86692f60a7Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
87692f60a7Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88692f60a7Smrg
89692f60a7SmrgSend bug reports to <bug-automake@gnu.org>."
90692f60a7Smrg    exit $?
91692f60a7Smrg    ;;
92692f60a7Smrg
93692f60a7Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94692f60a7Smrg    echo "missing $scriptversion (GNU Automake)"
95692f60a7Smrg    exit $?
96692f60a7Smrg    ;;
97692f60a7Smrg
98692f60a7Smrg  -*)
99692f60a7Smrg    echo 1>&2 "$0: Unknown \`$1' option"
100692f60a7Smrg    echo 1>&2 "Try \`$0 --help' for more information"
101692f60a7Smrg    exit 1
102692f60a7Smrg    ;;
103692f60a7Smrg
104692f60a7Smrgesac
105692f60a7Smrg
106692f60a7Smrg# Now exit if we have it, but it failed.  Also exit now if we
107692f60a7Smrg# don't have it and --version was passed (most likely to detect
108692f60a7Smrg# the program).
109692f60a7Smrgcase "$1" in
110692f60a7Smrg  lex|yacc)
111692f60a7Smrg    # Not GNU programs, they don't have --version.
112692f60a7Smrg    ;;
113692f60a7Smrg
114692f60a7Smrg  tar)
115692f60a7Smrg    if test -n "$run"; then
116692f60a7Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
117692f60a7Smrg       exit 1
118692f60a7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119692f60a7Smrg       exit 1
120692f60a7Smrg    fi
121692f60a7Smrg    ;;
122692f60a7Smrg
123692f60a7Smrg  *)
124692f60a7Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125692f60a7Smrg       # We have it, but it failed.
126692f60a7Smrg       exit 1
127692f60a7Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128692f60a7Smrg       # Could not run --version or --help.  This is probably someone
129692f60a7Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
130692f60a7Smrg       # $TOOL exists and not knowing $TOOL uses missing.
131692f60a7Smrg       exit 1
132692f60a7Smrg    fi
133692f60a7Smrg    ;;
134692f60a7Smrgesac
135692f60a7Smrg
136692f60a7Smrg# If it does not exist, or fails to run (possibly an outdated version),
137692f60a7Smrg# try to emulate it.
138692f60a7Smrgcase "$1" in
139692f60a7Smrg  aclocal*)
140692f60a7Smrg    echo 1>&2 "\
141692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
142692f60a7Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143692f60a7Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
144692f60a7Smrg         any GNU archive site."
145692f60a7Smrg    touch aclocal.m4
146692f60a7Smrg    ;;
147692f60a7Smrg
148692f60a7Smrg  autoconf)
149692f60a7Smrg    echo 1>&2 "\
150692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
151692f60a7Smrg         you modified \`${configure_ac}'.  You might want to install the
152692f60a7Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153692f60a7Smrg         archive site."
154692f60a7Smrg    touch configure
155692f60a7Smrg    ;;
156692f60a7Smrg
157692f60a7Smrg  autoheader)
158692f60a7Smrg    echo 1>&2 "\
159692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
160692f60a7Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161692f60a7Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162692f60a7Smrg         from any GNU archive site."
163692f60a7Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164692f60a7Smrg    test -z "$files" && files="config.h"
165692f60a7Smrg    touch_files=
166692f60a7Smrg    for f in $files; do
167692f60a7Smrg      case "$f" in
168692f60a7Smrg      *:*) touch_files="$touch_files "`echo "$f" |
169692f60a7Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170692f60a7Smrg      *) touch_files="$touch_files $f.in";;
171692f60a7Smrg      esac
172692f60a7Smrg    done
173692f60a7Smrg    touch $touch_files
174692f60a7Smrg    ;;
175692f60a7Smrg
176692f60a7Smrg  automake*)
177692f60a7Smrg    echo 1>&2 "\
178692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
179692f60a7Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180692f60a7Smrg         You might want to install the \`Automake' and \`Perl' packages.
181692f60a7Smrg         Grab them from any GNU archive site."
182692f60a7Smrg    find . -type f -name Makefile.am -print |
183692f60a7Smrg	   sed 's/\.am$/.in/' |
184692f60a7Smrg	   while read f; do touch "$f"; done
185692f60a7Smrg    ;;
186692f60a7Smrg
187692f60a7Smrg  autom4te)
188692f60a7Smrg    echo 1>&2 "\
189692f60a7SmrgWARNING: \`$1' is needed, but is $msg.
190692f60a7Smrg         You might have modified some files without having the
191692f60a7Smrg         proper tools for further handling them.
192692f60a7Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
193692f60a7Smrg         archive site."
194692f60a7Smrg
195692f60a7Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196692f60a7Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197692f60a7Smrg    if test -f "$file"; then
198692f60a7Smrg	touch $file
199692f60a7Smrg    else
200692f60a7Smrg	test -z "$file" || exec >$file
201692f60a7Smrg	echo "#! /bin/sh"
202692f60a7Smrg	echo "# Created by GNU Automake missing as a replacement of"
203692f60a7Smrg	echo "#  $ $@"
204692f60a7Smrg	echo "exit 0"
205692f60a7Smrg	chmod +x $file
206692f60a7Smrg	exit 1
207692f60a7Smrg    fi
208692f60a7Smrg    ;;
209692f60a7Smrg
210692f60a7Smrg  bison|yacc)
211692f60a7Smrg    echo 1>&2 "\
212692f60a7SmrgWARNING: \`$1' $msg.  You should only need it if
213692f60a7Smrg         you modified a \`.y' file.  You may need the \`Bison' package
214692f60a7Smrg         in order for those modifications to take effect.  You can get
215692f60a7Smrg         \`Bison' from any GNU archive site."
216692f60a7Smrg    rm -f y.tab.c y.tab.h
217692f60a7Smrg    if [ $# -ne 1 ]; then
218692f60a7Smrg        eval LASTARG="\${$#}"
219692f60a7Smrg	case "$LASTARG" in
220692f60a7Smrg	*.y)
221692f60a7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222692f60a7Smrg	    if [ -f "$SRCFILE" ]; then
223692f60a7Smrg	         cp "$SRCFILE" y.tab.c
224692f60a7Smrg	    fi
225692f60a7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226692f60a7Smrg	    if [ -f "$SRCFILE" ]; then
227692f60a7Smrg	         cp "$SRCFILE" y.tab.h
228692f60a7Smrg	    fi
229692f60a7Smrg	  ;;
230692f60a7Smrg	esac
231692f60a7Smrg    fi
232692f60a7Smrg    if [ ! -f y.tab.h ]; then
233692f60a7Smrg	echo >y.tab.h
234692f60a7Smrg    fi
235692f60a7Smrg    if [ ! -f y.tab.c ]; then
236692f60a7Smrg	echo 'main() { return 0; }' >y.tab.c
237692f60a7Smrg    fi
238692f60a7Smrg    ;;
239692f60a7Smrg
240692f60a7Smrg  lex|flex)
241692f60a7Smrg    echo 1>&2 "\
242692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
243692f60a7Smrg         you modified a \`.l' file.  You may need the \`Flex' package
244692f60a7Smrg         in order for those modifications to take effect.  You can get
245692f60a7Smrg         \`Flex' from any GNU archive site."
246692f60a7Smrg    rm -f lex.yy.c
247692f60a7Smrg    if [ $# -ne 1 ]; then
248692f60a7Smrg        eval LASTARG="\${$#}"
249692f60a7Smrg	case "$LASTARG" in
250692f60a7Smrg	*.l)
251692f60a7Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252692f60a7Smrg	    if [ -f "$SRCFILE" ]; then
253692f60a7Smrg	         cp "$SRCFILE" lex.yy.c
254692f60a7Smrg	    fi
255692f60a7Smrg	  ;;
256692f60a7Smrg	esac
257692f60a7Smrg    fi
258692f60a7Smrg    if [ ! -f lex.yy.c ]; then
259692f60a7Smrg	echo 'main() { return 0; }' >lex.yy.c
260692f60a7Smrg    fi
261692f60a7Smrg    ;;
262692f60a7Smrg
263692f60a7Smrg  help2man)
264692f60a7Smrg    echo 1>&2 "\
265692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
266692f60a7Smrg	 you modified a dependency of a manual page.  You may need the
267692f60a7Smrg	 \`Help2man' package in order for those modifications to take
268692f60a7Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
269692f60a7Smrg
270692f60a7Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271692f60a7Smrg    if test -z "$file"; then
272692f60a7Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273692f60a7Smrg    fi
274692f60a7Smrg    if [ -f "$file" ]; then
275692f60a7Smrg	touch $file
276692f60a7Smrg    else
277692f60a7Smrg	test -z "$file" || exec >$file
278692f60a7Smrg	echo ".ab help2man is required to generate this page"
279692f60a7Smrg	exit 1
280692f60a7Smrg    fi
281692f60a7Smrg    ;;
282692f60a7Smrg
283692f60a7Smrg  makeinfo)
284692f60a7Smrg    echo 1>&2 "\
285692f60a7SmrgWARNING: \`$1' is $msg.  You should only need it if
286692f60a7Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
287692f60a7Smrg         indirectly affecting the aspect of the manual.  The spurious
288692f60a7Smrg         call might also be the consequence of using a buggy \`make' (AIX,
289692f60a7Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
290692f60a7Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
291692f60a7Smrg    # The file to touch is that specified with -o ...
292692f60a7Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
293692f60a7Smrg    if test -z "$file"; then
294692f60a7Smrg      # ... or it is the one specified with @setfilename ...
295692f60a7Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296692f60a7Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297692f60a7Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298692f60a7Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
299692f60a7Smrg    fi
300692f60a7Smrg    # If the file does not exist, the user really needs makeinfo;
301692f60a7Smrg    # let's fail without touching anything.
302692f60a7Smrg    test -f $file || exit 1
303692f60a7Smrg    touch $file
304692f60a7Smrg    ;;
305692f60a7Smrg
306692f60a7Smrg  tar)
307692f60a7Smrg    shift
308692f60a7Smrg
309692f60a7Smrg    # We have already tried tar in the generic part.
310692f60a7Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
311692f60a7Smrg    # messages.
312692f60a7Smrg    if (gnutar --version > /dev/null 2>&1); then
313692f60a7Smrg       gnutar "$@" && exit 0
314692f60a7Smrg    fi
315692f60a7Smrg    if (gtar --version > /dev/null 2>&1); then
316692f60a7Smrg       gtar "$@" && exit 0
317692f60a7Smrg    fi
318692f60a7Smrg    firstarg="$1"
319692f60a7Smrg    if shift; then
320692f60a7Smrg	case "$firstarg" in
321692f60a7Smrg	*o*)
322692f60a7Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
323692f60a7Smrg	    tar "$firstarg" "$@" && exit 0
324692f60a7Smrg	    ;;
325692f60a7Smrg	esac
326692f60a7Smrg	case "$firstarg" in
327692f60a7Smrg	*h*)
328692f60a7Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
329692f60a7Smrg	    tar "$firstarg" "$@" && exit 0
330692f60a7Smrg	    ;;
331692f60a7Smrg	esac
332692f60a7Smrg    fi
333692f60a7Smrg
334692f60a7Smrg    echo 1>&2 "\
335692f60a7SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
336692f60a7Smrg         You may want to install GNU tar or Free paxutils, or check the
337692f60a7Smrg         command line arguments."
338692f60a7Smrg    exit 1
339692f60a7Smrg    ;;
340692f60a7Smrg
341692f60a7Smrg  *)
342692f60a7Smrg    echo 1>&2 "\
343692f60a7SmrgWARNING: \`$1' is needed, and is $msg.
344692f60a7Smrg         You might have modified some files without having the
345692f60a7Smrg         proper tools for further handling them.  Check the \`README' file,
346692f60a7Smrg         it often tells you about the needed prerequisites for installing
347692f60a7Smrg         this package.  You may also peek at any GNU archive site, in case
348692f60a7Smrg         some other package would contain this missing \`$1' program."
349692f60a7Smrg    exit 1
350692f60a7Smrg    ;;
351692f60a7Smrgesac
352692f60a7Smrg
353692f60a7Smrgexit 0
354692f60a7Smrg
355692f60a7Smrg# Local variables:
356692f60a7Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
357692f60a7Smrg# time-stamp-start: "scriptversion="
358692f60a7Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
359692f60a7Smrg# time-stamp-end: "$"
360692f60a7Smrg# End:
361