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