missing revision b3eb03f3
1010cdda0Smrg#! /bin/sh
2010cdda0Smrg# Common stub for a few missing GNU programs while installing.
3b3eb03f3Smrg
4b3eb03f3Smrgscriptversion=2009-04-28.21; # UTC
5b3eb03f3Smrg
6b3eb03f3Smrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
7b3eb03f3Smrg# 2008, 2009 Free Software Foundation, Inc.
8010cdda0Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9010cdda0Smrg
10010cdda0Smrg# This program is free software; you can redistribute it and/or modify
11010cdda0Smrg# it under the terms of the GNU General Public License as published by
12010cdda0Smrg# the Free Software Foundation; either version 2, or (at your option)
13010cdda0Smrg# any later version.
14010cdda0Smrg
15010cdda0Smrg# This program is distributed in the hope that it will be useful,
16010cdda0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17010cdda0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18010cdda0Smrg# GNU General Public License for more details.
19010cdda0Smrg
20010cdda0Smrg# You should have received a copy of the GNU General Public License
21b3eb03f3Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22010cdda0Smrg
23010cdda0Smrg# As a special exception to the GNU General Public License, if you
24010cdda0Smrg# distribute this file as part of a program that contains a
25010cdda0Smrg# configuration script generated by Autoconf, you may include it under
26010cdda0Smrg# the same distribution terms that you use for the rest of that program.
27010cdda0Smrg
28010cdda0Smrgif test $# -eq 0; then
29010cdda0Smrg  echo 1>&2 "Try \`$0 --help' for more information"
30010cdda0Smrg  exit 1
31010cdda0Smrgfi
32010cdda0Smrg
33010cdda0Smrgrun=:
34b3eb03f3Smrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
35b3eb03f3Smrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36010cdda0Smrg
37010cdda0Smrg# In the cases where this matters, `missing' is being run in the
38010cdda0Smrg# srcdir already.
39010cdda0Smrgif test -f configure.ac; then
40010cdda0Smrg  configure_ac=configure.ac
41010cdda0Smrgelse
42010cdda0Smrg  configure_ac=configure.in
43010cdda0Smrgfi
44010cdda0Smrg
45b3eb03f3Smrgmsg="missing on your system"
46b3eb03f3Smrg
47b3eb03f3Smrgcase $1 in
48010cdda0Smrg--run)
49010cdda0Smrg  # Try to run requested program, and just exit if it succeeds.
50010cdda0Smrg  run=
51010cdda0Smrg  shift
52010cdda0Smrg  "$@" && exit 0
53b3eb03f3Smrg  # Exit code 63 means version mismatch.  This often happens
54b3eb03f3Smrg  # when the user try to use an ancient version of a tool on
55b3eb03f3Smrg  # a file that requires a minimum version.  In this case we
56b3eb03f3Smrg  # we should proceed has if the program had been absent, or
57b3eb03f3Smrg  # if --run hadn't been passed.
58b3eb03f3Smrg  if test $? = 63; then
59b3eb03f3Smrg    run=:
60b3eb03f3Smrg    msg="probably too old"
61b3eb03f3Smrg  fi
62010cdda0Smrg  ;;
63010cdda0Smrg
64010cdda0Smrg  -h|--h|--he|--hel|--help)
65010cdda0Smrg    echo "\
66010cdda0Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67010cdda0Smrg
68010cdda0SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69010cdda0Smrgerror status if there is no known handling for PROGRAM.
70010cdda0Smrg
71010cdda0SmrgOptions:
72010cdda0Smrg  -h, --help      display this help and exit
73010cdda0Smrg  -v, --version   output version information and exit
74010cdda0Smrg  --run           try to run the given command, and emulate it if it fails
75010cdda0Smrg
76010cdda0SmrgSupported PROGRAM values:
77010cdda0Smrg  aclocal      touch file \`aclocal.m4'
78010cdda0Smrg  autoconf     touch file \`configure'
79010cdda0Smrg  autoheader   touch file \`config.h.in'
80b3eb03f3Smrg  autom4te     touch the output file, or create a stub one
81010cdda0Smrg  automake     touch all \`Makefile.in' files
82010cdda0Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83010cdda0Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84010cdda0Smrg  help2man     touch the output file
85010cdda0Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86010cdda0Smrg  makeinfo     touch the output file
87010cdda0Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
88b3eb03f3Smrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
89b3eb03f3Smrg
90b3eb03f3SmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
91b3eb03f3Smrg\`g' are ignored when checking the name.
92b3eb03f3Smrg
93b3eb03f3SmrgSend bug reports to <bug-automake@gnu.org>."
94b3eb03f3Smrg    exit $?
95010cdda0Smrg    ;;
96010cdda0Smrg
97010cdda0Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
98b3eb03f3Smrg    echo "missing $scriptversion (GNU Automake)"
99b3eb03f3Smrg    exit $?
100010cdda0Smrg    ;;
101010cdda0Smrg
102010cdda0Smrg  -*)
103010cdda0Smrg    echo 1>&2 "$0: Unknown \`$1' option"
104010cdda0Smrg    echo 1>&2 "Try \`$0 --help' for more information"
105010cdda0Smrg    exit 1
106010cdda0Smrg    ;;
107010cdda0Smrg
108b3eb03f3Smrgesac
109b3eb03f3Smrg
110b3eb03f3Smrg# normalize program name to check for.
111b3eb03f3Smrgprogram=`echo "$1" | sed '
112b3eb03f3Smrg  s/^gnu-//; t
113b3eb03f3Smrg  s/^gnu//; t
114b3eb03f3Smrg  s/^g//; t'`
115b3eb03f3Smrg
116b3eb03f3Smrg# Now exit if we have it, but it failed.  Also exit now if we
117b3eb03f3Smrg# don't have it and --version was passed (most likely to detect
118b3eb03f3Smrg# the program).  This is about non-GNU programs, so use $1 not
119b3eb03f3Smrg# $program.
120b3eb03f3Smrgcase $1 in
121b3eb03f3Smrg  lex*|yacc*)
122b3eb03f3Smrg    # Not GNU programs, they don't have --version.
123b3eb03f3Smrg    ;;
124b3eb03f3Smrg
125b3eb03f3Smrg  tar*)
126b3eb03f3Smrg    if test -n "$run"; then
127b3eb03f3Smrg       echo 1>&2 "ERROR: \`tar' requires --run"
128b3eb03f3Smrg       exit 1
129b3eb03f3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
130b3eb03f3Smrg       exit 1
131b3eb03f3Smrg    fi
132b3eb03f3Smrg    ;;
133b3eb03f3Smrg
134b3eb03f3Smrg  *)
135010cdda0Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136010cdda0Smrg       # We have it, but it failed.
137010cdda0Smrg       exit 1
138b3eb03f3Smrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
139b3eb03f3Smrg       # Could not run --version or --help.  This is probably someone
140b3eb03f3Smrg       # running `$TOOL --version' or `$TOOL --help' to check whether
141b3eb03f3Smrg       # $TOOL exists and not knowing $TOOL uses missing.
142b3eb03f3Smrg       exit 1
143010cdda0Smrg    fi
144b3eb03f3Smrg    ;;
145b3eb03f3Smrgesac
146010cdda0Smrg
147b3eb03f3Smrg# If it does not exist, or fails to run (possibly an outdated version),
148b3eb03f3Smrg# try to emulate it.
149b3eb03f3Smrgcase $program in
150b3eb03f3Smrg  aclocal*)
151010cdda0Smrg    echo 1>&2 "\
152b3eb03f3SmrgWARNING: \`$1' is $msg.  You should only need it if
153010cdda0Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154010cdda0Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155010cdda0Smrg         any GNU archive site."
156010cdda0Smrg    touch aclocal.m4
157010cdda0Smrg    ;;
158010cdda0Smrg
159b3eb03f3Smrg  autoconf*)
160010cdda0Smrg    echo 1>&2 "\
161b3eb03f3SmrgWARNING: \`$1' is $msg.  You should only need it if
162010cdda0Smrg         you modified \`${configure_ac}'.  You might want to install the
163010cdda0Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164010cdda0Smrg         archive site."
165010cdda0Smrg    touch configure
166010cdda0Smrg    ;;
167010cdda0Smrg
168b3eb03f3Smrg  autoheader*)
169010cdda0Smrg    echo 1>&2 "\
170b3eb03f3SmrgWARNING: \`$1' is $msg.  You should only need it if
171010cdda0Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172010cdda0Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173010cdda0Smrg         from any GNU archive site."
174010cdda0Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175010cdda0Smrg    test -z "$files" && files="config.h"
176010cdda0Smrg    touch_files=
177010cdda0Smrg    for f in $files; do
178b3eb03f3Smrg      case $f in
179010cdda0Smrg      *:*) touch_files="$touch_files "`echo "$f" |
180010cdda0Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181010cdda0Smrg      *) touch_files="$touch_files $f.in";;
182010cdda0Smrg      esac
183010cdda0Smrg    done
184010cdda0Smrg    touch $touch_files
185010cdda0Smrg    ;;
186010cdda0Smrg
187010cdda0Smrg  automake*)
188010cdda0Smrg    echo 1>&2 "\
189b3eb03f3SmrgWARNING: \`$1' is $msg.  You should only need it if
190010cdda0Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191010cdda0Smrg         You might want to install the \`Automake' and \`Perl' packages.
192010cdda0Smrg         Grab them from any GNU archive site."
193010cdda0Smrg    find . -type f -name Makefile.am -print |
194010cdda0Smrg	   sed 's/\.am$/.in/' |
195010cdda0Smrg	   while read f; do touch "$f"; done
196010cdda0Smrg    ;;
197010cdda0Smrg
198b3eb03f3Smrg  autom4te*)
199010cdda0Smrg    echo 1>&2 "\
200b3eb03f3SmrgWARNING: \`$1' is needed, but is $msg.
201b3eb03f3Smrg         You might have modified some files without having the
202010cdda0Smrg         proper tools for further handling them.
203010cdda0Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
204010cdda0Smrg         archive site."
205010cdda0Smrg
206b3eb03f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
207b3eb03f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208010cdda0Smrg    if test -f "$file"; then
209010cdda0Smrg	touch $file
210010cdda0Smrg    else
211010cdda0Smrg	test -z "$file" || exec >$file
212010cdda0Smrg	echo "#! /bin/sh"
213010cdda0Smrg	echo "# Created by GNU Automake missing as a replacement of"
214010cdda0Smrg	echo "#  $ $@"
215010cdda0Smrg	echo "exit 0"
216010cdda0Smrg	chmod +x $file
217010cdda0Smrg	exit 1
218010cdda0Smrg    fi
219010cdda0Smrg    ;;
220010cdda0Smrg
221b3eb03f3Smrg  bison*|yacc*)
222010cdda0Smrg    echo 1>&2 "\
223b3eb03f3SmrgWARNING: \`$1' $msg.  You should only need it if
224010cdda0Smrg         you modified a \`.y' file.  You may need the \`Bison' package
225010cdda0Smrg         in order for those modifications to take effect.  You can get
226010cdda0Smrg         \`Bison' from any GNU archive site."
227010cdda0Smrg    rm -f y.tab.c y.tab.h
228b3eb03f3Smrg    if test $# -ne 1; then
229010cdda0Smrg        eval LASTARG="\${$#}"
230b3eb03f3Smrg	case $LASTARG in
231010cdda0Smrg	*.y)
232010cdda0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
233b3eb03f3Smrg	    if test -f "$SRCFILE"; then
234010cdda0Smrg	         cp "$SRCFILE" y.tab.c
235010cdda0Smrg	    fi
236010cdda0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
237b3eb03f3Smrg	    if test -f "$SRCFILE"; then
238010cdda0Smrg	         cp "$SRCFILE" y.tab.h
239010cdda0Smrg	    fi
240010cdda0Smrg	  ;;
241010cdda0Smrg	esac
242010cdda0Smrg    fi
243b3eb03f3Smrg    if test ! -f y.tab.h; then
244010cdda0Smrg	echo >y.tab.h
245010cdda0Smrg    fi
246b3eb03f3Smrg    if test ! -f y.tab.c; then
247010cdda0Smrg	echo 'main() { return 0; }' >y.tab.c
248010cdda0Smrg    fi
249010cdda0Smrg    ;;
250010cdda0Smrg
251b3eb03f3Smrg  lex*|flex*)
252010cdda0Smrg    echo 1>&2 "\
253b3eb03f3SmrgWARNING: \`$1' is $msg.  You should only need it if
254010cdda0Smrg         you modified a \`.l' file.  You may need the \`Flex' package
255010cdda0Smrg         in order for those modifications to take effect.  You can get
256010cdda0Smrg         \`Flex' from any GNU archive site."
257010cdda0Smrg    rm -f lex.yy.c
258b3eb03f3Smrg    if test $# -ne 1; then
259010cdda0Smrg        eval LASTARG="\${$#}"
260b3eb03f3Smrg	case $LASTARG in
261010cdda0Smrg	*.l)
262010cdda0Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
263b3eb03f3Smrg	    if test -f "$SRCFILE"; then
264010cdda0Smrg	         cp "$SRCFILE" lex.yy.c
265010cdda0Smrg	    fi
266010cdda0Smrg	  ;;
267010cdda0Smrg	esac
268010cdda0Smrg    fi
269b3eb03f3Smrg    if test ! -f lex.yy.c; then
270010cdda0Smrg	echo 'main() { return 0; }' >lex.yy.c
271010cdda0Smrg    fi
272010cdda0Smrg    ;;
273010cdda0Smrg
274b3eb03f3Smrg  help2man*)
275010cdda0Smrg    echo 1>&2 "\
276b3eb03f3SmrgWARNING: \`$1' is $msg.  You should only need it if
277010cdda0Smrg	 you modified a dependency of a manual page.  You may need the
278010cdda0Smrg	 \`Help2man' package in order for those modifications to take
279010cdda0Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
280010cdda0Smrg
281b3eb03f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
282b3eb03f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
283b3eb03f3Smrg    if test -f "$file"; then
284010cdda0Smrg	touch $file
285010cdda0Smrg    else
286010cdda0Smrg	test -z "$file" || exec >$file
287010cdda0Smrg	echo ".ab help2man is required to generate this page"
288b3eb03f3Smrg	exit $?
289010cdda0Smrg    fi
290010cdda0Smrg    ;;
291010cdda0Smrg
292b3eb03f3Smrg  makeinfo*)
293010cdda0Smrg    echo 1>&2 "\
294b3eb03f3SmrgWARNING: \`$1' is $msg.  You should only need it if
295010cdda0Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296010cdda0Smrg         indirectly affecting the aspect of the manual.  The spurious
297010cdda0Smrg         call might also be the consequence of using a buggy \`make' (AIX,
298010cdda0Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299010cdda0Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
300b3eb03f3Smrg    # The file to touch is that specified with -o ...
301b3eb03f3Smrg    file=`echo "$*" | sed -n "$sed_output"`
302b3eb03f3Smrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303010cdda0Smrg    if test -z "$file"; then
304b3eb03f3Smrg      # ... or it is the one specified with @setfilename ...
305b3eb03f3Smrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
306b3eb03f3Smrg      file=`sed -n '
307b3eb03f3Smrg	/^@setfilename/{
308b3eb03f3Smrg	  s/.* \([^ ]*\) *$/\1/
309b3eb03f3Smrg	  p
310b3eb03f3Smrg	  q
311b3eb03f3Smrg	}' $infile`
312b3eb03f3Smrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
313b3eb03f3Smrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314010cdda0Smrg    fi
315b3eb03f3Smrg    # If the file does not exist, the user really needs makeinfo;
316b3eb03f3Smrg    # let's fail without touching anything.
317b3eb03f3Smrg    test -f $file || exit 1
318010cdda0Smrg    touch $file
319010cdda0Smrg    ;;
320010cdda0Smrg
321b3eb03f3Smrg  tar*)
322010cdda0Smrg    shift
323010cdda0Smrg
324010cdda0Smrg    # We have already tried tar in the generic part.
325010cdda0Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
326010cdda0Smrg    # messages.
327010cdda0Smrg    if (gnutar --version > /dev/null 2>&1); then
328010cdda0Smrg       gnutar "$@" && exit 0
329010cdda0Smrg    fi
330010cdda0Smrg    if (gtar --version > /dev/null 2>&1); then
331010cdda0Smrg       gtar "$@" && exit 0
332010cdda0Smrg    fi
333010cdda0Smrg    firstarg="$1"
334010cdda0Smrg    if shift; then
335b3eb03f3Smrg	case $firstarg in
336010cdda0Smrg	*o*)
337010cdda0Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
338010cdda0Smrg	    tar "$firstarg" "$@" && exit 0
339010cdda0Smrg	    ;;
340010cdda0Smrg	esac
341b3eb03f3Smrg	case $firstarg in
342010cdda0Smrg	*h*)
343010cdda0Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
344010cdda0Smrg	    tar "$firstarg" "$@" && exit 0
345010cdda0Smrg	    ;;
346010cdda0Smrg	esac
347010cdda0Smrg    fi
348010cdda0Smrg
349010cdda0Smrg    echo 1>&2 "\
350010cdda0SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351010cdda0Smrg         You may want to install GNU tar or Free paxutils, or check the
352010cdda0Smrg         command line arguments."
353010cdda0Smrg    exit 1
354010cdda0Smrg    ;;
355010cdda0Smrg
356010cdda0Smrg  *)
357010cdda0Smrg    echo 1>&2 "\
358b3eb03f3SmrgWARNING: \`$1' is needed, and is $msg.
359b3eb03f3Smrg         You might have modified some files without having the
360010cdda0Smrg         proper tools for further handling them.  Check the \`README' file,
361010cdda0Smrg         it often tells you about the needed prerequisites for installing
362010cdda0Smrg         this package.  You may also peek at any GNU archive site, in case
363010cdda0Smrg         some other package would contain this missing \`$1' program."
364010cdda0Smrg    exit 1
365010cdda0Smrg    ;;
366010cdda0Smrgesac
367010cdda0Smrg
368010cdda0Smrgexit 0
369b3eb03f3Smrg
370b3eb03f3Smrg# Local variables:
371b3eb03f3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
372b3eb03f3Smrg# time-stamp-start: "scriptversion="
373b3eb03f3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
374b3eb03f3Smrg# time-stamp-time-zone: "UTC"
375b3eb03f3Smrg# time-stamp-end: "; # UTC"
376b3eb03f3Smrg# End:
377