missing revision 382ff0af
1382ff0afSmrg#! /bin/sh
2382ff0afSmrg# Common stub for a few missing GNU programs while installing.
3382ff0afSmrg
4382ff0afSmrgscriptversion=2005-06-08.21
5382ff0afSmrg
6382ff0afSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7382ff0afSmrg#   Free Software Foundation, Inc.
8382ff0afSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9382ff0afSmrg
10382ff0afSmrg# This program is free software; you can redistribute it and/or modify
11382ff0afSmrg# it under the terms of the GNU General Public License as published by
12382ff0afSmrg# the Free Software Foundation; either version 2, or (at your option)
13382ff0afSmrg# any later version.
14382ff0afSmrg
15382ff0afSmrg# This program is distributed in the hope that it will be useful,
16382ff0afSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17382ff0afSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18382ff0afSmrg# GNU General Public License for more details.
19382ff0afSmrg
20382ff0afSmrg# You should have received a copy of the GNU General Public License
21382ff0afSmrg# along with this program; if not, write to the Free Software
22382ff0afSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23382ff0afSmrg# 02110-1301, USA.
24382ff0afSmrg
25382ff0afSmrg# As a special exception to the GNU General Public License, if you
26382ff0afSmrg# distribute this file as part of a program that contains a
27382ff0afSmrg# configuration script generated by Autoconf, you may include it under
28382ff0afSmrg# the same distribution terms that you use for the rest of that program.
29382ff0afSmrg
30382ff0afSmrgif test $# -eq 0; then
31382ff0afSmrg  echo 1>&2 "Try \`$0 --help' for more information"
32382ff0afSmrg  exit 1
33382ff0afSmrgfi
34382ff0afSmrg
35382ff0afSmrgrun=:
36382ff0afSmrg
37382ff0afSmrg# In the cases where this matters, `missing' is being run in the
38382ff0afSmrg# srcdir already.
39382ff0afSmrgif test -f configure.ac; then
40382ff0afSmrg  configure_ac=configure.ac
41382ff0afSmrgelse
42382ff0afSmrg  configure_ac=configure.in
43382ff0afSmrgfi
44382ff0afSmrg
45382ff0afSmrgmsg="missing on your system"
46382ff0afSmrg
47382ff0afSmrgcase "$1" in
48382ff0afSmrg--run)
49382ff0afSmrg  # Try to run requested program, and just exit if it succeeds.
50382ff0afSmrg  run=
51382ff0afSmrg  shift
52382ff0afSmrg  "$@" && exit 0
53382ff0afSmrg  # Exit code 63 means version mismatch.  This often happens
54382ff0afSmrg  # when the user try to use an ancient version of a tool on
55382ff0afSmrg  # a file that requires a minimum version.  In this case we
56382ff0afSmrg  # we should proceed has if the program had been absent, or
57382ff0afSmrg  # if --run hadn't been passed.
58382ff0afSmrg  if test $? = 63; then
59382ff0afSmrg    run=:
60382ff0afSmrg    msg="probably too old"
61382ff0afSmrg  fi
62382ff0afSmrg  ;;
63382ff0afSmrg
64382ff0afSmrg  -h|--h|--he|--hel|--help)
65382ff0afSmrg    echo "\
66382ff0afSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67382ff0afSmrg
68382ff0afSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69382ff0afSmrgerror status if there is no known handling for PROGRAM.
70382ff0afSmrg
71382ff0afSmrgOptions:
72382ff0afSmrg  -h, --help      display this help and exit
73382ff0afSmrg  -v, --version   output version information and exit
74382ff0afSmrg  --run           try to run the given command, and emulate it if it fails
75382ff0afSmrg
76382ff0afSmrgSupported PROGRAM values:
77382ff0afSmrg  aclocal      touch file \`aclocal.m4'
78382ff0afSmrg  autoconf     touch file \`configure'
79382ff0afSmrg  autoheader   touch file \`config.h.in'
80382ff0afSmrg  automake     touch all \`Makefile.in' files
81382ff0afSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
82382ff0afSmrg  flex         create \`lex.yy.c', if possible, from existing .c
83382ff0afSmrg  help2man     touch the output file
84382ff0afSmrg  lex          create \`lex.yy.c', if possible, from existing .c
85382ff0afSmrg  makeinfo     touch the output file
86382ff0afSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
87382ff0afSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88382ff0afSmrg
89382ff0afSmrgSend bug reports to <bug-automake@gnu.org>."
90382ff0afSmrg    exit $?
91382ff0afSmrg    ;;
92382ff0afSmrg
93382ff0afSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94382ff0afSmrg    echo "missing $scriptversion (GNU Automake)"
95382ff0afSmrg    exit $?
96382ff0afSmrg    ;;
97382ff0afSmrg
98382ff0afSmrg  -*)
99382ff0afSmrg    echo 1>&2 "$0: Unknown \`$1' option"
100382ff0afSmrg    echo 1>&2 "Try \`$0 --help' for more information"
101382ff0afSmrg    exit 1
102382ff0afSmrg    ;;
103382ff0afSmrg
104382ff0afSmrgesac
105382ff0afSmrg
106382ff0afSmrg# Now exit if we have it, but it failed.  Also exit now if we
107382ff0afSmrg# don't have it and --version was passed (most likely to detect
108382ff0afSmrg# the program).
109382ff0afSmrgcase "$1" in
110382ff0afSmrg  lex|yacc)
111382ff0afSmrg    # Not GNU programs, they don't have --version.
112382ff0afSmrg    ;;
113382ff0afSmrg
114382ff0afSmrg  tar)
115382ff0afSmrg    if test -n "$run"; then
116382ff0afSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
117382ff0afSmrg       exit 1
118382ff0afSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119382ff0afSmrg       exit 1
120382ff0afSmrg    fi
121382ff0afSmrg    ;;
122382ff0afSmrg
123382ff0afSmrg  *)
124382ff0afSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125382ff0afSmrg       # We have it, but it failed.
126382ff0afSmrg       exit 1
127382ff0afSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128382ff0afSmrg       # Could not run --version or --help.  This is probably someone
129382ff0afSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
130382ff0afSmrg       # $TOOL exists and not knowing $TOOL uses missing.
131382ff0afSmrg       exit 1
132382ff0afSmrg    fi
133382ff0afSmrg    ;;
134382ff0afSmrgesac
135382ff0afSmrg
136382ff0afSmrg# If it does not exist, or fails to run (possibly an outdated version),
137382ff0afSmrg# try to emulate it.
138382ff0afSmrgcase "$1" in
139382ff0afSmrg  aclocal*)
140382ff0afSmrg    echo 1>&2 "\
141382ff0afSmrgWARNING: \`$1' is $msg.  You should only need it if
142382ff0afSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143382ff0afSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
144382ff0afSmrg         any GNU archive site."
145382ff0afSmrg    touch aclocal.m4
146382ff0afSmrg    ;;
147382ff0afSmrg
148382ff0afSmrg  autoconf)
149382ff0afSmrg    echo 1>&2 "\
150382ff0afSmrgWARNING: \`$1' is $msg.  You should only need it if
151382ff0afSmrg         you modified \`${configure_ac}'.  You might want to install the
152382ff0afSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153382ff0afSmrg         archive site."
154382ff0afSmrg    touch configure
155382ff0afSmrg    ;;
156382ff0afSmrg
157382ff0afSmrg  autoheader)
158382ff0afSmrg    echo 1>&2 "\
159382ff0afSmrgWARNING: \`$1' is $msg.  You should only need it if
160382ff0afSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161382ff0afSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162382ff0afSmrg         from any GNU archive site."
163382ff0afSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164382ff0afSmrg    test -z "$files" && files="config.h"
165382ff0afSmrg    touch_files=
166382ff0afSmrg    for f in $files; do
167382ff0afSmrg      case "$f" in
168382ff0afSmrg      *:*) touch_files="$touch_files "`echo "$f" |
169382ff0afSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170382ff0afSmrg      *) touch_files="$touch_files $f.in";;
171382ff0afSmrg      esac
172382ff0afSmrg    done
173382ff0afSmrg    touch $touch_files
174382ff0afSmrg    ;;
175382ff0afSmrg
176382ff0afSmrg  automake*)
177382ff0afSmrg    echo 1>&2 "\
178382ff0afSmrgWARNING: \`$1' is $msg.  You should only need it if
179382ff0afSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180382ff0afSmrg         You might want to install the \`Automake' and \`Perl' packages.
181382ff0afSmrg         Grab them from any GNU archive site."
182382ff0afSmrg    find . -type f -name Makefile.am -print |
183382ff0afSmrg	   sed 's/\.am$/.in/' |
184382ff0afSmrg	   while read f; do touch "$f"; done
185382ff0afSmrg    ;;
186382ff0afSmrg
187382ff0afSmrg  autom4te)
188382ff0afSmrg    echo 1>&2 "\
189382ff0afSmrgWARNING: \`$1' is needed, but is $msg.
190382ff0afSmrg         You might have modified some files without having the
191382ff0afSmrg         proper tools for further handling them.
192382ff0afSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
193382ff0afSmrg         archive site."
194382ff0afSmrg
195382ff0afSmrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196382ff0afSmrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197382ff0afSmrg    if test -f "$file"; then
198382ff0afSmrg	touch $file
199382ff0afSmrg    else
200382ff0afSmrg	test -z "$file" || exec >$file
201382ff0afSmrg	echo "#! /bin/sh"
202382ff0afSmrg	echo "# Created by GNU Automake missing as a replacement of"
203382ff0afSmrg	echo "#  $ $@"
204382ff0afSmrg	echo "exit 0"
205382ff0afSmrg	chmod +x $file
206382ff0afSmrg	exit 1
207382ff0afSmrg    fi
208382ff0afSmrg    ;;
209382ff0afSmrg
210382ff0afSmrg  bison|yacc)
211382ff0afSmrg    echo 1>&2 "\
212382ff0afSmrgWARNING: \`$1' $msg.  You should only need it if
213382ff0afSmrg         you modified a \`.y' file.  You may need the \`Bison' package
214382ff0afSmrg         in order for those modifications to take effect.  You can get
215382ff0afSmrg         \`Bison' from any GNU archive site."
216382ff0afSmrg    rm -f y.tab.c y.tab.h
217382ff0afSmrg    if [ $# -ne 1 ]; then
218382ff0afSmrg        eval LASTARG="\${$#}"
219382ff0afSmrg	case "$LASTARG" in
220382ff0afSmrg	*.y)
221382ff0afSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222382ff0afSmrg	    if [ -f "$SRCFILE" ]; then
223382ff0afSmrg	         cp "$SRCFILE" y.tab.c
224382ff0afSmrg	    fi
225382ff0afSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226382ff0afSmrg	    if [ -f "$SRCFILE" ]; then
227382ff0afSmrg	         cp "$SRCFILE" y.tab.h
228382ff0afSmrg	    fi
229382ff0afSmrg	  ;;
230382ff0afSmrg	esac
231382ff0afSmrg    fi
232382ff0afSmrg    if [ ! -f y.tab.h ]; then
233382ff0afSmrg	echo >y.tab.h
234382ff0afSmrg    fi
235382ff0afSmrg    if [ ! -f y.tab.c ]; then
236382ff0afSmrg	echo 'main() { return 0; }' >y.tab.c
237382ff0afSmrg    fi
238382ff0afSmrg    ;;
239382ff0afSmrg
240382ff0afSmrg  lex|flex)
241382ff0afSmrg    echo 1>&2 "\
242382ff0afSmrgWARNING: \`$1' is $msg.  You should only need it if
243382ff0afSmrg         you modified a \`.l' file.  You may need the \`Flex' package
244382ff0afSmrg         in order for those modifications to take effect.  You can get
245382ff0afSmrg         \`Flex' from any GNU archive site."
246382ff0afSmrg    rm -f lex.yy.c
247382ff0afSmrg    if [ $# -ne 1 ]; then
248382ff0afSmrg        eval LASTARG="\${$#}"
249382ff0afSmrg	case "$LASTARG" in
250382ff0afSmrg	*.l)
251382ff0afSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252382ff0afSmrg	    if [ -f "$SRCFILE" ]; then
253382ff0afSmrg	         cp "$SRCFILE" lex.yy.c
254382ff0afSmrg	    fi
255382ff0afSmrg	  ;;
256382ff0afSmrg	esac
257382ff0afSmrg    fi
258382ff0afSmrg    if [ ! -f lex.yy.c ]; then
259382ff0afSmrg	echo 'main() { return 0; }' >lex.yy.c
260382ff0afSmrg    fi
261382ff0afSmrg    ;;
262382ff0afSmrg
263382ff0afSmrg  help2man)
264382ff0afSmrg    echo 1>&2 "\
265382ff0afSmrgWARNING: \`$1' is $msg.  You should only need it if
266382ff0afSmrg	 you modified a dependency of a manual page.  You may need the
267382ff0afSmrg	 \`Help2man' package in order for those modifications to take
268382ff0afSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
269382ff0afSmrg
270382ff0afSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271382ff0afSmrg    if test -z "$file"; then
272382ff0afSmrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273382ff0afSmrg    fi
274382ff0afSmrg    if [ -f "$file" ]; then
275382ff0afSmrg	touch $file
276382ff0afSmrg    else
277382ff0afSmrg	test -z "$file" || exec >$file
278382ff0afSmrg	echo ".ab help2man is required to generate this page"
279382ff0afSmrg	exit 1
280382ff0afSmrg    fi
281382ff0afSmrg    ;;
282382ff0afSmrg
283382ff0afSmrg  makeinfo)
284382ff0afSmrg    echo 1>&2 "\
285382ff0afSmrgWARNING: \`$1' is $msg.  You should only need it if
286382ff0afSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
287382ff0afSmrg         indirectly affecting the aspect of the manual.  The spurious
288382ff0afSmrg         call might also be the consequence of using a buggy \`make' (AIX,
289382ff0afSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
290382ff0afSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
291382ff0afSmrg    # The file to touch is that specified with -o ...
292382ff0afSmrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
293382ff0afSmrg    if test -z "$file"; then
294382ff0afSmrg      # ... or it is the one specified with @setfilename ...
295382ff0afSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296382ff0afSmrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297382ff0afSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298382ff0afSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
299382ff0afSmrg    fi
300382ff0afSmrg    # If the file does not exist, the user really needs makeinfo;
301382ff0afSmrg    # let's fail without touching anything.
302382ff0afSmrg    test -f $file || exit 1
303382ff0afSmrg    touch $file
304382ff0afSmrg    ;;
305382ff0afSmrg
306382ff0afSmrg  tar)
307382ff0afSmrg    shift
308382ff0afSmrg
309382ff0afSmrg    # We have already tried tar in the generic part.
310382ff0afSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
311382ff0afSmrg    # messages.
312382ff0afSmrg    if (gnutar --version > /dev/null 2>&1); then
313382ff0afSmrg       gnutar "$@" && exit 0
314382ff0afSmrg    fi
315382ff0afSmrg    if (gtar --version > /dev/null 2>&1); then
316382ff0afSmrg       gtar "$@" && exit 0
317382ff0afSmrg    fi
318382ff0afSmrg    firstarg="$1"
319382ff0afSmrg    if shift; then
320382ff0afSmrg	case "$firstarg" in
321382ff0afSmrg	*o*)
322382ff0afSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
323382ff0afSmrg	    tar "$firstarg" "$@" && exit 0
324382ff0afSmrg	    ;;
325382ff0afSmrg	esac
326382ff0afSmrg	case "$firstarg" in
327382ff0afSmrg	*h*)
328382ff0afSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
329382ff0afSmrg	    tar "$firstarg" "$@" && exit 0
330382ff0afSmrg	    ;;
331382ff0afSmrg	esac
332382ff0afSmrg    fi
333382ff0afSmrg
334382ff0afSmrg    echo 1>&2 "\
335382ff0afSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
336382ff0afSmrg         You may want to install GNU tar or Free paxutils, or check the
337382ff0afSmrg         command line arguments."
338382ff0afSmrg    exit 1
339382ff0afSmrg    ;;
340382ff0afSmrg
341382ff0afSmrg  *)
342382ff0afSmrg    echo 1>&2 "\
343382ff0afSmrgWARNING: \`$1' is needed, and is $msg.
344382ff0afSmrg         You might have modified some files without having the
345382ff0afSmrg         proper tools for further handling them.  Check the \`README' file,
346382ff0afSmrg         it often tells you about the needed prerequisites for installing
347382ff0afSmrg         this package.  You may also peek at any GNU archive site, in case
348382ff0afSmrg         some other package would contain this missing \`$1' program."
349382ff0afSmrg    exit 1
350382ff0afSmrg    ;;
351382ff0afSmrgesac
352382ff0afSmrg
353382ff0afSmrgexit 0
354382ff0afSmrg
355382ff0afSmrg# Local variables:
356382ff0afSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
357382ff0afSmrg# time-stamp-start: "scriptversion="
358382ff0afSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
359382ff0afSmrg# time-stamp-end: "$"
360382ff0afSmrg# End:
361