OSDN Git Service

* acinclude.m4 (CXX): AC_SUBST it, instead of glibcpp_CXX.
[pf3gnuchains/gcc-fork.git] / libjava / acinclude.m4
1 AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
2 [changequote(<<, >>)dnl
3 dnl The name to #define.
4 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
5 dnl The cache variable name.
6 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
7 changequote([, ])dnl
8 AC_MSG_CHECKING(size of $1)
9 AC_CACHE_VAL(AC_CV_NAME,
10 [for ac_size in 4 8 1 2 16 12 $2 ; do # List sizes in rough order of prevalence.
11   AC_TRY_COMPILE([#include "confdefs.h"
12 #include <sys/types.h>
13 $2
14 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
15   if test x$AC_CV_NAME != x ; then break; fi
16 done
17 ])
18 if test x$AC_CV_NAME = x ; then
19   AC_MSG_ERROR([cannot determine a size for $1])
20 fi
21 AC_MSG_RESULT($AC_CV_NAME)
22 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
23 undefine([AC_TYPE_NAME])dnl
24 undefine([AC_CV_NAME])dnl
25 ])
26
27 AC_DEFUN(LIBGCJ_CONFIGURE,
28 [
29 dnl Default to --enable-multilib
30 AC_ARG_ENABLE(multilib,
31 [  --enable-multilib       build many library versions (default)],
32 [case "${enableval}" in
33   yes) multilib=yes ;;
34   no)  multilib=no ;;
35   *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
36  esac], [multilib=yes])dnl
37
38 dnl We may get other options which we don't document:
39 dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
40
41 # When building with srcdir == objdir, links to the source files will
42 # be created in directories within the target_subdir.  We have to
43 # adjust toplevel_srcdir accordingly, so that configure finds
44 # install-sh and other auxiliary files that live in the top-level
45 # source directory.
46 if test "${srcdir}" = "."; then
47   if test -z "${with_target_subdir}"; then
48     toprel=".."
49   else
50     if test "${with_target_subdir}" != "."; then
51       toprel="${with_multisrctop}../.."
52     else
53       toprel="${with_multisrctop}.."
54     fi
55   fi
56 else
57   toprel=".."
58 fi
59
60 libgcj_basedir=$srcdir/$toprel/$1/libjava
61 AC_SUBST(libgcj_basedir)
62
63 AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
64 if :; then :; else
65   # This overrides the previous occurrence for automake, but not for
66   # autoconf, which is exactly what we want.
67   AC_CONFIG_AUX_DIR(..)
68 fi
69
70 # This works around an automake problem.
71 mkinstalldirs="`cd $ac_aux_dir && pwd`/mkinstalldirs"
72 AC_SUBST(mkinstalldirs)
73
74 AC_CANONICAL_SYSTEM
75
76 dnl This shouldn't be needed, as long as top-level dependencies are
77 dnl defined correctly and shared-library paths are set up so that
78 dnl execution tests succeed.  FIXME.
79 define([AC_PROG_CC_WORKS],[])
80 define([AC_PROG_CXX_WORKS],[])
81
82 AC_PROG_CC
83
84 # We use the libstdc++-v3 version of LIB_AC_PROG_CXX, that gets
85 # glibcpp_CXX cached instead of CXX.  That's because we're passed a
86 # different definition of CXX than other directories, since we don't
87 # depend on libstdc++-v3 having already been built.
88 AC_DEFUN(LIB_AC_PROG_CXX,
89 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
90 dnl Fool anybody using AC_PROG_CXX.
91 AC_PROVIDE([AC_PROG_CXX])
92 # Use glibcpp_CXX so that we do not cause CXX to be cached with the
93 # flags that come in CXX while configuring libstdc++.  They're different
94 # from those used for all other target libraries.  If CXX is set in
95 # the environment, respect that here.
96 glibcpp_CXX=$CXX
97 AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
98 AC_SUBST(CXX)
99 CXX=$glibcpp_CXX
100 test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
101
102 AC_PROG_CXX_GNU
103
104 if test $ac_cv_prog_gxx = yes; then
105   GXX=yes
106 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
107 dnl plays around with CXXFLAGS (such as to build both debugging and
108 dnl normal versions of a library), tasteless as that idea is.
109   ac_test_CXXFLAGS="${CXXFLAGS+set}"
110   ac_save_CXXFLAGS="$CXXFLAGS"
111   CXXFLAGS=
112   AC_PROG_CXX_G
113   if test "$ac_test_CXXFLAGS" = set; then
114     CXXFLAGS="$ac_save_CXXFLAGS"
115   elif test $ac_cv_prog_cxx_g = yes; then
116     CXXFLAGS="-g -O2"
117   else
118     CXXFLAGS="-O2"
119   fi
120 else
121   GXX=
122   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
123 fi
124 ])
125
126 LIB_AC_PROG_CXX
127
128 dnl version is pulled out to make it a bit easier to change using sed.
129 version=0.0.7
130 dnl Still use "libjava" here to placate dejagnu.
131 AM_INIT_AUTOMAKE(libjava, $version)
132
133 # AC_CHECK_TOOL does AC_REQUIRE (AC_CANONICAL_BUILD).  If we don't
134 # run it explicitly here, it will be run implicitly before
135 # LIBGCJ_CONFIGURE, which doesn't work because that means that it will
136 # be run before AC_CANONICAL_HOST.
137 AC_CANONICAL_BUILD
138
139 AC_CHECK_TOOL(AS, as)
140 AC_CHECK_TOOL(AR, ar)
141 AC_CHECK_TOOL(RANLIB, ranlib, :)
142
143 AC_PROG_INSTALL
144
145 AM_MAINTAINER_MODE
146
147 # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
148 # at least currently, we never actually build a program, so we never
149 # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
150 # fails, because we are probably configuring with a cross compiler
151 # which cant create executables.  So we include AC_EXEEXT to keep
152 # automake happy, but we don't execute it, since we don't care about
153 # the result.
154 if false; then
155   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
156   # to nothing, so nothing would remain between `then' and `fi' if it
157   # were not for the `:' below.
158   :
159   AC_EXEEXT
160 fi
161
162 # configure.host sets the following important variables
163 #       libgcj_cflags    - host specific C compiler flags
164 #       libgcj_cxxflags  - host specific C++ compiler flags
165 #       libgcj_javaflags - host specific Java compiler flags
166
167 libgcj_cflags=
168 libgcj_cxxflags=
169 libgcj_javaflags=
170
171 . [$]{srcdir}/configure.host
172
173 LIBGCJ_CFLAGS="[$]{libgcj_cflags}"
174 LIBGCJ_CXXFLAGS="[$]{libgcj_cxxflags}"
175 LIBGCJ_JAVAFLAGS="[$]{libgcj_javaflags}"
176 AC_SUBST(LIBGCJ_CFLAGS)
177 AC_SUBST(LIBGCJ_CXXFLAGS)
178 AC_SUBST(LIBGCJ_JAVAFLAGS)
179 ])dnl
180
181 sinclude(../libtool.m4)
182 dnl The lines below arrange for aclocal not to bring libtool.m4
183 dnl AM_PROG_LIBTOOL into aclocal.m4, while still arranging for automake
184 dnl to add a definition of LIBTOOL to Makefile.in.
185 ifelse(yes,no,[
186 AC_DEFUN([AM_PROG_LIBTOOL],)
187 AC_DEFUN([AC_LIBTOOL_DLOPEN],)
188 AC_DEFUN([AC_LIBLTDL_CONVENIENCE],)
189 AC_DEFUN([LT_AC_PROG_GCJ],)
190 AC_SUBST(GCJ)
191 AC_SUBST(LIBTOOL)
192 ])
193
194 #serial AM2
195
196 dnl From Bruno Haible.
197
198 AC_DEFUN([AM_ICONV],
199 [
200   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
201   dnl those with the standalone portable GNU libiconv installed).
202
203   am_cv_lib_iconv_ldpath=
204   AC_ARG_WITH([libiconv-prefix],
205 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
206     for dir in `echo "$withval" | tr : ' '`; do
207       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
208       if test -d $dir/lib; then am_cv_lib_iconv_ldpath="-L$dir/lib"; fi
209     done
210    ])
211
212   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
213     am_cv_func_iconv="no, consider installing GNU libiconv"
214     am_cv_lib_iconv=no
215     AC_TRY_LINK([#include <stdlib.h>
216 #include <iconv.h>],
217       [iconv_t cd = iconv_open("","");
218        iconv(cd,NULL,NULL,NULL,NULL);
219        iconv_close(cd);],
220       am_cv_func_iconv=yes)
221     if test "$am_cv_func_iconv" != yes; then
222       am_save_LIBS="$LIBS"
223       LIBS="$LIBS $am_cv_libiconv_ldpath -liconv"
224       AC_TRY_LINK([#include <stdlib.h>
225 #include <iconv.h>],
226         [iconv_t cd = iconv_open("","");
227          iconv(cd,NULL,NULL,NULL,NULL);
228          iconv_close(cd);],
229         am_cv_lib_iconv=yes
230         am_cv_func_iconv=yes)
231       LIBS="$am_save_LIBS"
232     fi
233   ])
234   if test "$am_cv_func_iconv" = yes; then
235     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
236     AC_MSG_CHECKING([for iconv declaration])
237     AC_CACHE_VAL(am_cv_proto_iconv, [
238       AC_TRY_COMPILE([
239 #include <stdlib.h>
240 #include <iconv.h>
241 extern
242 #ifdef __cplusplus
243 "C"
244 #endif
245 #if defined(__STDC__) || defined(__cplusplus)
246 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
247 #else
248 size_t iconv();
249 #endif
250 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
251       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
252     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
253     AC_MSG_RESULT([$]{ac_t:-
254          }[$]am_cv_proto_iconv)
255     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
256       [Define as const if the declaration of iconv() needs const.])
257   fi
258   LIBICONV=
259   if test "$am_cv_lib_iconv" = yes; then
260     LIBICONV="$am_cv_lib_iconv_ldpath -liconv"
261   fi
262   AC_SUBST(LIBICONV)
263 ])
264
265 # Check whether LC_MESSAGES is available in <locale.h>.
266 # Ulrich Drepper <drepper@cygnus.com>, 1995.
267 #
268 # This file can be copied and used freely without restrictions.  It can
269 # be used in projects which are not available under the GNU General Public
270 # License or the GNU Library General Public License but which still want
271 # to provide support for the GNU gettext functionality.
272 # Please note that the actual code of the GNU gettext library is covered
273 # by the GNU Library General Public License, and the rest of the GNU
274 # gettext package package is covered by the GNU General Public License.
275 # They are *not* in the public domain.
276
277 # serial 2
278
279 AC_DEFUN([AM_LC_MESSAGES],
280   [if test $ac_cv_header_locale_h = yes; then
281     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
282       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
283        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
284     if test $am_cv_val_LC_MESSAGES = yes; then
285       AC_DEFINE(HAVE_LC_MESSAGES, 1,
286         [Define if your <locale.h> file defines LC_MESSAGES.])
287     fi
288   fi])