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