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