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