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