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