missing revision 100ae103
1100ae103Smrg#! /bin/sh
2100ae103Smrg# Common stub for a few missing GNU programs while installing.
3100ae103Smrg
4100ae103Smrgscriptversion=2005-06-08.21
5100ae103Smrg
6100ae103Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
7100ae103Smrg#   Free Software Foundation, Inc.
8100ae103Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9100ae103Smrg
10100ae103Smrg# This program is free software; you can redistribute it and/or modify
11100ae103Smrg# it under the terms of the GNU General Public License as published by
12100ae103Smrg# the Free Software Foundation; either version 2, or (at your option)
13100ae103Smrg# any later version.
14100ae103Smrg
15100ae103Smrg# This program is distributed in the hope that it will be useful,
16100ae103Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17100ae103Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18100ae103Smrg# GNU General Public License for more details.
19100ae103Smrg
20100ae103Smrg# You should have received a copy of the GNU General Public License
21100ae103Smrg# along with this program; if not, write to the Free Software
22100ae103Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23100ae103Smrg# 02110-1301, USA.
24100ae103Smrg
25100ae103Smrg# As a special exception to the GNU General Public License, if you
26100ae103Smrg# distribute this file as part of a program that contains a
27100ae103Smrg# configuration script generated by Autoconf, you may include it under
28100ae103Smrg# the same distribution terms that you use for the rest of that program.
29100ae103Smrg
30100ae103Smrgif test $# -eq 0; then
31100ae103Smrg  echo 1>&2 "Try \`$0 --help' for more information"
32100ae103Smrg  exit 1
33100ae103Smrgfi
34100ae103Smrg
35100ae103Smrgrun=:
36100ae103Smrg
37100ae103Smrg# In the cases where this matters, `missing' is being run in the
38100ae103Smrg# srcdir already.
39100ae103Smrgif test -f configure.ac; then
40100ae103Smrg  configure_ac=configure.ac
41100ae103Smrgelse
42100ae103Smrg  configure_ac=configure.in
43100ae103Smrgfi
44100ae103Smrg
45100ae103Smrgmsg="missing on your system"
46100ae103Smrg
47100ae103Smrgcase "$1" in
48100ae103Smrg--run)
49100ae103Smrg  # Try to run requested program, and just exit if it succeeds.
50100ae103Smrg  run=
51100ae103Smrg  shift
52100ae103Smrg  "$@" && exit 0
53100ae103Smrg  # Exit code 63 means version mismatch.  This often happens
54100ae103Smrg  # when the user try to use an ancient version of a tool on
55100ae103Smrg  # a file that requires a minimum version.  In this case we
56100ae103Smrg  # we should proceed has if the program had been absent, or
57100ae103Smrg  # if --run hadn't been passed.
58100ae103Smrg  if test $? = 63; then
59100ae103Smrg    run=:
60100ae103Smrg    msg="probably too old"
61100ae103Smrg  fi
62100ae103Smrg  ;;
63100ae103Smrg
64100ae103Smrg  -h|--h|--he|--hel|--help)
65100ae103Smrg    echo "\
66100ae103Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67100ae103Smrg
68100ae103SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69100ae103Smrgerror status if there is no known handling for PROGRAM.
70100ae103Smrg
71100ae103SmrgOptions:
72100ae103Smrg  -h, --help      display this help and exit
73100ae103Smrg  -v, --version   output version information and exit
74100ae103Smrg  --run           try to run the given command, and emulate it if it fails
75100ae103Smrg
76100ae103SmrgSupported PROGRAM values:
77100ae103Smrg  aclocal      touch file \`aclocal.m4'
78100ae103Smrg  autoconf     touch file \`configure'
79100ae103Smrg  autoheader   touch file \`config.h.in'
80100ae103Smrg  automake     touch all \`Makefile.in' files
81100ae103Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
82100ae103Smrg  flex         create \`lex.yy.c', if possible, from existing .c
83100ae103Smrg  help2man     touch the output file
84100ae103Smrg  lex          create \`lex.yy.c', if possible, from existing .c
85100ae103Smrg  makeinfo     touch the output file
86100ae103Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
87100ae103Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
88100ae103Smrg
89100ae103SmrgSend bug reports to <bug-automake@gnu.org>."
90100ae103Smrg    exit $?
91100ae103Smrg    ;;
92100ae103Smrg
93100ae103Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
94100ae103Smrg    echo "missing $scriptversion (GNU Automake)"
95100ae103Smrg    exit $?
96100ae103Smrg    ;;
97100ae103Smrg
98100ae103Smrg  -*)
99100ae103Smrg    echo 1>&2 "$0: Unknown \`$1' option"
100100ae103Smrg    echo 1>&2 "Try \`$0 --help' for more information"
101100ae103Smrg    exit 1
102100ae103Smrg    ;;
103100ae103Smrg
104100ae103Smrgesac
105100ae103Smrg
106100ae103Smrg# Now exit if we have it, but it failed.  Also exit now if we
107100ae103Smrg# don't have it and --version was passed (most likely to detect
108100ae103Smrg# the program).
109100ae103Smrgcase "$1" in
110100ae103Smrg  lex|yacc)
111100ae103Smrg    # Not GNU programs, they don't have --version.
112100ae103Smrg    ;;
113100ae103Smrg
114100ae103Smrg  tar)
115100ae103Smrg    if test -n "$run"; then
116100ae103Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
117100ae103Smrg       exit 1
118100ae103Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
119100ae103Smrg       exit 1
120100ae103Smrg    fi
121100ae103Smrg    ;;
122100ae103Smrg
123100ae103Smrg  *)
124100ae103Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
125100ae103Smrg       # We have it, but it failed.
126100ae103Smrg       exit 1
127100ae103Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
128100ae103Smrg       # Could not run --version or --help.  This is probably someone
129100ae103Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
130100ae103Smrg       # $TOOL exists and not knowing $TOOL uses missing.
131100ae103Smrg       exit 1
132100ae103Smrg    fi
133100ae103Smrg    ;;
134100ae103Smrgesac
135100ae103Smrg
136100ae103Smrg# If it does not exist, or fails to run (possibly an outdated version),
137100ae103Smrg# try to emulate it.
138100ae103Smrgcase "$1" in
139100ae103Smrg  aclocal*)
140100ae103Smrg    echo 1>&2 "\
141100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
142100ae103Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
143100ae103Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
144100ae103Smrg         any GNU archive site."
145100ae103Smrg    touch aclocal.m4
146100ae103Smrg    ;;
147100ae103Smrg
148100ae103Smrg  autoconf)
149100ae103Smrg    echo 1>&2 "\
150100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
151100ae103Smrg         you modified \`${configure_ac}'.  You might want to install the
152100ae103Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
153100ae103Smrg         archive site."
154100ae103Smrg    touch configure
155100ae103Smrg    ;;
156100ae103Smrg
157100ae103Smrg  autoheader)
158100ae103Smrg    echo 1>&2 "\
159100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
160100ae103Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
161100ae103Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
162100ae103Smrg         from any GNU archive site."
163100ae103Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
164100ae103Smrg    test -z "$files" && files="config.h"
165100ae103Smrg    touch_files=
166100ae103Smrg    for f in $files; do
167100ae103Smrg      case "$f" in
168100ae103Smrg      *:*) touch_files="$touch_files "`echo "$f" |
169100ae103Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
170100ae103Smrg      *) touch_files="$touch_files $f.in";;
171100ae103Smrg      esac
172100ae103Smrg    done
173100ae103Smrg    touch $touch_files
174100ae103Smrg    ;;
175100ae103Smrg
176100ae103Smrg  automake*)
177100ae103Smrg    echo 1>&2 "\
178100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
179100ae103Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
180100ae103Smrg         You might want to install the \`Automake' and \`Perl' packages.
181100ae103Smrg         Grab them from any GNU archive site."
182100ae103Smrg    find . -type f -name Makefile.am -print |
183100ae103Smrg	   sed 's/\.am$/.in/' |
184100ae103Smrg	   while read f; do touch "$f"; done
185100ae103Smrg    ;;
186100ae103Smrg
187100ae103Smrg  autom4te)
188100ae103Smrg    echo 1>&2 "\
189100ae103SmrgWARNING: \`$1' is needed, but is $msg.
190100ae103Smrg         You might have modified some files without having the
191100ae103Smrg         proper tools for further handling them.
192100ae103Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
193100ae103Smrg         archive site."
194100ae103Smrg
195100ae103Smrg    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
196100ae103Smrg    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
197100ae103Smrg    if test -f "$file"; then
198100ae103Smrg	touch $file
199100ae103Smrg    else
200100ae103Smrg	test -z "$file" || exec >$file
201100ae103Smrg	echo "#! /bin/sh"
202100ae103Smrg	echo "# Created by GNU Automake missing as a replacement of"
203100ae103Smrg	echo "#  $ $@"
204100ae103Smrg	echo "exit 0"
205100ae103Smrg	chmod +x $file
206100ae103Smrg	exit 1
207100ae103Smrg    fi
208100ae103Smrg    ;;
209100ae103Smrg
210100ae103Smrg  bison|yacc)
211100ae103Smrg    echo 1>&2 "\
212100ae103SmrgWARNING: \`$1' $msg.  You should only need it if
213100ae103Smrg         you modified a \`.y' file.  You may need the \`Bison' package
214100ae103Smrg         in order for those modifications to take effect.  You can get
215100ae103Smrg         \`Bison' from any GNU archive site."
216100ae103Smrg    rm -f y.tab.c y.tab.h
217100ae103Smrg    if [ $# -ne 1 ]; then
218100ae103Smrg        eval LASTARG="\${$#}"
219100ae103Smrg	case "$LASTARG" in
220100ae103Smrg	*.y)
221100ae103Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
222100ae103Smrg	    if [ -f "$SRCFILE" ]; then
223100ae103Smrg	         cp "$SRCFILE" y.tab.c
224100ae103Smrg	    fi
225100ae103Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
226100ae103Smrg	    if [ -f "$SRCFILE" ]; then
227100ae103Smrg	         cp "$SRCFILE" y.tab.h
228100ae103Smrg	    fi
229100ae103Smrg	  ;;
230100ae103Smrg	esac
231100ae103Smrg    fi
232100ae103Smrg    if [ ! -f y.tab.h ]; then
233100ae103Smrg	echo >y.tab.h
234100ae103Smrg    fi
235100ae103Smrg    if [ ! -f y.tab.c ]; then
236100ae103Smrg	echo 'main() { return 0; }' >y.tab.c
237100ae103Smrg    fi
238100ae103Smrg    ;;
239100ae103Smrg
240100ae103Smrg  lex|flex)
241100ae103Smrg    echo 1>&2 "\
242100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
243100ae103Smrg         you modified a \`.l' file.  You may need the \`Flex' package
244100ae103Smrg         in order for those modifications to take effect.  You can get
245100ae103Smrg         \`Flex' from any GNU archive site."
246100ae103Smrg    rm -f lex.yy.c
247100ae103Smrg    if [ $# -ne 1 ]; then
248100ae103Smrg        eval LASTARG="\${$#}"
249100ae103Smrg	case "$LASTARG" in
250100ae103Smrg	*.l)
251100ae103Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
252100ae103Smrg	    if [ -f "$SRCFILE" ]; then
253100ae103Smrg	         cp "$SRCFILE" lex.yy.c
254100ae103Smrg	    fi
255100ae103Smrg	  ;;
256100ae103Smrg	esac
257100ae103Smrg    fi
258100ae103Smrg    if [ ! -f lex.yy.c ]; then
259100ae103Smrg	echo 'main() { return 0; }' >lex.yy.c
260100ae103Smrg    fi
261100ae103Smrg    ;;
262100ae103Smrg
263100ae103Smrg  help2man)
264100ae103Smrg    echo 1>&2 "\
265100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
266100ae103Smrg	 you modified a dependency of a manual page.  You may need the
267100ae103Smrg	 \`Help2man' package in order for those modifications to take
268100ae103Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
269100ae103Smrg
270100ae103Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
271100ae103Smrg    if test -z "$file"; then
272100ae103Smrg	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
273100ae103Smrg    fi
274100ae103Smrg    if [ -f "$file" ]; then
275100ae103Smrg	touch $file
276100ae103Smrg    else
277100ae103Smrg	test -z "$file" || exec >$file
278100ae103Smrg	echo ".ab help2man is required to generate this page"
279100ae103Smrg	exit 1
280100ae103Smrg    fi
281100ae103Smrg    ;;
282100ae103Smrg
283100ae103Smrg  makeinfo)
284100ae103Smrg    echo 1>&2 "\
285100ae103SmrgWARNING: \`$1' is $msg.  You should only need it if
286100ae103Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
287100ae103Smrg         indirectly affecting the aspect of the manual.  The spurious
288100ae103Smrg         call might also be the consequence of using a buggy \`make' (AIX,
289100ae103Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
290100ae103Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
291100ae103Smrg    # The file to touch is that specified with -o ...
292100ae103Smrg    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
293100ae103Smrg    if test -z "$file"; then
294100ae103Smrg      # ... or it is the one specified with @setfilename ...
295100ae103Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
296100ae103Smrg      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
297100ae103Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
298100ae103Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
299100ae103Smrg    fi
300100ae103Smrg    # If the file does not exist, the user really needs makeinfo;
301100ae103Smrg    # let's fail without touching anything.
302100ae103Smrg    test -f $file || exit 1
303100ae103Smrg    touch $file
304100ae103Smrg    ;;
305100ae103Smrg
306100ae103Smrg  tar)
307100ae103Smrg    shift
308100ae103Smrg
309100ae103Smrg    # We have already tried tar in the generic part.
310100ae103Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
311100ae103Smrg    # messages.
312100ae103Smrg    if (gnutar --version > /dev/null 2>&1); then
313100ae103Smrg       gnutar "$@" && exit 0
314100ae103Smrg    fi
315100ae103Smrg    if (gtar --version > /dev/null 2>&1); then
316100ae103Smrg       gtar "$@" && exit 0
317100ae103Smrg    fi
318100ae103Smrg    firstarg="$1"
319100ae103Smrg    if shift; then
320100ae103Smrg	case "$firstarg" in
321100ae103Smrg	*o*)
322100ae103Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
323100ae103Smrg	    tar "$firstarg" "$@" && exit 0
324100ae103Smrg	    ;;
325100ae103Smrg	esac
326100ae103Smrg	case "$firstarg" in
327100ae103Smrg	*h*)
328100ae103Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
329100ae103Smrg	    tar "$firstarg" "$@" && exit 0
330100ae103Smrg	    ;;
331100ae103Smrg	esac
332100ae103Smrg    fi
333100ae103Smrg
334100ae103Smrg    echo 1>&2 "\
335100ae103SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
336100ae103Smrg         You may want to install GNU tar or Free paxutils, or check the
337100ae103Smrg         command line arguments."
338100ae103Smrg    exit 1
339100ae103Smrg    ;;
340100ae103Smrg
341100ae103Smrg  *)
342100ae103Smrg    echo 1>&2 "\
343100ae103SmrgWARNING: \`$1' is needed, and is $msg.
344100ae103Smrg         You might have modified some files without having the
345100ae103Smrg         proper tools for further handling them.  Check the \`README' file,
346100ae103Smrg         it often tells you about the needed prerequisites for installing
347100ae103Smrg         this package.  You may also peek at any GNU archive site, in case
348100ae103Smrg         some other package would contain this missing \`$1' program."
349100ae103Smrg    exit 1
350100ae103Smrg    ;;
351100ae103Smrgesac
352100ae103Smrg
353100ae103Smrgexit 0
354100ae103Smrg
355100ae103Smrg# Local variables:
356100ae103Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
357100ae103Smrg# time-stamp-start: "scriptversion="
358100ae103Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
359100ae103Smrg# time-stamp-end: "$"
360100ae103Smrg# End:
361