missing revision 7e4fd55a
1b8f75c19Smrg#! /bin/sh
2b8f75c19Smrg# Common stub for a few missing GNU programs while installing.
37e4fd55aSmrg
47e4fd55aSmrgscriptversion=2009-04-28.21; # UTC
57e4fd55aSmrg
67e4fd55aSmrg# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
77e4fd55aSmrg# 2008, 2009 Free Software Foundation, Inc.
8b8f75c19Smrg# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
9b8f75c19Smrg
10b8f75c19Smrg# This program is free software; you can redistribute it and/or modify
11b8f75c19Smrg# it under the terms of the GNU General Public License as published by
12b8f75c19Smrg# the Free Software Foundation; either version 2, or (at your option)
13b8f75c19Smrg# any later version.
14b8f75c19Smrg
15b8f75c19Smrg# This program is distributed in the hope that it will be useful,
16b8f75c19Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
17b8f75c19Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18b8f75c19Smrg# GNU General Public License for more details.
19b8f75c19Smrg
20b8f75c19Smrg# You should have received a copy of the GNU General Public License
217e4fd55aSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22b8f75c19Smrg
23b8f75c19Smrg# As a special exception to the GNU General Public License, if you
24b8f75c19Smrg# distribute this file as part of a program that contains a
25b8f75c19Smrg# configuration script generated by Autoconf, you may include it under
26b8f75c19Smrg# the same distribution terms that you use for the rest of that program.
27b8f75c19Smrg
28b8f75c19Smrgif test $# -eq 0; then
29b8f75c19Smrg  echo 1>&2 "Try \`$0 --help' for more information"
30b8f75c19Smrg  exit 1
31b8f75c19Smrgfi
32b8f75c19Smrg
33b8f75c19Smrgrun=:
347e4fd55aSmrgsed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
357e4fd55aSmrgsed_minuso='s/.* -o \([^ ]*\).*/\1/p'
36b8f75c19Smrg
37b8f75c19Smrg# In the cases where this matters, `missing' is being run in the
38b8f75c19Smrg# srcdir already.
39b8f75c19Smrgif test -f configure.ac; then
40b8f75c19Smrg  configure_ac=configure.ac
41b8f75c19Smrgelse
42b8f75c19Smrg  configure_ac=configure.in
43b8f75c19Smrgfi
44b8f75c19Smrg
457e4fd55aSmrgmsg="missing on your system"
467e4fd55aSmrg
477e4fd55aSmrgcase $1 in
48b8f75c19Smrg--run)
49b8f75c19Smrg  # Try to run requested program, and just exit if it succeeds.
50b8f75c19Smrg  run=
51b8f75c19Smrg  shift
52b8f75c19Smrg  "$@" && exit 0
537e4fd55aSmrg  # Exit code 63 means version mismatch.  This often happens
547e4fd55aSmrg  # when the user try to use an ancient version of a tool on
557e4fd55aSmrg  # a file that requires a minimum version.  In this case we
567e4fd55aSmrg  # we should proceed has if the program had been absent, or
577e4fd55aSmrg  # if --run hadn't been passed.
587e4fd55aSmrg  if test $? = 63; then
597e4fd55aSmrg    run=:
607e4fd55aSmrg    msg="probably too old"
617e4fd55aSmrg  fi
62b8f75c19Smrg  ;;
63b8f75c19Smrg
64b8f75c19Smrg  -h|--h|--he|--hel|--help)
65b8f75c19Smrg    echo "\
66b8f75c19Smrg$0 [OPTION]... PROGRAM [ARGUMENT]...
67b8f75c19Smrg
68b8f75c19SmrgHandle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
69b8f75c19Smrgerror status if there is no known handling for PROGRAM.
70b8f75c19Smrg
71b8f75c19SmrgOptions:
72b8f75c19Smrg  -h, --help      display this help and exit
73b8f75c19Smrg  -v, --version   output version information and exit
74b8f75c19Smrg  --run           try to run the given command, and emulate it if it fails
75b8f75c19Smrg
76b8f75c19SmrgSupported PROGRAM values:
77b8f75c19Smrg  aclocal      touch file \`aclocal.m4'
78b8f75c19Smrg  autoconf     touch file \`configure'
79b8f75c19Smrg  autoheader   touch file \`config.h.in'
807e4fd55aSmrg  autom4te     touch the output file, or create a stub one
81b8f75c19Smrg  automake     touch all \`Makefile.in' files
82b8f75c19Smrg  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
83b8f75c19Smrg  flex         create \`lex.yy.c', if possible, from existing .c
84b8f75c19Smrg  help2man     touch the output file
85b8f75c19Smrg  lex          create \`lex.yy.c', if possible, from existing .c
86b8f75c19Smrg  makeinfo     touch the output file
87b8f75c19Smrg  tar          try tar, gnutar, gtar, then tar without non-portable flags
887e4fd55aSmrg  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
897e4fd55aSmrg
907e4fd55aSmrgVersion suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
917e4fd55aSmrg\`g' are ignored when checking the name.
927e4fd55aSmrg
937e4fd55aSmrgSend bug reports to <bug-automake@gnu.org>."
947e4fd55aSmrg    exit $?
95b8f75c19Smrg    ;;
96b8f75c19Smrg
97b8f75c19Smrg  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
987e4fd55aSmrg    echo "missing $scriptversion (GNU Automake)"
997e4fd55aSmrg    exit $?
100b8f75c19Smrg    ;;
101b8f75c19Smrg
102b8f75c19Smrg  -*)
103b8f75c19Smrg    echo 1>&2 "$0: Unknown \`$1' option"
104b8f75c19Smrg    echo 1>&2 "Try \`$0 --help' for more information"
105b8f75c19Smrg    exit 1
106b8f75c19Smrg    ;;
107b8f75c19Smrg
1087e4fd55aSmrgesac
1097e4fd55aSmrg
1107e4fd55aSmrg# normalize program name to check for.
1117e4fd55aSmrgprogram=`echo "$1" | sed '
1127e4fd55aSmrg  s/^gnu-//; t
1137e4fd55aSmrg  s/^gnu//; t
1147e4fd55aSmrg  s/^g//; t'`
1157e4fd55aSmrg
1167e4fd55aSmrg# Now exit if we have it, but it failed.  Also exit now if we
1177e4fd55aSmrg# don't have it and --version was passed (most likely to detect
1187e4fd55aSmrg# the program).  This is about non-GNU programs, so use $1 not
1197e4fd55aSmrg# $program.
1207e4fd55aSmrgcase $1 in
1217e4fd55aSmrg  lex*|yacc*)
1227e4fd55aSmrg    # Not GNU programs, they don't have --version.
1237e4fd55aSmrg    ;;
1247e4fd55aSmrg
1257e4fd55aSmrg  tar*)
1267e4fd55aSmrg    if test -n "$run"; then
1277e4fd55aSmrg       echo 1>&2 "ERROR: \`tar' requires --run"
1287e4fd55aSmrg       exit 1
1297e4fd55aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1307e4fd55aSmrg       exit 1
1317e4fd55aSmrg    fi
1327e4fd55aSmrg    ;;
1337e4fd55aSmrg
1347e4fd55aSmrg  *)
135b8f75c19Smrg    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
136b8f75c19Smrg       # We have it, but it failed.
137b8f75c19Smrg       exit 1
1387e4fd55aSmrg    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
1397e4fd55aSmrg       # Could not run --version or --help.  This is probably someone
1407e4fd55aSmrg       # running `$TOOL --version' or `$TOOL --help' to check whether
1417e4fd55aSmrg       # $TOOL exists and not knowing $TOOL uses missing.
1427e4fd55aSmrg       exit 1
143b8f75c19Smrg    fi
1447e4fd55aSmrg    ;;
1457e4fd55aSmrgesac
146b8f75c19Smrg
1477e4fd55aSmrg# If it does not exist, or fails to run (possibly an outdated version),
1487e4fd55aSmrg# try to emulate it.
1497e4fd55aSmrgcase $program in
1507e4fd55aSmrg  aclocal*)
151b8f75c19Smrg    echo 1>&2 "\
1527e4fd55aSmrgWARNING: \`$1' is $msg.  You should only need it if
153b8f75c19Smrg         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
154b8f75c19Smrg         to install the \`Automake' and \`Perl' packages.  Grab them from
155b8f75c19Smrg         any GNU archive site."
156b8f75c19Smrg    touch aclocal.m4
157b8f75c19Smrg    ;;
158b8f75c19Smrg
1597e4fd55aSmrg  autoconf*)
160b8f75c19Smrg    echo 1>&2 "\
1617e4fd55aSmrgWARNING: \`$1' is $msg.  You should only need it if
162b8f75c19Smrg         you modified \`${configure_ac}'.  You might want to install the
163b8f75c19Smrg         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
164b8f75c19Smrg         archive site."
165b8f75c19Smrg    touch configure
166b8f75c19Smrg    ;;
167b8f75c19Smrg
1687e4fd55aSmrg  autoheader*)
169b8f75c19Smrg    echo 1>&2 "\
1707e4fd55aSmrgWARNING: \`$1' is $msg.  You should only need it if
171b8f75c19Smrg         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
172b8f75c19Smrg         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
173b8f75c19Smrg         from any GNU archive site."
174b8f75c19Smrg    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
175b8f75c19Smrg    test -z "$files" && files="config.h"
176b8f75c19Smrg    touch_files=
177b8f75c19Smrg    for f in $files; do
1787e4fd55aSmrg      case $f in
179b8f75c19Smrg      *:*) touch_files="$touch_files "`echo "$f" |
180b8f75c19Smrg				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
181b8f75c19Smrg      *) touch_files="$touch_files $f.in";;
182b8f75c19Smrg      esac
183b8f75c19Smrg    done
184b8f75c19Smrg    touch $touch_files
185b8f75c19Smrg    ;;
186b8f75c19Smrg
187b8f75c19Smrg  automake*)
188b8f75c19Smrg    echo 1>&2 "\
1897e4fd55aSmrgWARNING: \`$1' is $msg.  You should only need it if
190b8f75c19Smrg         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
191b8f75c19Smrg         You might want to install the \`Automake' and \`Perl' packages.
192b8f75c19Smrg         Grab them from any GNU archive site."
193b8f75c19Smrg    find . -type f -name Makefile.am -print |
194b8f75c19Smrg	   sed 's/\.am$/.in/' |
195b8f75c19Smrg	   while read f; do touch "$f"; done
196b8f75c19Smrg    ;;
197b8f75c19Smrg
1987e4fd55aSmrg  autom4te*)
199b8f75c19Smrg    echo 1>&2 "\
2007e4fd55aSmrgWARNING: \`$1' is needed, but is $msg.
2017e4fd55aSmrg         You might have modified some files without having the
202b8f75c19Smrg         proper tools for further handling them.
203b8f75c19Smrg         You can get \`$1' as part of \`Autoconf' from any GNU
204b8f75c19Smrg         archive site."
205b8f75c19Smrg
2067e4fd55aSmrg    file=`echo "$*" | sed -n "$sed_output"`
2077e4fd55aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
208b8f75c19Smrg    if test -f "$file"; then
209b8f75c19Smrg	touch $file
210b8f75c19Smrg    else
211b8f75c19Smrg	test -z "$file" || exec >$file
212b8f75c19Smrg	echo "#! /bin/sh"
213b8f75c19Smrg	echo "# Created by GNU Automake missing as a replacement of"
214b8f75c19Smrg	echo "#  $ $@"
215b8f75c19Smrg	echo "exit 0"
216b8f75c19Smrg	chmod +x $file
217b8f75c19Smrg	exit 1
218b8f75c19Smrg    fi
219b8f75c19Smrg    ;;
220b8f75c19Smrg
2217e4fd55aSmrg  bison*|yacc*)
222b8f75c19Smrg    echo 1>&2 "\
2237e4fd55aSmrgWARNING: \`$1' $msg.  You should only need it if
224b8f75c19Smrg         you modified a \`.y' file.  You may need the \`Bison' package
225b8f75c19Smrg         in order for those modifications to take effect.  You can get
226b8f75c19Smrg         \`Bison' from any GNU archive site."
227b8f75c19Smrg    rm -f y.tab.c y.tab.h
2287e4fd55aSmrg    if test $# -ne 1; then
229b8f75c19Smrg        eval LASTARG="\${$#}"
2307e4fd55aSmrg	case $LASTARG in
231b8f75c19Smrg	*.y)
232b8f75c19Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
2337e4fd55aSmrg	    if test -f "$SRCFILE"; then
234b8f75c19Smrg	         cp "$SRCFILE" y.tab.c
235b8f75c19Smrg	    fi
236b8f75c19Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
2377e4fd55aSmrg	    if test -f "$SRCFILE"; then
238b8f75c19Smrg	         cp "$SRCFILE" y.tab.h
239b8f75c19Smrg	    fi
240b8f75c19Smrg	  ;;
241b8f75c19Smrg	esac
242b8f75c19Smrg    fi
2437e4fd55aSmrg    if test ! -f y.tab.h; then
244b8f75c19Smrg	echo >y.tab.h
245b8f75c19Smrg    fi
2467e4fd55aSmrg    if test ! -f y.tab.c; then
247b8f75c19Smrg	echo 'main() { return 0; }' >y.tab.c
248b8f75c19Smrg    fi
249b8f75c19Smrg    ;;
250b8f75c19Smrg
2517e4fd55aSmrg  lex*|flex*)
252b8f75c19Smrg    echo 1>&2 "\
2537e4fd55aSmrgWARNING: \`$1' is $msg.  You should only need it if
254b8f75c19Smrg         you modified a \`.l' file.  You may need the \`Flex' package
255b8f75c19Smrg         in order for those modifications to take effect.  You can get
256b8f75c19Smrg         \`Flex' from any GNU archive site."
257b8f75c19Smrg    rm -f lex.yy.c
2587e4fd55aSmrg    if test $# -ne 1; then
259b8f75c19Smrg        eval LASTARG="\${$#}"
2607e4fd55aSmrg	case $LASTARG in
261b8f75c19Smrg	*.l)
262b8f75c19Smrg	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
2637e4fd55aSmrg	    if test -f "$SRCFILE"; then
264b8f75c19Smrg	         cp "$SRCFILE" lex.yy.c
265b8f75c19Smrg	    fi
266b8f75c19Smrg	  ;;
267b8f75c19Smrg	esac
268b8f75c19Smrg    fi
2697e4fd55aSmrg    if test ! -f lex.yy.c; then
270b8f75c19Smrg	echo 'main() { return 0; }' >lex.yy.c
271b8f75c19Smrg    fi
272b8f75c19Smrg    ;;
273b8f75c19Smrg
2747e4fd55aSmrg  help2man*)
275b8f75c19Smrg    echo 1>&2 "\
2767e4fd55aSmrgWARNING: \`$1' is $msg.  You should only need it if
277b8f75c19Smrg	 you modified a dependency of a manual page.  You may need the
278b8f75c19Smrg	 \`Help2man' package in order for those modifications to take
279b8f75c19Smrg	 effect.  You can get \`Help2man' from any GNU archive site."
280b8f75c19Smrg
2817e4fd55aSmrg    file=`echo "$*" | sed -n "$sed_output"`
2827e4fd55aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
2837e4fd55aSmrg    if test -f "$file"; then
284b8f75c19Smrg	touch $file
285b8f75c19Smrg    else
286b8f75c19Smrg	test -z "$file" || exec >$file
287b8f75c19Smrg	echo ".ab help2man is required to generate this page"
2887e4fd55aSmrg	exit $?
289b8f75c19Smrg    fi
290b8f75c19Smrg    ;;
291b8f75c19Smrg
2927e4fd55aSmrg  makeinfo*)
293b8f75c19Smrg    echo 1>&2 "\
2947e4fd55aSmrgWARNING: \`$1' is $msg.  You should only need it if
295b8f75c19Smrg         you modified a \`.texi' or \`.texinfo' file, or any other file
296b8f75c19Smrg         indirectly affecting the aspect of the manual.  The spurious
297b8f75c19Smrg         call might also be the consequence of using a buggy \`make' (AIX,
298b8f75c19Smrg         DU, IRIX).  You might want to install the \`Texinfo' package or
299b8f75c19Smrg         the \`GNU make' package.  Grab either from any GNU archive site."
3007e4fd55aSmrg    # The file to touch is that specified with -o ...
3017e4fd55aSmrg    file=`echo "$*" | sed -n "$sed_output"`
3027e4fd55aSmrg    test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
303b8f75c19Smrg    if test -z "$file"; then
3047e4fd55aSmrg      # ... or it is the one specified with @setfilename ...
3057e4fd55aSmrg      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
3067e4fd55aSmrg      file=`sed -n '
3077e4fd55aSmrg	/^@setfilename/{
3087e4fd55aSmrg	  s/.* \([^ ]*\) *$/\1/
3097e4fd55aSmrg	  p
3107e4fd55aSmrg	  q
3117e4fd55aSmrg	}' $infile`
3127e4fd55aSmrg      # ... or it is derived from the source name (dir/f.texi becomes f.info)
3137e4fd55aSmrg      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
314b8f75c19Smrg    fi
3157e4fd55aSmrg    # If the file does not exist, the user really needs makeinfo;
3167e4fd55aSmrg    # let's fail without touching anything.
3177e4fd55aSmrg    test -f $file || exit 1
318b8f75c19Smrg    touch $file
319b8f75c19Smrg    ;;
320b8f75c19Smrg
3217e4fd55aSmrg  tar*)
322b8f75c19Smrg    shift
323b8f75c19Smrg
324b8f75c19Smrg    # We have already tried tar in the generic part.
325b8f75c19Smrg    # Look for gnutar/gtar before invocation to avoid ugly error
326b8f75c19Smrg    # messages.
327b8f75c19Smrg    if (gnutar --version > /dev/null 2>&1); then
328b8f75c19Smrg       gnutar "$@" && exit 0
329b8f75c19Smrg    fi
330b8f75c19Smrg    if (gtar --version > /dev/null 2>&1); then
331b8f75c19Smrg       gtar "$@" && exit 0
332b8f75c19Smrg    fi
333b8f75c19Smrg    firstarg="$1"
334b8f75c19Smrg    if shift; then
3357e4fd55aSmrg	case $firstarg in
336b8f75c19Smrg	*o*)
337b8f75c19Smrg	    firstarg=`echo "$firstarg" | sed s/o//`
338b8f75c19Smrg	    tar "$firstarg" "$@" && exit 0
339b8f75c19Smrg	    ;;
340b8f75c19Smrg	esac
3417e4fd55aSmrg	case $firstarg in
342b8f75c19Smrg	*h*)
343b8f75c19Smrg	    firstarg=`echo "$firstarg" | sed s/h//`
344b8f75c19Smrg	    tar "$firstarg" "$@" && exit 0
345b8f75c19Smrg	    ;;
346b8f75c19Smrg	esac
347b8f75c19Smrg    fi
348b8f75c19Smrg
349b8f75c19Smrg    echo 1>&2 "\
350b8f75c19SmrgWARNING: I can't seem to be able to run \`tar' with the given arguments.
351b8f75c19Smrg         You may want to install GNU tar or Free paxutils, or check the
352b8f75c19Smrg         command line arguments."
353b8f75c19Smrg    exit 1
354b8f75c19Smrg    ;;
355b8f75c19Smrg
356b8f75c19Smrg  *)
357b8f75c19Smrg    echo 1>&2 "\
3587e4fd55aSmrgWARNING: \`$1' is needed, and is $msg.
3597e4fd55aSmrg         You might have modified some files without having the
360b8f75c19Smrg         proper tools for further handling them.  Check the \`README' file,
361b8f75c19Smrg         it often tells you about the needed prerequisites for installing
362b8f75c19Smrg         this package.  You may also peek at any GNU archive site, in case
363b8f75c19Smrg         some other package would contain this missing \`$1' program."
364b8f75c19Smrg    exit 1
365b8f75c19Smrg    ;;
366b8f75c19Smrgesac
367b8f75c19Smrg
368b8f75c19Smrgexit 0
3697e4fd55aSmrg
3707e4fd55aSmrg# Local variables:
3717e4fd55aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
3727e4fd55aSmrg# time-stamp-start: "scriptversion="
3737e4fd55aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
3747e4fd55aSmrg# time-stamp-time-zone: "UTC"
3757e4fd55aSmrg# time-stamp-end: "; # UTC"
3767e4fd55aSmrg# End:
377