missing revision 126a8a12
1126a8a12Smrg#! /bin/sh
2126a8a12Smrg# Common stub for a few missing GNU programs while installing.
3126a8a12Smrg
4126a8a12Smrgscriptversion=2006-05-10.23
5126a8a12Smrg
6126a8a12Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
7126a8a12Smrg#   Free Software Foundation, Inc.
8126a8a12Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9126a8a12Smrg
10126a8a12Smrg# This program is free software; you can redistribute it and/or modify
11126a8a12Smrg# it under the terms of the GNU General Public License as published by
12126a8a12Smrg# the Free Software Foundation; either version 2, or (at your option)
13126a8a12Smrg# any later version.
14126a8a12Smrg
15126a8a12Smrg# This program is distributed in the hope that it will be useful,
16126a8a12Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17126a8a12Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18126a8a12Smrg# GNU General Public License for more details.
19126a8a12Smrg
20126a8a12Smrg# You should have received a copy of the GNU General Public License
21126a8a12Smrg# along with this program; if not, write to the Free Software
22126a8a12Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23126a8a12Smrg# 02110-1301, USA.
24126a8a12Smrg
25126a8a12Smrg# As a special exception to the GNU General Public License, if you
26126a8a12Smrg# distribute this file as part of a program that contains a
27126a8a12Smrg# configuration script generated by Autoconf, you may include it under
28126a8a12Smrg# the same distribution terms that you use for the rest of that program.
29126a8a12Smrg
30126a8a12Smrgif test $# -eq 0; then
31126a8a12Smrg  echo 1>&2 "Try \`$0 --help' for more information"
32126a8a12Smrg  exit 1
33126a8a12Smrgfi
34126a8a12Smrg
35126a8a12Smrgrun=:
36126a8a12Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
37126a8a12Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
38126a8a12Smrg
39126a8a12Smrg# In the cases where this matters, `missing' is being run in the
40126a8a12Smrg# srcdir already.
41126a8a12Smrgif test -f configure.ac; then
42126a8a12Smrg  configure_ac=configure.ac
43126a8a12Smrgelse
44126a8a12Smrg  configure_ac=configure.in
45126a8a12Smrgfi
46126a8a12Smrg
47126a8a12Smrgmsg="missing on your system"
48126a8a12Smrg
49126a8a12Smrgcase $1 in
50126a8a12Smrg--run)
51126a8a12Smrg  # Try to run requested program, and just exit if it succeeds.
52126a8a12Smrg  run=
53126a8a12Smrg  shift
54126a8a12Smrg  "$@" && exit 0
55126a8a12Smrg  # Exit code 63 means version mismatch.  This often happens
56126a8a12Smrg  # when the user try to use an ancient version of a tool on
57126a8a12Smrg  # a file that requires a minimum version.  In this case we
58126a8a12Smrg  # we should proceed has if the program had been absent, or
59126a8a12Smrg  # if --run hadn't been passed.
60126a8a12Smrg  if test $? = 63; then
61126a8a12Smrg    run=:
62126a8a12Smrg    msg="probably too old"
63126a8a12Smrg  fi
64126a8a12Smrg  ;;
65126a8a12Smrg
66126a8a12Smrg  -h|--h|--he|--hel|--help)
67126a8a12Smrg    echo "\
68126a8a12Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
69126a8a12Smrg
70126a8a12SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
71126a8a12Smrgerror status if there is no known handling for PROGRAM.
72126a8a12Smrg
73126a8a12SmrgOptions:
74126a8a12Smrg  -h, --help      display this help and exit
75126a8a12Smrg  -v, --version   output version information and exit
76126a8a12Smrg  --run           try to run the given command, and emulate it if it fails
77126a8a12Smrg
78126a8a12SmrgSupported PROGRAM values:
79126a8a12Smrg  aclocal      touch file \`aclocal.m4'
80126a8a12Smrg  autoconf     touch file \`configure'
81126a8a12Smrg  autoheader   touch file \`config.h.in'
82126a8a12Smrg  autom4te     touch the output file, or create a stub one
83126a8a12Smrg  automake     touch all \`Makefile.in' files
84126a8a12Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
85126a8a12Smrg  flex         create \`lex.yy.c', if possible, from existing .c
86126a8a12Smrg  help2man     touch the output file
87126a8a12Smrg  lex          create \`lex.yy.c', if possible, from existing .c
88126a8a12Smrg  makeinfo     touch the output file
89126a8a12Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
90126a8a12Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
91126a8a12Smrg
92126a8a12SmrgSend bug reports to <bug-automake@gnu.org>."
93126a8a12Smrg    exit $?
94126a8a12Smrg    ;;
95126a8a12Smrg
96126a8a12Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
97126a8a12Smrg    echo "missing $scriptversion (GNU Automake)"
98126a8a12Smrg    exit $?
99126a8a12Smrg    ;;
100126a8a12Smrg
101126a8a12Smrg  -*)
102126a8a12Smrg    echo 1>&2 "$0: Unknown \`$1' option"
103126a8a12Smrg    echo 1>&2 "Try \`$0 --help' for more information"
104126a8a12Smrg    exit 1
105126a8a12Smrg    ;;
106126a8a12Smrg
107126a8a12Smrgesac
108126a8a12Smrg
109126a8a12Smrg# Now exit if we have it, but it failed.  Also exit now if we
110126a8a12Smrg# don't have it and --version was passed (most likely to detect
111126a8a12Smrg# the program).
112126a8a12Smrgcase $1 in
113126a8a12Smrg  lex|yacc)
114126a8a12Smrg    # Not GNU programs, they don't have --version.
115126a8a12Smrg    ;;
116126a8a12Smrg
117126a8a12Smrg  tar)
118126a8a12Smrg    if test -n "$run"; then
119126a8a12Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
120126a8a12Smrg       exit 1
121126a8a12Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
122126a8a12Smrg       exit 1
123126a8a12Smrg    fi
124126a8a12Smrg    ;;
125126a8a12Smrg
126126a8a12Smrg  *)
127126a8a12Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
128126a8a12Smrg       # We have it, but it failed.
129126a8a12Smrg       exit 1
130126a8a12Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
131126a8a12Smrg       # Could not run --version or --help.  This is probably someone
132126a8a12Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
133126a8a12Smrg       # $TOOL exists and not knowing $TOOL uses missing.
134126a8a12Smrg       exit 1
135126a8a12Smrg    fi
136126a8a12Smrg    ;;
137126a8a12Smrgesac
138126a8a12Smrg
139126a8a12Smrg# If it does not exist, or fails to run (possibly an outdated version),
140126a8a12Smrg# try to emulate it.
141126a8a12Smrgcase $1 in
142126a8a12Smrg  aclocal*)
143126a8a12Smrg    echo 1>&2 "\
144126a8a12SmrgWARNING: \`$1' is $msg.  You should only need it if
145126a8a12Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
146126a8a12Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
147126a8a12Smrg         any GNU archive site."
148126a8a12Smrg    touch aclocal.m4
149126a8a12Smrg    ;;
150126a8a12Smrg
151126a8a12Smrg  autoconf)
152126a8a12Smrg    echo 1>&2 "\
153126a8a12SmrgWARNING: \`$1' is $msg.  You should only need it if
154126a8a12Smrg         you modified \`${configure_ac}'.  You might want to install the
155126a8a12Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
156126a8a12Smrg         archive site."
157126a8a12Smrg    touch configure
158126a8a12Smrg    ;;
159126a8a12Smrg
160126a8a12Smrg  autoheader)
161126a8a12Smrg    echo 1>&2 "\
162126a8a12SmrgWARNING: \`$1' is $msg.  You should only need it if
163126a8a12Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
164126a8a12Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
165126a8a12Smrg         from any GNU archive site."
166126a8a12Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
167126a8a12Smrg    test -z "$files" && files="config.h"
168126a8a12Smrg    touch_files=
169126a8a12Smrg    for f in $files; do
170126a8a12Smrg      case $f in
171126a8a12Smrg      *:*) touch_files="$touch_files "`echo "$f" |
172126a8a12Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
173126a8a12Smrg      *) touch_files="$touch_files $f.in";;
174126a8a12Smrg      esac
175126a8a12Smrg    done
176126a8a12Smrg    touch $touch_files
177126a8a12Smrg    ;;
178126a8a12Smrg
179126a8a12Smrg  automake*)
180126a8a12Smrg    echo 1>&2 "\
181126a8a12SmrgWARNING: \`$1' is $msg.  You should only need it if
182126a8a12Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
183126a8a12Smrg         You might want to install the \`Automake' and \`Perl' packages.
184126a8a12Smrg         Grab them from any GNU archive site."
185126a8a12Smrg    find . -type f -name Makefile.am -print |
186126a8a12Smrg	   sed 's/\.am$/.in/' |
187126a8a12Smrg	   while read f; do touch "$f"; done
188126a8a12Smrg    ;;
189126a8a12Smrg
190126a8a12Smrg  autom4te)
191126a8a12Smrg    echo 1>&2 "\
192126a8a12SmrgWARNING: \`$1' is needed, but is $msg.
193126a8a12Smrg         You might have modified some files without having the
194126a8a12Smrg         proper tools for further handling them.
195126a8a12Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
196126a8a12Smrg         archive site."
197126a8a12Smrg
198126a8a12Smrg    file=`echo "$*" | sed -n "$sed_output"`
199126a8a12Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
200126a8a12Smrg    if test -f "$file"; then
201126a8a12Smrg	touch $file
202126a8a12Smrg    else
203126a8a12Smrg	test -z "$file" || exec >$file
204126a8a12Smrg	echo "#! /bin/sh"
205126a8a12Smrg	echo "# Created by GNU Automake missing as a replacement of"
206126a8a12Smrg	echo "#  $ $@"
207126a8a12Smrg	echo "exit 0"
208126a8a12Smrg	chmod +x $file
209126a8a12Smrg	exit 1
210126a8a12Smrg    fi
211126a8a12Smrg    ;;
212126a8a12Smrg
213126a8a12Smrg  bison|yacc)
214126a8a12Smrg    echo 1>&2 "\
215126a8a12SmrgWARNING: \`$1' $msg.  You should only need it if
216126a8a12Smrg         you modified a \`.y' file.  You may need the \`Bison' package
217126a8a12Smrg         in order for those modifications to take effect.  You can get
218126a8a12Smrg         \`Bison' from any GNU archive site."
219126a8a12Smrg    rm -f y.tab.c y.tab.h
220126a8a12Smrg    if test $# -ne 1; then
221126a8a12Smrg        eval LASTARG="\${$#}"
222126a8a12Smrg	case $LASTARG in
223126a8a12Smrg	*.y)
224126a8a12Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
225126a8a12Smrg	    if test -f "$SRCFILE"; then
226126a8a12Smrg	         cp "$SRCFILE" y.tab.c
227126a8a12Smrg	    fi
228126a8a12Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
229126a8a12Smrg	    if test -f "$SRCFILE"; then
230126a8a12Smrg	         cp "$SRCFILE" y.tab.h
231126a8a12Smrg	    fi
232126a8a12Smrg	  ;;
233126a8a12Smrg	esac
234126a8a12Smrg    fi
235126a8a12Smrg    if test ! -f y.tab.h; then
236126a8a12Smrg	echo >y.tab.h
237126a8a12Smrg    fi
238126a8a12Smrg    if test ! -f y.tab.c; then
239126a8a12Smrg	echo 'main() { return 0; }' >y.tab.c
240126a8a12Smrg    fi
241126a8a12Smrg    ;;
242126a8a12Smrg
243126a8a12Smrg  lex|flex)
244126a8a12Smrg    echo 1>&2 "\
245126a8a12SmrgWARNING: \`$1' is $msg.  You should only need it if
246126a8a12Smrg         you modified a \`.l' file.  You may need the \`Flex' package
247126a8a12Smrg         in order for those modifications to take effect.  You can get
248126a8a12Smrg         \`Flex' from any GNU archive site."
249126a8a12Smrg    rm -f lex.yy.c
250126a8a12Smrg    if test $# -ne 1; then
251126a8a12Smrg        eval LASTARG="\${$#}"
252126a8a12Smrg	case $LASTARG in
253126a8a12Smrg	*.l)
254126a8a12Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
255126a8a12Smrg	    if test -f "$SRCFILE"; then
256126a8a12Smrg	         cp "$SRCFILE" lex.yy.c
257126a8a12Smrg	    fi
258126a8a12Smrg	  ;;
259126a8a12Smrg	esac
260126a8a12Smrg    fi
261126a8a12Smrg    if test ! -f lex.yy.c; then
262126a8a12Smrg	echo 'main() { return 0; }' >lex.yy.c
263126a8a12Smrg    fi
264126a8a12Smrg    ;;
265126a8a12Smrg
266126a8a12Smrg  help2man)
267126a8a12Smrg    echo 1>&2 "\
268126a8a12SmrgWARNING: \`$1' is $msg.  You should only need it if
269126a8a12Smrg	 you modified a dependency of a manual page.  You may need the
270126a8a12Smrg	 \`Help2man' package in order for those modifications to take
271126a8a12Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
272126a8a12Smrg
273126a8a12Smrg    file=`echo "$*" | sed -n "$sed_output"`
274126a8a12Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
275126a8a12Smrg    if test -f "$file"; then
276126a8a12Smrg	touch $file
277126a8a12Smrg    else
278126a8a12Smrg	test -z "$file" || exec >$file
279126a8a12Smrg	echo ".ab help2man is required to generate this page"
280126a8a12Smrg	exit 1
281126a8a12Smrg    fi
282126a8a12Smrg    ;;
283126a8a12Smrg
284126a8a12Smrg  makeinfo)
285126a8a12Smrg    echo 1>&2 "\
286126a8a12SmrgWARNING: \`$1' is $msg.  You should only need it if
287126a8a12Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
288126a8a12Smrg         indirectly affecting the aspect of the manual.  The spurious
289126a8a12Smrg         call might also be the consequence of using a buggy \`make' (AIX,
290126a8a12Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
291126a8a12Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
292126a8a12Smrg    # The file to touch is that specified with -o ...
293126a8a12Smrg    file=`echo "$*" | sed -n "$sed_output"`
294126a8a12Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
295126a8a12Smrg    if test -z "$file"; then
296126a8a12Smrg      # ... or it is the one specified with @setfilename ...
297126a8a12Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
298126a8a12Smrg      file=`sed -n '
299126a8a12Smrg	/^@setfilename/{
300126a8a12Smrg	  s/.* \([^ ]*\) *$/\1/
301126a8a12Smrg	  p
302126a8a12Smrg	  q
303126a8a12Smrg	}' $infile`
304126a8a12Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
305126a8a12Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
306126a8a12Smrg    fi
307126a8a12Smrg    # If the file does not exist, the user really needs makeinfo;
308126a8a12Smrg    # let's fail without touching anything.
309126a8a12Smrg    test -f $file || exit 1
310126a8a12Smrg    touch $file
311126a8a12Smrg    ;;
312126a8a12Smrg
313126a8a12Smrg  tar)
314126a8a12Smrg    shift
315126a8a12Smrg
316126a8a12Smrg    # We have already tried tar in the generic part.
317126a8a12Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
318126a8a12Smrg    # messages.
319126a8a12Smrg    if (gnutar --version > /dev/null 2>&1); then
320126a8a12Smrg       gnutar "$@" && exit 0
321126a8a12Smrg    fi
322126a8a12Smrg    if (gtar --version > /dev/null 2>&1); then
323126a8a12Smrg       gtar "$@" && exit 0
324126a8a12Smrg    fi
325126a8a12Smrg    firstarg="$1"
326126a8a12Smrg    if shift; then
327126a8a12Smrg	case $firstarg in
328126a8a12Smrg	*o*)
329126a8a12Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
330126a8a12Smrg	    tar "$firstarg" "$@" && exit 0
331126a8a12Smrg	    ;;
332126a8a12Smrg	esac
333126a8a12Smrg	case $firstarg in
334126a8a12Smrg	*h*)
335126a8a12Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
336126a8a12Smrg	    tar "$firstarg" "$@" && exit 0
337126a8a12Smrg	    ;;
338126a8a12Smrg	esac
339126a8a12Smrg    fi
340126a8a12Smrg
341126a8a12Smrg    echo 1>&2 "\
342126a8a12SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
343126a8a12Smrg         You may want to install GNU tar or Free paxutils, or check the
344126a8a12Smrg         command line arguments."
345126a8a12Smrg    exit 1
346126a8a12Smrg    ;;
347126a8a12Smrg
348126a8a12Smrg  *)
349126a8a12Smrg    echo 1>&2 "\
350126a8a12SmrgWARNING: \`$1' is needed, and is $msg.
351126a8a12Smrg         You might have modified some files without having the
352126a8a12Smrg         proper tools for further handling them.  Check the \`README' file,
353126a8a12Smrg         it often tells you about the needed prerequisites for installing
354126a8a12Smrg         this package.  You may also peek at any GNU archive site, in case
355126a8a12Smrg         some other package would contain this missing \`$1' program."
356126a8a12Smrg    exit 1
357126a8a12Smrg    ;;
358126a8a12Smrgesac
359126a8a12Smrg
360126a8a12Smrgexit 0
361126a8a12Smrg
362126a8a12Smrg# Local variables:
363126a8a12Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
364126a8a12Smrg# time-stamp-start: "scriptversion="
365126a8a12Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
366126a8a12Smrg# time-stamp-end: "$"
367126a8a12Smrg# End:
368