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