missing revision 70f7c90c
1a850946eSmrg#! /bin/sh
2a850946eSmrg# Common stub for a few missing GNU programs while installing.
370f7c90cSmrg
470f7c90cSmrgscriptversion=2009-04-28.21; # UTC
570f7c90cSmrg
670f7c90cSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
770f7c90cSmrg# 2008, 2009 Free Software Foundation, Inc.
8a850946eSmrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9a850946eSmrg
10a850946eSmrg# This program is free software; you can redistribute it and/or modify
11a850946eSmrg# it under the terms of the GNU General Public License as published by
12a850946eSmrg# the Free Software Foundation; either version 2, or (at your option)
13a850946eSmrg# any later version.
14a850946eSmrg
15a850946eSmrg# This program is distributed in the hope that it will be useful,
16a850946eSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17a850946eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18a850946eSmrg# GNU General Public License for more details.
19a850946eSmrg
20a850946eSmrg# You should have received a copy of the GNU General Public License
2170f7c90cSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22a850946eSmrg
23a850946eSmrg# As a special exception to the GNU General Public License, if you
24a850946eSmrg# distribute this file as part of a program that contains a
25a850946eSmrg# configuration script generated by Autoconf, you may include it under
26a850946eSmrg# the same distribution terms that you use for the rest of that program.
27a850946eSmrg
28a850946eSmrgif test $# -eq 0; then
29a850946eSmrg  echo 1>&2 "Try \`$0 --help' for more information"
30a850946eSmrg  exit 1
31a850946eSmrgfi
32a850946eSmrg
33a850946eSmrgrun=:
3470f7c90cSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
3570f7c90cSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36a850946eSmrg
37a850946eSmrg# In the cases where this matters, `missing' is being run in the
38a850946eSmrg# srcdir already.
39a850946eSmrgif test -f configure.ac; then
40a850946eSmrg  configure_ac=configure.ac
41a850946eSmrgelse
42a850946eSmrg  configure_ac=configure.in
43a850946eSmrgfi
44a850946eSmrg
4570f7c90cSmrgmsg="missing on your system"
4670f7c90cSmrg
4770f7c90cSmrgcase $1 in
48a850946eSmrg--run)
49a850946eSmrg  # Try to run requested program, and just exit if it succeeds.
50a850946eSmrg  run=
51a850946eSmrg  shift
52a850946eSmrg  "$@" && exit 0
5370f7c90cSmrg  # Exit code 63 means version mismatch.  This often happens
5470f7c90cSmrg  # when the user try to use an ancient version of a tool on
5570f7c90cSmrg  # a file that requires a minimum version.  In this case we
5670f7c90cSmrg  # we should proceed has if the program had been absent, or
5770f7c90cSmrg  # if --run hadn't been passed.
5870f7c90cSmrg  if test $? = 63; then
5970f7c90cSmrg    run=:
6070f7c90cSmrg    msg="probably too old"
6170f7c90cSmrg  fi
62a850946eSmrg  ;;
63a850946eSmrg
64a850946eSmrg  -h|--h|--he|--hel|--help)
65a850946eSmrg    echo "\
66a850946eSmrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67a850946eSmrg
68a850946eSmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69a850946eSmrgerror status if there is no known handling for PROGRAM.
70a850946eSmrg
71a850946eSmrgOptions:
72a850946eSmrg  -h, --help      display this help and exit
73a850946eSmrg  -v, --version   output version information and exit
74a850946eSmrg  --run           try to run the given command, and emulate it if it fails
75a850946eSmrg
76a850946eSmrgSupported PROGRAM values:
77a850946eSmrg  aclocal      touch file \`aclocal.m4'
78a850946eSmrg  autoconf     touch file \`configure'
79a850946eSmrg  autoheader   touch file \`config.h.in'
8070f7c90cSmrg  autom4te     touch the output file, or create a stub one
81a850946eSmrg  automake     touch all \`Makefile.in' files
82a850946eSmrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83a850946eSmrg  flex         create \`lex.yy.c', if possible, from existing .c
84a850946eSmrg  help2man     touch the output file
85a850946eSmrg  lex          create \`lex.yy.c', if possible, from existing .c
86a850946eSmrg  makeinfo     touch the output file
87a850946eSmrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
8870f7c90cSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
8970f7c90cSmrg
9070f7c90cSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
9170f7c90cSmrg\`g' are ignored when checking the name.
9270f7c90cSmrg
9370f7c90cSmrgSend bug reports to <bug-automake@gnu.org>."
9470f7c90cSmrg    exit $?
95a850946eSmrg    ;;
96a850946eSmrg
97a850946eSmrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
9870f7c90cSmrg    echo "missing $scriptversion (GNU Automake)"
9970f7c90cSmrg    exit $?
100a850946eSmrg    ;;
101a850946eSmrg
102a850946eSmrg  -*)
103a850946eSmrg    echo 1>&2 "$0: Unknown \`$1' option"
104a850946eSmrg    echo 1>&2 "Try \`$0 --help' for more information"
105a850946eSmrg    exit 1
106a850946eSmrg    ;;
107a850946eSmrg
10870f7c90cSmrgesac
10970f7c90cSmrg
11070f7c90cSmrg# normalize program name to check for.
11170f7c90cSmrgprogram=`echo "$1" | sed '
11270f7c90cSmrg  s/^gnu-//; t
11370f7c90cSmrg  s/^gnu//; t
11470f7c90cSmrg  s/^g//; t'`
11570f7c90cSmrg
11670f7c90cSmrg# Now exit if we have it, but it failed.  Also exit now if we
11770f7c90cSmrg# don't have it and --version was passed (most likely to detect
11870f7c90cSmrg# the program).  This is about non-GNU programs, so use $1 not
11970f7c90cSmrg# $program.
12070f7c90cSmrgcase $1 in
12170f7c90cSmrg  lex*|yacc*)
12270f7c90cSmrg    # Not GNU programs, they don't have --version.
12370f7c90cSmrg    ;;
12470f7c90cSmrg
12570f7c90cSmrg  tar*)
12670f7c90cSmrg    if test -n "$run"; then
12770f7c90cSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
12870f7c90cSmrg       exit 1
12970f7c90cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13070f7c90cSmrg       exit 1
13170f7c90cSmrg    fi
13270f7c90cSmrg    ;;
13370f7c90cSmrg
13470f7c90cSmrg  *)
135a850946eSmrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136a850946eSmrg       # We have it, but it failed.
137a850946eSmrg       exit 1
13870f7c90cSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
13970f7c90cSmrg       # Could not run --version or --help.  This is probably someone
14070f7c90cSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
14170f7c90cSmrg       # $TOOL exists and not knowing $TOOL uses missing.
14270f7c90cSmrg       exit 1
143a850946eSmrg    fi
14470f7c90cSmrg    ;;
14570f7c90cSmrgesac
146a850946eSmrg
14770f7c90cSmrg# If it does not exist, or fails to run (possibly an outdated version),
14870f7c90cSmrg# try to emulate it.
14970f7c90cSmrgcase $program in
15070f7c90cSmrg  aclocal*)
151a850946eSmrg    echo 1>&2 "\
15270f7c90cSmrgWARNING: \`$1' is $msg.  You should only need it if
153a850946eSmrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154a850946eSmrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155a850946eSmrg         any GNU archive site."
156a850946eSmrg    touch aclocal.m4
157a850946eSmrg    ;;
158a850946eSmrg
15970f7c90cSmrg  autoconf*)
160a850946eSmrg    echo 1>&2 "\
16170f7c90cSmrgWARNING: \`$1' is $msg.  You should only need it if
162a850946eSmrg         you modified \`${configure_ac}'.  You might want to install the
163a850946eSmrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164a850946eSmrg         archive site."
165a850946eSmrg    touch configure
166a850946eSmrg    ;;
167a850946eSmrg
16870f7c90cSmrg  autoheader*)
169a850946eSmrg    echo 1>&2 "\
17070f7c90cSmrgWARNING: \`$1' is $msg.  You should only need it if
171a850946eSmrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172a850946eSmrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173a850946eSmrg         from any GNU archive site."
174a850946eSmrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175a850946eSmrg    test -z "$files" && files="config.h"
176a850946eSmrg    touch_files=
177a850946eSmrg    for f in $files; do
17870f7c90cSmrg      case $f in
179a850946eSmrg      *:*) touch_files="$touch_files "`echo "$f" |
180a850946eSmrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181a850946eSmrg      *) touch_files="$touch_files $f.in";;
182a850946eSmrg      esac
183a850946eSmrg    done
184a850946eSmrg    touch $touch_files
185a850946eSmrg    ;;
186a850946eSmrg
187a850946eSmrg  automake*)
188a850946eSmrg    echo 1>&2 "\
18970f7c90cSmrgWARNING: \`$1' is $msg.  You should only need it if
190a850946eSmrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191a850946eSmrg         You might want to install the \`Automake' and \`Perl' packages.
192a850946eSmrg         Grab them from any GNU archive site."
193a850946eSmrg    find . -type f -name Makefile.am -print |
194a850946eSmrg	   sed 's/\.am$/.in/' |
195a850946eSmrg	   while read f; do touch "$f"; done
196a850946eSmrg    ;;
197a850946eSmrg
19870f7c90cSmrg  autom4te*)
199a850946eSmrg    echo 1>&2 "\
20070f7c90cSmrgWARNING: \`$1' is needed, but is $msg.
20170f7c90cSmrg         You might have modified some files without having the
202a850946eSmrg         proper tools for further handling them.
203a850946eSmrg         You can get \`$1' as part of \`Autoconf' from any GNU
204a850946eSmrg         archive site."
205a850946eSmrg
20670f7c90cSmrg    file=`echo "$*" | sed -n "$sed_output"`
20770f7c90cSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208a850946eSmrg    if test -f "$file"; then
209a850946eSmrg	touch $file
210a850946eSmrg    else
211a850946eSmrg	test -z "$file" || exec >$file
212a850946eSmrg	echo "#! /bin/sh"
213a850946eSmrg	echo "# Created by GNU Automake missing as a replacement of"
214a850946eSmrg	echo "#  $ $@"
215a850946eSmrg	echo "exit 0"
216a850946eSmrg	chmod +x $file
217a850946eSmrg	exit 1
218a850946eSmrg    fi
219a850946eSmrg    ;;
220a850946eSmrg
22170f7c90cSmrg  bison*|yacc*)
222a850946eSmrg    echo 1>&2 "\
22370f7c90cSmrgWARNING: \`$1' $msg.  You should only need it if
224a850946eSmrg         you modified a \`.y' file.  You may need the \`Bison' package
225a850946eSmrg         in order for those modifications to take effect.  You can get
226a850946eSmrg         \`Bison' from any GNU archive site."
227a850946eSmrg    rm -f y.tab.c y.tab.h
22870f7c90cSmrg    if test $# -ne 1; then
229a850946eSmrg        eval LASTARG="\${$#}"
23070f7c90cSmrg	case $LASTARG in
231a850946eSmrg	*.y)
232a850946eSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
23370f7c90cSmrg	    if test -f "$SRCFILE"; then
234a850946eSmrg	         cp "$SRCFILE" y.tab.c
235a850946eSmrg	    fi
236a850946eSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
23770f7c90cSmrg	    if test -f "$SRCFILE"; then
238a850946eSmrg	         cp "$SRCFILE" y.tab.h
239a850946eSmrg	    fi
240a850946eSmrg	  ;;
241a850946eSmrg	esac
242a850946eSmrg    fi
24370f7c90cSmrg    if test ! -f y.tab.h; then
244a850946eSmrg	echo >y.tab.h
245a850946eSmrg    fi
24670f7c90cSmrg    if test ! -f y.tab.c; then
247a850946eSmrg	echo 'main() { return 0; }' >y.tab.c
248a850946eSmrg    fi
249a850946eSmrg    ;;
250a850946eSmrg
25170f7c90cSmrg  lex*|flex*)
252a850946eSmrg    echo 1>&2 "\
25370f7c90cSmrgWARNING: \`$1' is $msg.  You should only need it if
254a850946eSmrg         you modified a \`.l' file.  You may need the \`Flex' package
255a850946eSmrg         in order for those modifications to take effect.  You can get
256a850946eSmrg         \`Flex' from any GNU archive site."
257a850946eSmrg    rm -f lex.yy.c
25870f7c90cSmrg    if test $# -ne 1; then
259a850946eSmrg        eval LASTARG="\${$#}"
26070f7c90cSmrg	case $LASTARG in
261a850946eSmrg	*.l)
262a850946eSmrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
26370f7c90cSmrg	    if test -f "$SRCFILE"; then
264a850946eSmrg	         cp "$SRCFILE" lex.yy.c
265a850946eSmrg	    fi
266a850946eSmrg	  ;;
267a850946eSmrg	esac
268a850946eSmrg    fi
26970f7c90cSmrg    if test ! -f lex.yy.c; then
270a850946eSmrg	echo 'main() { return 0; }' >lex.yy.c
271a850946eSmrg    fi
272a850946eSmrg    ;;
273a850946eSmrg
27470f7c90cSmrg  help2man*)
275a850946eSmrg    echo 1>&2 "\
27670f7c90cSmrgWARNING: \`$1' is $msg.  You should only need it if
277a850946eSmrg	 you modified a dependency of a manual page.  You may need the
278a850946eSmrg	 \`Help2man' package in order for those modifications to take
279a850946eSmrg	 effect.  You can get \`Help2man' from any GNU archive site."
280a850946eSmrg
28170f7c90cSmrg    file=`echo "$*" | sed -n "$sed_output"`
28270f7c90cSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
28370f7c90cSmrg    if test -f "$file"; then
284a850946eSmrg	touch $file
285a850946eSmrg    else
286a850946eSmrg	test -z "$file" || exec >$file
287a850946eSmrg	echo ".ab help2man is required to generate this page"
28870f7c90cSmrg	exit $?
289a850946eSmrg    fi
290a850946eSmrg    ;;
291a850946eSmrg
29270f7c90cSmrg  makeinfo*)
293a850946eSmrg    echo 1>&2 "\
29470f7c90cSmrgWARNING: \`$1' is $msg.  You should only need it if
295a850946eSmrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296a850946eSmrg         indirectly affecting the aspect of the manual.  The spurious
297a850946eSmrg         call might also be the consequence of using a buggy \`make' (AIX,
298a850946eSmrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299a850946eSmrg         the \`GNU make' package.  Grab either from any GNU archive site."
30070f7c90cSmrg    # The file to touch is that specified with -o ...
30170f7c90cSmrg    file=`echo "$*" | sed -n "$sed_output"`
30270f7c90cSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303a850946eSmrg    if test -z "$file"; then
30470f7c90cSmrg      # ... or it is the one specified with @setfilename ...
30570f7c90cSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
30670f7c90cSmrg      file=`sed -n '
30770f7c90cSmrg	/^@setfilename/{
30870f7c90cSmrg	  s/.* \([^ ]*\) *$/\1/
30970f7c90cSmrg	  p
31070f7c90cSmrg	  q
31170f7c90cSmrg	}' $infile`
31270f7c90cSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
31370f7c90cSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314a850946eSmrg    fi
31570f7c90cSmrg    # If the file does not exist, the user really needs makeinfo;
31670f7c90cSmrg    # let's fail without touching anything.
31770f7c90cSmrg    test -f $file || exit 1
318a850946eSmrg    touch $file
319a850946eSmrg    ;;
320a850946eSmrg
32170f7c90cSmrg  tar*)
322a850946eSmrg    shift
323a850946eSmrg
324a850946eSmrg    # We have already tried tar in the generic part.
325a850946eSmrg    # Look for gnutar/gtar before invocation to avoid ugly error
326a850946eSmrg    # messages.
327a850946eSmrg    if (gnutar --version > /dev/null 2>&1); then
328a850946eSmrg       gnutar "$@" && exit 0
329a850946eSmrg    fi
330a850946eSmrg    if (gtar --version > /dev/null 2>&1); then
331a850946eSmrg       gtar "$@" && exit 0
332a850946eSmrg    fi
333a850946eSmrg    firstarg="$1"
334a850946eSmrg    if shift; then
33570f7c90cSmrg	case $firstarg in
336a850946eSmrg	*o*)
337a850946eSmrg	    firstarg=`echo "$firstarg" | sed s/o//`
338a850946eSmrg	    tar "$firstarg" "$@" && exit 0
339a850946eSmrg	    ;;
340a850946eSmrg	esac
34170f7c90cSmrg	case $firstarg in
342a850946eSmrg	*h*)
343a850946eSmrg	    firstarg=`echo "$firstarg" | sed s/h//`
344a850946eSmrg	    tar "$firstarg" "$@" && exit 0
345a850946eSmrg	    ;;
346a850946eSmrg	esac
347a850946eSmrg    fi
348a850946eSmrg
349a850946eSmrg    echo 1>&2 "\
350a850946eSmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351a850946eSmrg         You may want to install GNU tar or Free paxutils, or check the
352a850946eSmrg         command line arguments."
353a850946eSmrg    exit 1
354a850946eSmrg    ;;
355a850946eSmrg
356a850946eSmrg  *)
357a850946eSmrg    echo 1>&2 "\
35870f7c90cSmrgWARNING: \`$1' is needed, and is $msg.
35970f7c90cSmrg         You might have modified some files without having the
360a850946eSmrg         proper tools for further handling them.  Check the \`README' file,
361a850946eSmrg         it often tells you about the needed prerequisites for installing
362a850946eSmrg         this package.  You may also peek at any GNU archive site, in case
363a850946eSmrg         some other package would contain this missing \`$1' program."
364a850946eSmrg    exit 1
365a850946eSmrg    ;;
366a850946eSmrgesac
367a850946eSmrg
368a850946eSmrgexit 0
36970f7c90cSmrg
37070f7c90cSmrg# Local variables:
37170f7c90cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
37270f7c90cSmrg# time-stamp-start: "scriptversion="
37370f7c90cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
37470f7c90cSmrg# time-stamp-time-zone: "UTC"
37570f7c90cSmrg# time-stamp-end: "; # UTC"
37670f7c90cSmrg# End:
377