]> git.ipfire.org Git - thirdparty/gcc.git/blob - libjava/configure.ac
re PR target/26792 (need to use autoconf when using newly-added libgcc functions)
[thirdparty/gcc.git] / libjava / configure.ac
1 dnl # Process this with autoconf to create configure
2 AC_PREREQ(2.59)
3 # Still use "libjava" here to placate dejagnu.
4 AC_INIT([libjava], [version-unused],, [libjava])
5
6 AC_CONFIG_SRCDIR(java/lang/System.java)
7
8 GCC_TOPLEV_SUBDIRS
9
10 # We use these options to decide which functions to include.
11 AC_ARG_WITH(target-subdir,
12 AS_HELP_STRING([--with-target-subdir=SUBDIR],
13 [configure in a subdirectory]))
14
15 # We may get other options which we don't document:
16 # --with-target-subdir, --with-multisrctop, --with-multisubdir
17
18 # When building with srcdir == objdir, links to the source files will
19 # be created in directories within the target_subdir. We have to
20 # adjust toplevel_srcdir accordingly, so that configure finds
21 # install-sh and other auxiliary files that live in the top-level
22 # source directory.
23 if test "${srcdir}" = "."; then
24 if test -z "${with_target_subdir}"; then
25 toprel=".."
26 else
27 if test "${with_target_subdir}" != "."; then
28 toprel="${with_multisrctop}../.."
29 else
30 toprel="${with_multisrctop}.."
31 fi
32 fi
33 else
34 toprel=".."
35 fi
36
37 libgcj_basedir=$srcdir/$toprel/./libjava
38 AC_SUBST(libgcj_basedir)
39
40 AC_CANONICAL_SYSTEM
41 _GCC_TOPLEV_NONCANONICAL_BUILD
42 _GCC_TOPLEV_NONCANONICAL_TARGET
43
44 AC_SUBST(target_noncanonical)
45
46 # This works around the fact that libtool configuration may change LD
47 # for this particular configuration, but some shells, instead of
48 # keeping the changes in LD private, export them just because LD is
49 # exported.
50 ORIGINAL_LD_FOR_MULTILIBS=$LD
51
52 AC_PROG_LN_S
53
54 # This works around an automake problem.
55 mkinstalldirs="`cd $ac_aux_dir && ${PWDCMD-pwd}`/mkinstalldirs"
56 AC_SUBST(mkinstalldirs)
57
58 AC_ARG_WITH(cross-host,
59 AS_HELP_STRING([--with-cross-host=HOST],
60 [configure with a cross compiler from HOST]))
61
62 AC_ARG_WITH(newlib,
63 AS_HELP_STRING([--with-newlib],
64 [configure with newlib]))
65
66 AC_ARG_ENABLE(version-specific-runtime-libs,
67 AS_HELP_STRING([--enable-version-specific-runtime-libs],
68 [specify that runtime libraries should be installed in a compiler-specific directory]),
69 [case "$enableval" in
70 yes) version_specific_libs=yes ;;
71 no) version_specific_libs=no ;;
72 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
73 esac],
74 [version_specific_libs=no]
75 )
76
77 # Default to --enable-multilib
78 AC_ARG_ENABLE(multilib,
79 AS_HELP_STRING([--enable-multilib],
80 [build many library versions (default)]),
81 [case "${enableval}" in
82 yes) multilib=yes ;;
83 no) multilib=no ;;
84 *) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
85 esac], [multilib=yes])dnl
86
87 AC_ARG_ENABLE(plugin,
88 AS_HELP_STRING([--enable-plugin],
89 [build gcjwebplugin web browser plugin]),
90 [case "$enableval" in
91 yes) plugin_enabled=yes ;;
92 no) plugin_enabled=no ;;
93 *) AC_MSG_ERROR([Unknown argument to enable/disable plugin]);;
94 esac],
95 [plugin_enabled=no]
96 )
97
98 AC_ARG_ENABLE(gconf-peer,
99 AS_HELP_STRING([--enable-gconf-peer],
100 [compile GConf native peers for util.preferences]),
101 [case "$enableval" in
102 yes) gconf_enabled=yes ;;
103 no) gconf_enabled=no ;;
104 *) AC_MSG_ERROR([Unknown argument to enable/disable gconf-peer]);;
105 esac],
106 [gconf_enabled=no]
107 )
108
109 # It may not be safe to run linking tests in AC_PROG_CC/AC_PROG_CXX.
110 GCC_NO_EXECUTABLES
111
112 # (1) We use an abnormal CXX (without library references), so we
113 # must cache it under a different name.
114 # (2) CC, CFLAGS, CXX, CXXFLAGS, LDFLAGS must not be 'precious', or
115 # the non-multilib-adjusted value will be used in multilibs.
116 # (3) As a side effect, we must SUBST CXXFLAGS, CFLAGS, and LDFLAGS ourselves.
117 # (4) As another side effect, automake doesn't automatically include them
118 # in Makefile.in.
119 # (5) For libstdc++-v3, -fno-builtin must be present here so that a
120 # non-conflicting form of std::exit can be guessed by AC_PROG_CXX, and
121 # used in later tests. This may not be necessary in libjava; I don't know.
122 m4_define([ac_cv_prog_CXX],[glibcxx_cv_prog_CXX])
123 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibcxx_PRECIOUS])
124 m4_define([_AC_ARG_VAR_PRECIOUS],[])
125 save_CXXFLAGS="$CXXFLAGS"
126 CXXFLAGS="$CXXFLAGS -fno-builtin"
127 AC_PROG_CC
128 AC_PROG_CXX
129 CXXFLAGS="$save_CXXFLAGS"
130 m4_rename([glibcxx_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
131 AC_SUBST(CFLAGS)
132 AC_SUBST(CXXFLAGS)
133 AC_SUBST(LDFLAGS)
134
135 AM_INIT_AUTOMAKE([1.9.0])
136
137 AC_CHECK_TOOL(AS, as)
138 AC_CHECK_TOOL(LD, ld)
139 AC_CHECK_TOOL(AR, ar)
140 AC_CHECK_TOOL(RANLIB, ranlib, :)
141 AC_PROG_AWK
142 AC_CHECK_PROGS([JAR], [jar fastjar], no)
143 AC_PATH_PROG([ZIP], [zip], no)
144 AC_PATH_PROG([UNZIP], [unzip], unzip)
145 AM_CONDITIONAL(BASH_JAR, test "$JAR" = no)
146 if test "$ZIP" = no; then
147 if test "$JAR" = no; then
148 AC_MSG_ERROR([cannot find neither zip nor jar, cannot continue])
149 fi
150 else
151 # InfoZIP available, use the 'guaranteed' Bourne-shell JAR to build libjava
152 JAR=`pwd`/scripts/jar
153 fi
154
155 AC_PROG_INSTALL
156
157 AM_MAINTAINER_MODE
158
159 AC_EXEEXT
160
161 # configure.host sets the following important variables
162 # libgcj_cflags - host specific C compiler flags
163 # libgcj_cxxflags - host specific C++ compiler flags
164 # libgcj_javaflags - host specific Java compiler flags
165
166 libgcj_cflags=
167 libgcj_cxxflags=
168 libgcj_javaflags=
169
170 . ${srcdir}/configure.host
171
172 LIBGCJ_CFLAGS="${libgcj_cflags}"
173 LIBGCJ_CXXFLAGS="${libgcj_cxxflags}"
174 LIBGCJ_JAVAFLAGS="${libgcj_javaflags}"
175 LIBGCJ_LD_SYMBOLIC="${libgcj_ld_symbolic}"
176 AC_SUBST(LIBGCJ_CFLAGS)
177 AC_SUBST(LIBGCJ_CXXFLAGS)
178 AC_SUBST(LIBGCJ_JAVAFLAGS)
179 AC_SUBST(LIBGCJ_LD_SYMBOLIC)
180
181 # Only use libltdl for non-newlib builds.
182 if test "x${with_newlib}" = "x" || test "x${with_newlib}" = "xno"; then
183 AC_LTDL_SHLIBPATH
184 fi
185
186 AC_CONFIG_HEADERS([include/config.h gcj/libgcj-config.h])
187
188 # See if the user has requested runtime debugging.
189 LIBGCJDEBUG="disable"
190 AC_SUBST(LIBGCJDEBUG)
191 AC_ARG_ENABLE(libgcj-debug,
192 AS_HELP_STRING([--enable-libgcj-debug],
193 [enable runtime debugging code]),
194 [if test "$enable_libgcj_debug" = yes; then
195 AC_DEFINE(DEBUG, 1, [Define this if you want runtime debugging enabled.])
196 LIBGCJDEBUG="enable"
197 fi])
198
199 # Determine which AWT peer libraries to build
200 AC_ARG_ENABLE(java-awt,
201 AS_HELP_STRING([--enable-java-awt],
202 [list of AWT peer implementations to be built]))
203
204 peerlibs="`echo ${enable_java_awt} | tr ',' ' '`"
205 use_xlib_awt=""
206 use_gtk_awt=""
207 use_qt_awt=""
208 # The default toolkit to use is the first one specified.
209 TOOLKIT=
210 AC_SUBST(TOOLKIT)
211
212 for peer in $peerlibs ; do
213 case $peer in
214 xlib)
215 if test "$no_x" = yes; then
216 echo "*** xlib peers requested but no X library available" 1>&2
217 exit 1
218 else
219 use_xlib_awt="yes"
220 if test -z "$TOOLKIT"; then
221 TOOLKIT=gnu.awt.xlib.XToolkit
222 fi
223 fi
224 ;;
225 gtk)
226 if test "$no_x" = yes; then
227 echo "*** gtk peers requested but no X library available" 1>&2
228 exit 1
229 else
230 use_gtk_awt=yes
231 if test -z "$TOOLKIT"; then
232 TOOLKIT=gnu.java.awt.peer.gtk.GtkToolkit
233 fi
234 fi
235 ;;
236 qt)
237 if test "$no_x" = yes; then
238 # Perhaps we should admit the possibility of embedded Qt.
239 echo "*** Qt peers requested but no X library available" 1>&2
240 exit 1
241 else
242 use_qt_awt=yes
243 if test -z "$TOOLKIT"; then
244 TOOLKIT=gnu.java.awt.peer.qt.QtToolkit
245 fi
246 fi
247 ;;
248 no)
249 use_xlib_awt=
250 use_gtk_awt=
251 use_qt_awt=
252 break
253 ;;
254 *)
255 echo "*** unrecognised argument \"${peer}\" for --enable-java-awt" 1>&2
256 exit 1
257 esac
258 done
259
260 AM_CONDITIONAL(XLIB_AWT, test "$use_xlib_awt" = yes)
261
262 # Create standard.omit based on decisions we just made.
263 cp $srcdir/standard.omit.in standard.omit
264 if test "$use_xlib_awt" != yes; then
265 echo gnu/awt/xlib >> standard.omit
266 echo gnu/gcj/xlib >> standard.omit
267 fi
268
269 if test -z "${with_multisubdir}"; then
270 builddotdot=.
271 else
272 builddotdot=`echo ${with_multisubdir} | sed -e 's:[[^/]][[^/]]*:..:g'`
273 fi
274
275 NATIVE=yes
276
277 # Which gcj do we use?
278 which_gcj=default
279 built_gcc_dir="`cd ${builddotdot}/../../${host_subdir}/gcc && ${PWDCMD-pwd}`"
280 if test -n "${with_cross_host}"; then
281 # We are being configured with a cross compiler. We can't
282 # use ac_exeext, because that is for the target platform.
283 NATIVE=no
284 cross_host_exeext=
285 case "${with_cross_host}" in
286 *mingw* | *cygwin*)
287 cross_host_exeext=.exe
288 ;;
289 esac
290 if test -x "${built_gcc_dir}/gcj${cross_host_exeext}"; then
291 if test x"$build_noncanonical" = x"$with_cross_host"; then
292 # Ordinary cross (host!=target and host=build)
293 which_gcj=built
294 else
295 # Canadian cross (host!=target and host!=build)
296 which_gcj=cross
297 fi
298 else
299 which_gcj=cross
300 fi
301 else
302 # We are being configured with a native or crossed-native compiler
303 if test -x "${built_gcc_dir}/gcj${ac_exeext}"; then
304 if test x"$build" = x"$host"; then
305 # True native build (host=target and host=build)
306 which_gcj=built
307 else
308 # Crossed-native build (host=target and host!=build)
309 which_gcj=cross
310 fi
311 else
312 which_gcj=path
313 fi
314 fi
315 case "${which_gcj}" in
316 built)
317 GCJ="$built_gcc_dir/gcj -B`${PWDCMD-pwd}`/ -B$built_gcc_dir/"
318 GCJH='$(top_builddir)/$(MULTIBUILDTOP)../../$(host_subdir)/gcc/gcjh'
319 ;;
320 cross)
321 if test "x${with_newlib}" = "xyes"; then
322 # FIXME (comment): Why is this needed?
323 GCC_UNWIND_INCLUDE=
324 GCJ="${target_noncanonical}-gcj"
325 else
326 GCJ="${target_noncanonical}-gcj -B`${PWDCMD-pwd}`/"
327 fi
328 GCJH='$(target_noncanonical)-gcjh'
329 ;;
330 path)
331 GCJ="gcj -B`${PWDCMD-pwd}`/"
332 GCJH=gcjh
333 ;;
334 esac
335
336 AC_SUBST(GCJH)
337
338 # Create it, so that compile/link tests don't fail
339 test -f libgcj.spec || touch libgcj.spec
340
341
342
343 # Set up to configure Classpath.
344 # FIXME: no supported way to pass args in autoconf.
345 ac_configure_args="$ac_configure_args --with-fastjar=$JAR"
346 ac_configure_args="$ac_configure_args --enable-tool-wrappers"
347 ac_configure_args="$ac_configure_args --disable-load-library"
348 ac_configure_args="$ac_configure_args --${LIBGCJDEBUG}-debug"
349 ac_configure_args="$ac_configure_args --enable-default-toolkit=$TOOLKIT"
350 dir1=`cd $srcdir && pwd`
351 dir2=`pwd`
352 ac_configure_args="$ac_configure_args --with-vm-classes=$dir1:$dir2"
353 ac_configure_args="$ac_configure_args --disable-core-jni"
354 dnl FIXME?
355 ac_configure_args="$ac_configure_args --disable-examples"
356 ac_configure_args="$ac_configure_args --with-glibj=build"
357 if test "$plugin_enabled" != yes; then
358 ac_configure_args="$ac_configure_args --disable-plugin"
359 fi
360 if test "$gconf_enabled" != yes; then
361 ac_configure_args="$ac_configure_args --disable-gconf-peer"
362 ac_configure_args="$ac_configure_args --enable-default-preferences-peer=gnu.java.util.prefs.FileBasedFactory"
363 fi
364 if test "$use_gtk_awt" != yes; then
365 ac_configure_args="$ac_configure_args --disable-gtk-peer"
366 fi
367 if test "$use_qt_awt" != yes; then
368 ac_configure_args="$ac_configure_args --disable-qt-peer"
369 else
370 # We need this as qt is disabled by default in classpath.
371 ac_configure_args="$ac_configure_args --enable-qt-peer"
372 fi
373 dnl --with-gcj=$GCJ
374 dnl --with-javah=$GCJH
375 dnl gjdoc?
376 dnl gtk-cairo -- just export here...
377 dnl --enable-regen-headers?
378
379 # Only use libltdl for non-newlib builds.
380 if test "x${with_newlib}" = "x" || test "x${with_newlib}" = "xno"; then
381 AC_LIBLTDL_CONVENIENCE
382 AC_LIBTOOL_DLOPEN
383 DIRLTDL=libltdl
384 AC_DEFINE(USE_LTDL, 1, [Define if libltdl is in use.])
385 # Sigh. Libtool's macro doesn't do the right thing.
386 INCLTDL="-I\$(top_srcdir)/libltdl $INCLTDL"
387 # FIXME: this is a hack.
388 sub_auxdir="`cd $ac_aux_dir && ${PWDCMD-pwd}`"
389 ac_configure_args="$ac_configure_args --with-auxdir=$sub_auxdir"
390 fi
391 AC_SUBST(INCLTDL)
392 AC_SUBST(LIBLTDL)
393 AC_SUBST(DIRLTDL)
394 AC_PROG_LIBTOOL
395 AM_PROG_GCJ
396 AM_PROG_CC_C_O
397
398 AC_CONFIG_SUBDIRS(classpath libltdl)
399
400 # The -no-testsuite modules omit the test subdir.
401 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
402
403 # Should the runtime set system properties by examining the
404 # environment variable GCJ_PROPERTIES?
405 AC_ARG_ENABLE(getenv-properties,
406 AS_HELP_STRING([--disable-getenv-properties],
407 [don't set system properties from GCJ_PROPERTIES]))
408
409 # Whether GCJ_PROPERTIES is used depends on the target.
410 if test -z "$enable_getenv_properties"; then
411 enable_getenv_properties=${enable_getenv_properties_default-yes}
412 fi
413 if test "$enable_getenv_properties" = no; then
414 AC_DEFINE(DISABLE_GETENV_PROPERTIES, 1,
415 [Define if system properties shouldn't be read from getenv("GCJ_PROPERTIES").])
416 fi
417
418 # Whether we should use arguments to main()
419 if test -z "$enable_main_args"; then
420 enable_main_args=${enable_main_args_default-yes}
421 fi
422 if test "$enable_main_args" = no; then
423 AC_DEFINE(DISABLE_MAIN_ARGS, 1, [Define if we should ignore arguments to main().])
424 fi
425
426
427 # Should we use hashtable-based synchronization?
428 # Currently works only for Linux X86/ia64
429 # Typically faster and more space-efficient
430 AC_ARG_ENABLE(hash-synchronization,
431 AS_HELP_STRING([--enable-hash-synchronization],
432 [use global hash table for monitor locks]))
433
434 if test -z "$enable_hash_synchronization"; then
435 enable_hash_synchronization=$enable_hash_synchronization_default
436 fi
437
438 AC_ARG_WITH(java-home,
439 AS_HELP_STRING([--with-java-home=DIRECTORY],
440 [value of java.home system property]),
441 [JAVA_HOME="${withval}"], [JAVA_HOME=""])
442 AM_CONDITIONAL(JAVA_HOME_SET, test ! -z "$JAVA_HOME")
443 AC_SUBST(JAVA_HOME)
444
445 # What is the native OS API for MinGW?
446 AC_ARG_WITH(win32-nlsapi,
447 AS_HELP_STRING([--with-win32-nlsapi=ansi or unicows or unicode],
448 [native MinGW libgcj Win32 OS API (default is ansi)]),
449 [case "${withval}" in
450 ansi) with_win32_nlsapi=ansi ;;
451 unicows) with_win32_nlsapi=unicows ;;
452 unicode) with_win32_nlsapi=unicode ;;
453 *) AC_MSG_ERROR(Bad value ${withval} for --with-win32-nlsapi.) ;;
454 esac],[with_win32_nlsapi=ansi])
455
456 case "${with_win32_nlsapi}" in
457 unicows | unicode)
458 AC_DEFINE(MINGW_LIBGCJ_UNICODE, 1,
459 [Define if MinGW libgcj uses the Windows UNICODE OS API.])
460 ;;
461 esac
462
463 # configure.host sets slow_pthread_self if the synchronization code should
464 # try to avoid pthread_self calls by caching thread IDs in a hashtable.
465 if test "${slow_pthread_self}" = "yes"; then
466 AC_DEFINE(SLOW_PTHREAD_SELF, 1,
467 [Define if if the synchronization code should try to avoid pthread_self calls by caching thread IDs in a hashtable.])
468 fi
469
470 # Check for gc debugging. This option is handled both here and in the GC.
471 AC_ARG_ENABLE(gc-debug,
472 AS_HELP_STRING([--enable-gc-debug],
473 [include full support for pointer backtracing etc.]),
474 [ if test "$enable_gc_debug" = "yes"; then
475 AC_DEFINE(LIBGCJ_GC_DEBUG, 1,
476 [Define if we want to use debug calls into the garbage collector.])
477 fi])
478
479 # See if the user has the interpreter included.
480 AC_ARG_ENABLE(interpreter,
481 AS_HELP_STRING([--enable-interpreter],
482 [enable interpreter]),
483 [if test "$enable_interpreter" = yes; then
484 # This can also be set in configure.host.
485 libgcj_interpreter=yes
486 elif test "$enable_interpreter" = no; then
487 libgcj_interpreter=no
488 fi])
489
490 if test "$libgcj_interpreter" = yes; then
491 AC_DEFINE(INTERPRETER, 1, [Define if you want a bytecode interpreter.])
492 fi
493 INTERPRETER="$libgcj_interpreter"
494 AC_SUBST(INTERPRETER)
495
496 AC_MSG_CHECKING([for exception model to use])
497 AC_LANG_PUSH(C++)
498 AC_ARG_ENABLE(sjlj-exceptions,
499 AS_HELP_STRING([--enable-sjlj-exceptions],
500 [force use of builtin_setjmp for exceptions]),
501 [:],
502 [dnl Botheration. Now we've got to detect the exception model.
503 dnl Link tests against libgcc.a are problematic since -- at least
504 dnl as of this writing -- we've not been given proper -L bits for
505 dnl single-tree newlib and libgloss.
506 dnl
507 dnl This is what AC_TRY_COMPILE would do if it didn't delete the
508 dnl conftest files before we got a change to grep them first.
509 cat > conftest.$ac_ext << EOF
510 [#]line __oline__ "configure"
511 struct S { ~S(); };
512 void bar();
513 void foo()
514 {
515 S s;
516 bar();
517 }
518 EOF
519 old_CXXFLAGS="$CXXFLAGS"
520 CXXFLAGS=-S
521 if AC_TRY_EVAL(ac_compile); then
522 if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
523 enable_sjlj_exceptions=yes
524 elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
525 enable_sjlj_exceptions=no
526 fi
527 fi
528 CXXFLAGS="$old_CXXFLAGS"
529 rm -f conftest*])
530 if test x$enable_sjlj_exceptions = xyes; then
531 AC_DEFINE(SJLJ_EXCEPTIONS, 1,
532 [Define if the compiler is configured for setjmp/longjmp exceptions.])
533 ac_exception_model_name=sjlj
534 elif test x$enable_sjlj_exceptions = xno; then
535 ac_exception_model_name="call frame"
536 else
537 AC_MSG_ERROR([unable to detect exception model])
538 fi
539 AC_LANG_POP(C++)
540 AC_MSG_RESULT($ac_exception_model_name)
541
542 # If we are non using SJLJ exceptions, and this host does not have support
543 # for unwinding from a signal handler, enable checked dereferences and divides.
544 if test $can_unwind_signal = no && test $enable_sjlj_exceptions = no; then
545 CHECKREFSPEC=-fcheck-references
546 DIVIDESPEC=-fuse-divide-subroutine
547 EXCEPTIONSPEC=
548 fi
549
550 # See if the user wants to disable java.net. This is the mildly
551 # ugly way that we admit that target-side configuration sucks.
552 AC_ARG_ENABLE(java-net,
553 AS_HELP_STRING([--disable-java-net],
554 [disable java.net]))
555
556 # Whether java.net is built by default can depend on the target.
557 if test -z "$enable_java_net"; then
558 enable_java_net=${enable_java_net_default-yes}
559 fi
560 if test "$enable_java_net" = no; then
561 AC_DEFINE(DISABLE_JAVA_NET, 1, [Define if java.net native functions should be stubbed out.])
562 fi
563
564 # See if the user wants to configure without libffi. Some
565 # architectures don't support it, and default values are set in
566 # configure.host.
567 AC_ARG_WITH(libffi,
568 AS_HELP_STRING([--without-libffi],
569 [don't use libffi]),
570 [:],
571 [with_libffi=${with_libffi_default-yes}])
572
573 LIBFFI=
574 LIBFFIINCS=
575 if test "$with_libffi" != no; then
576 AC_DEFINE(USE_LIBFFI, 1, [Define if we're to use libffi.])
577 LIBFFI=../libffi/libffi_convenience.la
578 LIBFFIINCS='-I$(top_srcdir)/../libffi/include -I../libffi/include'
579 fi
580 AC_SUBST(LIBFFI)
581 AC_SUBST(LIBFFIINCS)
582
583 # See if the user wants to disable JVMPI support.
584 AC_ARG_ENABLE(jvmpi,
585 AS_HELP_STRING([--disable-jvmpi],
586 [disable JVMPI support]))
587
588 if test "$enable_jvmpi" != no; then
589 AC_DEFINE(ENABLE_JVMPI, 1, [Define if you are using JVMPI.])
590 fi
591
592 # If the target is an eCos system, use the appropriate eCos
593 # I/O routines.
594 # FIXME: this should not be a local option but a global target
595 # system; at present there is no eCos target.
596 TARGET_ECOS=${PROCESS-"no"}
597 AC_ARG_WITH(ecos,
598 [ --with-ecos enable runtime eCos target support],
599 TARGET_ECOS="$with_ecos"
600 )
601
602 PLATFORM_INNER_NAT_HDRS=
603 case "$TARGET_ECOS" in
604 no) case "$host" in
605 *mingw*)
606 PLATFORM=Win32
607 PLATFORMNET=Win32
608 PLATFORMH=win32.h
609 CHECK_FOR_BROKEN_MINGW_LD
610 ;;
611 *)
612 PLATFORM=Posix
613 PLATFORMNET=Posix
614 PLATFORMH=posix.h
615 PLATFORM_INNER_NAT_HDRS='java/lang/ConcreteProcess$$ProcessManager.h'
616 ;;
617 esac
618 ;;
619 *)
620 PLATFORM=Ecos
621 PLATFORMNET=NoNet
622 AC_DEFINE(ECOS, 1, [Define if you're running eCos.])
623 PLATFORMH=posix.h
624 ;;
625 esac
626 AC_SUBST(PLATFORM_INNER_NAT_HDRS)
627 AC_CONFIG_LINKS(include/platform.h:include/$PLATFORMH)
628
629 AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1,
630 [Define if you have int32_t and uint32_t.]))
631 AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1,
632 [Define if you have int32_t and uint32_t.]))
633 AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1,
634 [Define if you have u_int32_t]))
635 AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1,
636 [Define if you have u_int32_t]))
637
638 AM_CONDITIONAL(USING_WIN32_PLATFORM, test "$PLATFORM" = Win32)
639 AM_CONDITIONAL(USING_POSIX_PLATFORM, test "$PLATFORM" = Posix || test "$PLATFORM" = Ecos)
640
641 case "$host" in
642 *-darwin*) DARWIN_CRT=true ;;
643 *) DARWIN_CRT=false ;;
644 esac
645 AM_CONDITIONAL(USING_DARWIN_CRT, $DARWIN_CRT)
646
647 # These may not be defined in a non-ANS conformant embedded system.
648 # FIXME: Should these case a runtime exception in that case?
649 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME, 1,
650 [Define is you have 'mktime' in <time.h>]))
651 AC_EGREP_HEADER(localtime, time.h, AC_DEFINE(HAVE_LOCALTIME, 1,
652 [Define is you have 'localtime' in <time.h>]))
653
654 # Create the subdirectory for natFile.cc, or the attempt
655 # to create the link will fail.
656 test -d java || mkdir java
657 test -d java/io || mkdir java/io
658 test -d gnu || mkdir gnu
659 AC_CONFIG_LINKS(java/io/natFile.cc:java/io/natFile${FILE-${PLATFORM}}.cc)
660
661 # Likewise for ConcreteProcess.java and natConcreteProcess.cc.
662 test -d java/lang || mkdir java/lang
663 AC_CONFIG_LINKS(java/lang/ConcreteProcess.java:java/lang/${PLATFORM}Process.java)
664 AC_CONFIG_LINKS(java/lang/natConcreteProcess.cc:java/lang/nat${PLATFORM}Process.cc)
665
666 # Likewise for natInetAddress.cc and natVMNetworkInterface.cc.
667 test -d java/net || mkdir java/net
668 AC_CONFIG_LINKS(java/net/natInetAddress.cc:java/net/natInetAddress${PLATFORMNET}.cc)
669 AC_CONFIG_LINKS(java/net/natVMNetworkInterface.cc:java/net/natVMNetworkInterface${PLATFORMNET}.cc)
670
671 # Likewise for natPlainSocketImpl.cc and natPlainDatagramSocketImpl.cc.
672 test -d gnu/java || mkdir gnu/java
673 test -d gnu/java/net || mkdir gnu/java/net
674 AC_CONFIG_LINKS(gnu/java/net/natPlainSocketImpl.cc:gnu/java/net/natPlainSocketImpl${PLATFORMNET}.cc)
675 AC_CONFIG_LINKS(gnu/java/net/natPlainDatagramSocketImpl.cc:gnu/java/net/natPlainDatagramSocketImpl${PLATFORMNET}.cc)
676
677 # Likewise for natPipeImpl.cc and natSelectorImpl.cc.
678 test -d gnu/java/nio || mkdir gnu/java/nio
679 AC_CONFIG_LINKS(gnu/java/nio/natPipeImpl.cc:gnu/java/nio/natPipeImpl${PLATFORM}.cc)
680 AC_CONFIG_LINKS(gnu/java/nio/natSelectorImpl.cc:gnu/java/nio/natSelectorImpl${PLATFORM}.cc)
681 test -d gnu/java/nio/channels || mkdir gnu/java/nio/channels
682 AC_CONFIG_LINKS(gnu/java/nio/channels/natFileChannelImpl.cc:gnu/java/nio/channels/natFileChannel${FILE-${PLATFORM}}.cc)
683
684 case "${host}" in
685 *mingw*)
686 SYSTEMSPEC="-lgdi32 -lws2_32"
687 if test "${with_win32_nlsapi}" = "unicows"; then
688 SYSTEMSPEC="-lunicows $SYSTEMSPEC"
689 fi
690 ;;
691 *)
692 SYSTEMSPEC=
693 ;;
694 esac
695 AC_SUBST(SYSTEMSPEC)
696
697 LIBGCJTESTSPEC="-L`${PWDCMD-pwd}`/.libs -rpath `${PWDCMD-pwd}`/.libs"
698 AC_SUBST(LIBGCJTESTSPEC)
699
700 AC_ARG_WITH(system-zlib,
701 AS_HELP_STRING([--with-system-zlib],
702 [use installed libz]))
703 ZLIBSPEC=
704 AC_SUBST(ZLIBSPEC)
705 ZLIBTESTSPEC=
706 AC_SUBST(ZLIBTESTSPEC)
707
708 AC_PATH_XTRA
709
710 # FIXME: this should be _libs on some hosts.
711 libsubdir=.libs
712
713 # extra LD Flags which are required for targets
714 case "${host}" in
715 *-*-darwin[[0-7]].*)
716 # For now we have to disable it on darwin[8-9] because it slows down
717 # the linking phase. A possible bug in ld?
718 # on Darwin -single_module speeds up loading of the dynamic libraries.
719 extra_ldflags_libjava=-Wl,-single_module
720 ;;
721 esac
722 AC_SUBST(extra_ldflags_libjava)
723
724 # Allow the GC to be disabled. Can be useful when debugging.
725 AC_MSG_CHECKING([for garbage collector to use])
726 AC_ARG_ENABLE(java-gc,
727 AS_HELP_STRING([--enable-java-gc=TYPE],
728 [choose garbage collector (default is boehm)]),
729 [GC=$enableval],
730 [GC=boehm])
731 GCLIBS=
732 GCINCS=
733 GCDEPS=
734 GCSPEC=
735 JC1GCSPEC=
736 GCTESTSPEC=
737 case "$GC" in
738 boehm)
739 AC_MSG_RESULT(boehm)
740 GCLIBS=../boehm-gc/libgcjgc_convenience.la
741 JC1GCSPEC='-fuse-boehm-gc'
742 GCTESTSPEC="-L`${PWDCMD-pwd}`/../boehm-gc/.libs -rpath `${PWDCMD-pwd}`/../boehm-gc/.libs"
743 GCINCS='-I$(top_srcdir)/../boehm-gc/include -I../boehm-gc/include'
744 GCOBJS=boehm.lo
745 GCHDR=boehm-gc.h
746 # The POSIX thread support needs to know this.
747 AC_DEFINE(HAVE_BOEHM_GC, 1, [Define if Boehm GC in use.])
748 ;;
749 no)
750 AC_MSG_RESULT(none)
751 GCHDR=no-gc.h
752 ;;
753 *)
754 AC_MSG_ERROR([unrecognized collector "$GC"])
755 ;;
756 esac
757 AC_SUBST(GCLIBS)
758 AC_SUBST(GCINCS)
759 AC_SUBST(GCDEPS)
760 AC_SUBST(GCSPEC)
761 AC_SUBST(JC1GCSPEC)
762 AC_SUBST(GCTESTSPEC)
763 AC_CONFIG_LINKS(include/java-gc.h:include/$GCHDR)
764 AM_CONDITIONAL(USING_BOEHMGC, test "$GC" = boehm)
765 AM_CONDITIONAL(USING_NOGC, test "$GC" = no)
766
767
768 AC_MSG_CHECKING([for thread model used by GCC])
769 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
770 AC_MSG_RESULT([$THREADS])
771
772 case "$THREADS" in
773 no | none | single)
774 THREADS=none
775 ;;
776 posix | posix95 | pthreads)
777 THREADS=posix
778 case "$host" in
779 *-*-linux*)
780 AC_DEFINE(LINUX_THREADS, 1, [Define if using POSIX threads on Linux.])
781 ;;
782 esac
783 ;;
784 win32)
785 ;;
786 decosf1 | irix | mach | os2 | solaris | dce | vxworks)
787 AC_MSG_ERROR(thread package $THREADS not yet supported)
788 ;;
789 *)
790 AC_MSG_ERROR($THREADS is an unknown thread package)
791 ;;
792 esac
793
794 THREADCXXFLAGS=
795 THREADLDFLAGS=
796 THREADLIBS=
797 THREADINCS=
798 THREADDEPS=
799 THREADH=
800 THREADSPEC=
801 THREADSTARTFILESPEC=
802 case "$THREADS" in
803 posix)
804 case "$host" in
805 *-*-cygwin*)
806 # Don't set THREADLIBS here. Cygwin doesn't have -lpthread.
807 ;;
808 *-*-freebsd[[1234]]*)
809 # Before FreeBSD 5, it didn't have -lpthread (or any library which
810 # merely adds pthread_* functions) but it does have a -pthread switch
811 # which is required at link-time to select -lc_r *instead* of -lc.
812 THREADLDFLAGS=-pthread
813 # Don't set THREADSPEC here as might be expected since -pthread is
814 # not processed when found within a spec file, it must come from
815 # the command line. For now, the user must provide the -pthread
816 # switch to link code compiled with gcj. In future, consider adding
817 # support for weak references to pthread_* functions ala gthr.h API.
818 THREADSPEC='%{!pthread: %{!shared: %eUnder this configuration, the user must provide -pthread when linking.}}'
819 ;;
820 *-*-freebsd*)
821 # FreeBSD >=5.3 implements a model much closer to other modern UNIX
822 # systems which support threads and -lpthread.
823 THREADLDFLAGS=-pthread
824 THREADSPEC=-lpthread
825 ;;
826 alpha*-dec-osf* | hppa*-hp-hpux*)
827 THREADCXXFLAGS=-pthread
828 # boehm-gc needs some functions from librt, so link that too.
829 THREADLIBS='-lpthread -lrt'
830 THREADSPEC='-lpthread -lrt'
831 ;;
832 *)
833 THREADLIBS=-lpthread
834 THREADSPEC=-lpthread
835 ;;
836 esac
837 THREADH=posix-threads.h
838 # MIT pthreads doesn't seem to have the mutexattr functions.
839 # But for now we don't check for it. We just assume you aren't
840 # using MIT pthreads.
841 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT, 1, [Define if using POSIX threads that have the mutexattr functions.])
842
843 # If we're using the Boehm GC, then we happen to know that it
844 # defines _REENTRANT, so we don't bother. Eww.
845 if test "$GC" != boehm; then
846 AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
847 fi
848 AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Required define if using POSIX threads])
849 ;;
850
851 win32)
852 THREADH=win32-threads.h
853 THREADCXXFLAGS=-mthreads
854 # We need thread-safe exception handling so _CRT_MT should be set to 1.
855 # But we do not want the executables created to be dependent on
856 # mingwm10.dll which provides a __mingwthr_key_dtor() that cleans up
857 # exception handling contexts. The following kludge achieves this effect
858 # and causes a dummy __mingwthr_key_dtor() to be linked in from
859 # libmingw32.a. This causes a memory leak of about 24 bytes per thread.
860 # A workaround is to explicitly use -mthreads while linking Java programs.
861 # See PR libgcj/28263.
862 #
863 # FIXME: In Java we are able to detect thread death at the end of
864 # Thread.run() so we should be able to clean up the exception handling
865 # contexts ourselves.
866 THREADSTARTFILESPEC='crtmt%O%s'
867 ;;
868
869 none)
870 THREADH=no-threads.h
871 ;;
872 esac
873 AC_CONFIG_LINKS(include/java-threads.h:include/$THREADH)
874 AC_SUBST(THREADLIBS)
875 AC_SUBST(THREADINCS)
876 AC_SUBST(THREADDEPS)
877 AC_SUBST(THREADSPEC)
878 AC_SUBST(THREADSTARTFILESPEC)
879 AC_SUBST(THREADLDFLAGS)
880 AC_SUBST(THREADCXXFLAGS)
881 AM_CONDITIONAL(USING_POSIX_THREADS, test "$THREADS" = posix)
882 AM_CONDITIONAL(USING_WIN32_THREADS, test "$THREADS" = win32)
883 AM_CONDITIONAL(USING_NO_THREADS, test "$THREADS" = none)
884 AM_CONDITIONAL(USE_LIBGCJ_BC, test "$use_libgcj_bc" = yes)
885
886 if test -d sysdep; then true; else mkdir sysdep; fi
887 AC_CONFIG_LINKS(sysdep/locks.h:sysdep/$sysdeps_dir/locks.h)
888 AC_CONFIG_LINKS(sysdep/backtrace.h:$fallback_backtrace_h)
889 AC_CONFIG_LINKS(sysdep/descriptor.h:$descriptor_h)
890
891 LIBGCJ_SPEC="%{s-bc-abi:} -lgcj"
892 if test "$use_libgcj_bc" = yes; then
893 LIBGCJ_SPEC="%{s-bc-abi:-lgcj_bc;:-lgcj}"
894 fi
895 AC_SUBST(LIBGCJ_SPEC)
896
897 HASH_SYNC_SPEC=
898 # Hash synchronization is only useful with posix threads right now.
899 if test "$enable_hash_synchronization" = yes && test "$THREADS" != "none"; then
900 HASH_SYNC_SPEC=-fhash-synchronization
901 AC_DEFINE(JV_HASH_SYNCHRONIZATION, 1, [Define if hash synchronization is in use])
902 fi
903 AC_SUBST(HASH_SYNC_SPEC)
904
905 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
906
907 # We're in the tree with gcc, and need to include some of its headers.
908 GCC_UNWIND_INCLUDE='-I$(libgcj_basedir)/../gcc'
909
910 if test "x${with_newlib}" = "xyes"; then
911 # We are being configured with a cross compiler. AC_REPLACE_FUNCS
912 # may not work correctly, because the compiler may not be able to
913 # link executables.
914
915 # We assume newlib. This lets us hard-code the functions we know
916 # we'll have.
917 AC_DEFINE(HAVE_MEMMOVE, 1, [Define if you have memmove.])
918 AC_DEFINE(HAVE_MEMCPY, 1, [Define if you have memcpy.])
919 AC_DEFINE(HAVE_STRERROR, 1, [Define if you have strerror.])
920 AC_DEFINE(HAVE_TIME, 1, [Define if you have time.])
921 AC_DEFINE(HAVE_GMTIME_R, 1, [Define if you have the 'gmtime_r' function])
922 AC_DEFINE(HAVE_LOCALTIME_R, 1, [Define if you have the 'localtime_r' function.])
923 AC_DEFINE(HAVE_USLEEP_DECL, 1, [Define if usleep is declared in <unistd.h>.])
924 # This is only for POSIX threads.
925 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT, 1, [Define if using POSIX threads that have the mutexattr functions.])
926 # We also assume we are using gcc, which provides alloca.
927 AC_DEFINE(HAVE_ALLOCA)
928
929 # Assume we do not have getuid and friends.
930 AC_DEFINE(NO_GETUID, 1, [Define if getuid() and friends are missing.])
931 PLATFORMNET=NoNet
932 else
933 AC_CHECK_FUNCS([strerror ioctl select fstat open fsync sleep opendir \
934 gmtime_r localtime_r readdir_r getpwuid_r getcwd \
935 access stat lstat mkdir rename rmdir unlink utime chmod readlink \
936 nl_langinfo setlocale \
937 inet_pton uname inet_ntoa \
938 fork execvp pipe sigaction ftruncate mmap \
939 getifaddrs])
940 AC_CHECK_FUNCS(inet_aton inet_addr, break)
941 AC_CHECK_HEADERS(execinfo.h unistd.h dlfcn.h)
942 # Do an additional check on dld, HP-UX for example has dladdr in libdld.sl
943 AC_CHECK_LIB(dl, dladdr, [
944 AC_DEFINE(HAVE_DLADDR, 1, [Define if you have dladdr()])], [
945 AC_CHECK_LIB(dld, dladdr, [
946 AC_DEFINE(HAVE_DLADDR, 1, [Define if you have dladdr()])])])
947
948 if test x"$build" = x"$host"; then
949 AC_CHECK_FILES(/proc/self/exe, [
950 AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])])
951 else
952 case $host in
953 *-linux*)
954 AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])
955 ;;
956 esac
957 fi
958
959 AM_ICONV
960 AM_LC_MESSAGES
961 AC_STRUCT_TIMEZONE
962
963 AC_CHECK_FUNCS(gethostbyname_r, [
964 AC_DEFINE(HAVE_GETHOSTBYNAME_R, 1,
965 [Define if you have the 'gethostbyname_r' function.])
966 # There are two different kinds of gethostbyname_r.
967 # We look for the one that returns `int'.
968 # Hopefully this check is robust enough.
969 AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
970 AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT, 1, [Define if gethostbyname_r returns 'int'.])])
971
972 case " $GCINCS " in
973 *" -D_REENTRANT "*) ;;
974 *)
975 dnl On DU4.0, gethostbyname_r is only declared with -D_REENTRANT
976 AC_CACHE_CHECK([whether gethostbyname_r declaration requires -D_REENTRANT],
977 [libjava_cv_gethostbyname_r_needs_reentrant],
978 [ AC_LANG_PUSH(C++)
979 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
980 [[gethostbyname_r("", 0, 0);]])],
981 [libjava_cv_gethostbyname_r_needs_reentrant=no], [dnl
982 CPPFLAGS_SAVE="$CPPFLAGS"
983 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
984 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[gethostbyname_r("", 0, 0);]])],
985 [libjava_cv_gethostbyname_r_needs_reentrant=yes],
986 [libjava_cv_gethostbyname_r_needs_reentrant=fail])
987 CPPFLAGS="$CPPFLAGS_SAVE"
988 ])
989 AC_LANG_POP(C++)
990 ])
991 if test "x$libjava_cv_gethostbyname_r_needs_reentrant" = xyes; then
992 AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
993 fi
994 ;;
995 esac
996
997 AC_CACHE_CHECK([for struct hostent_data],
998 [libjava_cv_struct_hostent_data], [dnl
999 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1000 #if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT)
1001 # define _REENTRANT 1
1002 #endif
1003 #include <netdb.h>]], [[struct hostent_data data;]])],
1004 [libjava_cv_struct_hostent_data=yes],
1005 [libjava_cv_struct_hostent_data=no])])
1006 if test "x$libjava_cv_struct_hostent_data" = xyes; then
1007 AC_DEFINE(HAVE_STRUCT_HOSTENT_DATA, 1,
1008 [Define if struct hostent_data is defined in netdb.h])
1009 fi
1010 ])
1011
1012 # FIXME: libjava source code expects to find a prototype for
1013 # gethostbyaddr_r in netdb.h. The outer check ensures that
1014 # HAVE_GETHOSTBYADDR_R will not be defined if the prototype fails
1015 # to exist where expected. (The root issue: AC_CHECK_FUNCS assumes C
1016 # linkage check is enough, yet C++ code requires proper prototypes.)
1017 AC_EGREP_HEADER(gethostbyaddr_r, netdb.h, [
1018 AC_CHECK_FUNCS(gethostbyaddr_r, [
1019 AC_DEFINE(HAVE_GETHOSTBYADDR_R, 1,
1020 [Define if you have the 'gethostbyaddr_r' function.])
1021 # There are two different kinds of gethostbyaddr_r.
1022 # We look for the one that returns `int'.
1023 # Hopefully this check is robust enough.
1024 AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
1025 AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT, 1,
1026 [Define if gethostbyaddr_r returns 'int'.])])])])
1027
1028 AC_CHECK_FUNCS(gethostname, [
1029 AC_DEFINE(HAVE_GETHOSTNAME, 1,
1030 [Define if you have the 'gethostname' function.])
1031 AC_EGREP_HEADER(gethostname, unistd.h, [
1032 AC_DEFINE(HAVE_GETHOSTNAME_DECL, 1,
1033 [Define if gethostname is declared in <unistd.h>.])])])
1034
1035 AC_CHECK_FUNCS(usleep, [
1036 AC_EGREP_HEADER(usleep, unistd.h, [
1037 AC_DEFINE(HAVE_USLEEP_DECL, 1,
1038 [Define if usleep is declared in <unistd.h>.])])])
1039
1040 # Look for these functions in the thread library, but only bother
1041 # if using POSIX threads.
1042 if test "$THREADS" = posix; then
1043 save_LIBS="$LIBS"
1044 LIBS="$LIBS $THREADLIBS"
1045 # Some POSIX thread systems don't have pthread_mutexattr_settype.
1046 # E.g., Solaris.
1047 AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
1048
1049 # Look for sched_yield. Up to Solaris 2.6, it is in libposix4, since
1050 # Solaris 7 the name librt is preferred.
1051 AC_CHECK_FUNCS(sched_yield, , [
1052 AC_CHECK_LIB(rt, sched_yield, [
1053 AC_DEFINE(HAVE_SCHED_YIELD)
1054 THREADLIBS="$THREADLIBS -lrt"
1055 THREADSPEC="$THREADSPEC -lrt"], [
1056 AC_CHECK_LIB(posix4, sched_yield, [
1057 AC_DEFINE(HAVE_SCHED_YIELD)
1058 THREADLIBS="$THREADLIBS -lposix4"
1059 THREADSPEC="$THREADSPEC -lposix4"])])])
1060
1061 AC_CHECK_LIB(rt, clock_gettime, [
1062 AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])
1063 case "$THREADSPEC" in
1064 *-lrt*) ;;
1065 *)
1066 THREADSPEC="$THREADSPEC -lrt"
1067 THREADLIBS="$THREADLIBS -lrt"
1068 ;;
1069 esac])
1070
1071 LIBS="$save_LIBS"
1072
1073 # We can save a little space at runtime if the mutex has m_count
1074 # or __m_count. This is a nice hack for Linux.
1075 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[
1076 extern pthread_mutex_t *mutex; int q = mutex->m_count;
1077 ]])], AC_DEFINE(PTHREAD_MUTEX_HAVE_M_COUNT, 1,
1078 [Define if pthread_mutex_t has m_count member.]), [
1079 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[
1080 extern pthread_mutex_t *mutex; int q = mutex->__m_count;
1081 ]])], AC_DEFINE(PTHREAD_MUTEX_HAVE___M_COUNT, 1,
1082 [Define if pthread_mutex_t has __m_count member.]))])
1083 fi
1084
1085 # We require a way to get the time.
1086 time_found=no
1087 AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
1088 if test "$time_found" = no; then
1089 AC_MSG_ERROR([no function found to get the time])
1090 fi
1091
1092 AC_CHECK_FUNCS(memmove)
1093
1094 # We require memcpy.
1095 memcpy_found=no
1096 AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
1097 if test "$memcpy_found" = no; then
1098 AC_MSG_ERROR([memcpy is required])
1099 fi
1100 # Do an additional check on dld, HP-UX for example has dlopen in libdld.sl
1101 AC_CHECK_LIB(dl, dlopen, [
1102 AC_DEFINE(HAVE_DLOPEN, 1, [Define if dlopen is available])], [
1103 AC_CHECK_LIB(dld, dlopen, [
1104 AC_DEFINE(HAVE_DLOPEN, 1, [Define if dlopen is available])])])
1105
1106 # Some library-finding code we stole from Tcl.
1107 #--------------------------------------------------------------------
1108 # Check for the existence of the -lsocket and -lnsl libraries.
1109 # The order here is important, so that they end up in the right
1110 # order in the command line generated by make. Here are some
1111 # special considerations:
1112 # 1. Use "connect" and "accept" to check for -lsocket, and
1113 # "gethostbyname" to check for -lnsl.
1114 # 2. Use each function name only once: can't redo a check because
1115 # autoconf caches the results of the last check and won't redo it.
1116 # 3. Use -lnsl and -lsocket only if they supply procedures that
1117 # aren't already present in the normal libraries. This is because
1118 # IRIX 5.2 has libraries, but they aren't needed and they're
1119 # bogus: they goof up name resolution if used.
1120 # 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
1121 # To get around this problem, check for both libraries together
1122 # if -lsocket doesn't work by itself.
1123 #--------------------------------------------------------------------
1124
1125 AC_CACHE_CHECK([for socket libraries], gcj_cv_lib_sockets,
1126 [gcj_cv_lib_sockets=
1127 gcj_checkBoth=0
1128 unset ac_cv_func_connect
1129 AC_CHECK_FUNC(connect, gcj_checkSocket=0, gcj_checkSocket=1)
1130 if test "$gcj_checkSocket" = 1; then
1131 unset ac_cv_func_connect
1132 AC_CHECK_LIB(socket, main, gcj_cv_lib_sockets="-lsocket",
1133 gcj_checkBoth=1)
1134 fi
1135 if test "$gcj_checkBoth" = 1; then
1136 gcj_oldLibs=$LIBS
1137 LIBS="$LIBS -lsocket -lnsl"
1138 unset ac_cv_func_accept
1139 AC_CHECK_FUNC(accept,
1140 [gcj_checkNsl=0
1141 gcj_cv_lib_sockets="-lsocket -lnsl"])
1142 unset ac_cv_func_accept
1143 LIBS=$gcj_oldLibs
1144 fi
1145 unset ac_cv_func_gethostbyname
1146 gcj_oldLibs=$LIBS
1147 LIBS="$LIBS $gcj_cv_lib_sockets"
1148 AC_CHECK_FUNC(gethostbyname, ,
1149 [AC_CHECK_LIB(nsl, main,
1150 [gcj_cv_lib_sockets="$gcj_cv_lib_sockets -lnsl"])])
1151 unset ac_cv_func_gethostbyname
1152 LIBS=$gcj_oldLIBS
1153 ])
1154 SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
1155
1156 if test "$with_system_zlib" = yes; then
1157 AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=)
1158 fi
1159
1160 # Test for Gtk stuff, if asked for.
1161 if test "$use_gtk_awt" = yes; then
1162 PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4)
1163 AC_SUBST(GTK_CFLAGS)
1164 AC_SUBST(GTK_LIBS)
1165
1166 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.4 gthread-2.0 >= 2.4)
1167 AC_SUBST(GLIB_CFLAGS)
1168 AC_SUBST(GLIB_LIBS)
1169
1170 PKG_CHECK_MODULES(LIBART, libart-2.0 >= 2.1)
1171 AC_SUBST(LIBART_CFLAGS)
1172 AC_SUBST(LIBART_LIBS)
1173
1174 # We require the XTest Extension to support java.awt.Robot.
1175 AC_CHECK_LIB([Xtst], [XTestQueryExtension], [true],
1176 [AC_MSG_ERROR([libXtst not found, required by java.awt.Robot])],
1177 [${X_LIBS}])
1178 fi
1179
1180 # On Solaris, and maybe other architectures, the Boehm collector
1181 # requires -ldl.
1182 if test "$GC" = boehm; then
1183 AC_CHECK_LIB(dl, main, SYSTEMSPEC="$SYSTEMSPEC -ldl")
1184 fi
1185 fi
1186
1187 # Use a semicolon as CLASSPATH separator for MinGW, otherwise a colon.
1188 case $build in
1189 *-mingw32) CLASSPATH_SEPARATOR=';' ;;
1190 *) CLASSPATH_SEPARATOR=':' ;;
1191 esac
1192 AC_SUBST(CLASSPATH_SEPARATOR)
1193
1194 # We must search the source tree for java.lang, since we still don't
1195 # have libgcj.jar nor java/lang/*.class
1196 GCJ_SAVE_CPPFLAGS=$CPPFLAGS
1197 CPPFLAGS="$CPPFLAGS -I`${PWDCMD-pwd}` -I`cd $srcdir && ${PWDCMD-pwd}`"
1198
1199 # Since some classes depend on this one, we need its source available
1200 # before we can do any GCJ compilation test :-(
1201 if test ! -f gnu/classpath/Configuration.java; then
1202 test -d gnu || mkdir gnu
1203 test -d gnu/classpath || mkdir gnu/classpath
1204 # Note that it is not crucial that all the values here be correct.
1205 sed -e "s,@prefix@,$prefix," \
1206 -e "s,@VERSION@,$VERSION," \
1207 -e "s,@LIBDEBUG@,false," \
1208 -e "s,@INIT_LOAD_LIBRARY@,false," \
1209 -e "s,@@,$LIBGCJDEBUG," \
1210 -e "s,@default_toolkit@,$TOOLKIT," \
1211 -e "s,@JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@,false," \
1212 -e "s,@GTK_CAIRO_ENABLED@,false," \
1213 < $srcdir/classpath/gnu/classpath/Configuration.java.in \
1214 > gnu/classpath/Configuration.java
1215 # We do not want to redirect the output of the grep below to /dev/null,
1216 # but we add /dev/null to the input list so that grep will print the
1217 # filename of Configuration.java in case it finds any matches.
1218 if grep '@.*@' gnu/classpath/Configuration.java /dev/null; then
1219 AC_MSG_ERROR([configure.ac is missing the substitutions above])
1220 fi
1221 fi
1222
1223 LT_AC_PROG_GCJ
1224
1225 # Now remove it.
1226 rm -f gnu/classpath/Configuration.java
1227
1228 CPPFLAGS=$GCJ_SAVE_CPPFLAGS
1229
1230 AC_CHECK_SIZEOF(void *)
1231
1232 AC_C_BIGENDIAN
1233
1234 ZLIBS=
1235 SYS_ZLIBS=
1236 ZINCS=
1237
1238 if test -z "$ZLIBSPEC"; then
1239 # Use zlib from the GCC tree.
1240 ZINCS='-I$(top_srcdir)/../zlib'
1241 ZLIBS=../zlib/libzgcj_convenience.la
1242 else
1243 # System's zlib.
1244 SYS_ZLIBS="$ZLIBSPEC"
1245 fi
1246 AC_SUBST(ZLIBS)
1247 AC_SUBST(SYS_ZLIBS)
1248 AC_SUBST(ZINCS)
1249 AC_SUBST(DIVIDESPEC)
1250 AC_SUBST(CHECKREFSPEC)
1251 AC_SUBST(EXCEPTIONSPEC)
1252 AC_SUBST(BACKTRACESPEC)
1253 AC_SUBST(IEEESPEC)
1254
1255 AM_CONDITIONAL(NATIVE, test "$NATIVE" = yes)
1256 AM_CONDITIONAL(NEEDS_DATA_START, test "$NEEDS_DATA_START" = yes && test "$NATIVE" = yes)
1257 AC_SUBST(GCC_UNWIND_INCLUDE)
1258
1259 # Process the option "--enable-version-specific-runtime-libs"
1260 # Calculate toolexeclibdir
1261 case ${version_specific_libs} in
1262 yes)
1263 # Need the gcc compiler version to know where to install libraries
1264 # and header files if --enable-version-specific-runtime-libs option
1265 # is selected.
1266 includedir='$(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include/'
1267 toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
1268 toolexecmainlibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
1269 toolexeclibdir=$toolexecmainlibdir
1270 ;;
1271 no)
1272 if test -n "$with_cross_host" &&
1273 test x"$with_cross_host" != x"no"; then
1274 # Install a library built with a cross compiler in tooldir, not libdir.
1275 toolexecdir='$(exec_prefix)/$(target_noncanonical)'
1276 toolexecmainlibdir='$(toolexecdir)/lib'
1277 else
1278 toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
1279 toolexecmainlibdir='$(libdir)'
1280 fi
1281 multi_os_directory=`$CC -print-multi-os-directory`
1282 case $multi_os_directory in
1283 .) toolexeclibdir=$toolexecmainlibdir ;; # Avoid trailing /.
1284 *) toolexeclibdir=$toolexecmainlibdir/$multi_os_directory ;;
1285 esac
1286 ;;
1287 esac
1288 AC_SUBST(toolexecdir)
1289 AC_SUBST(toolexecmainlibdir)
1290 AC_SUBST(toolexeclibdir)
1291
1292 # Determine where the standard .db file and GNU Classpath JNI
1293 # libraries are found.
1294 multi_os_directory=`$CC -print-multi-os-directory`
1295 case $multi_os_directory in
1296 .)
1297 dbexecdir='$(libdir)/gcj-$(gcc_version)' # Avoid /.
1298 ;;
1299 *)
1300 dbexecdir='$(libdir)/'$multi_os_directory'/gcj-$(gcc_version)'
1301 ;;
1302 esac
1303 AC_SUBST(dbexecdir)
1304
1305 # Determine gcj version number.
1306 gcjversion=`$GCJ -v 2>&1 | sed -n 's/^.*version \([[^ ]]*\).*$/\1/p'`
1307 GCJVERSION=$gcjversion
1308 AC_SUBST(GCJVERSION)
1309 AC_DEFINE_UNQUOTED(GCJVERSION, "$GCJVERSION", [Short GCJ version ID])
1310
1311 AC_DEFINE(JV_VERSION, "1.4.2", [Compatibility version string])
1312 AC_DEFINE(JV_API_VERSION, "1.4", [API compatibility version string])
1313
1314 TL_AC_GXX_INCLUDE_DIR
1315
1316 # We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
1317 # On that system, sys/ioctl.h will not include sys/filio.h unless
1318 # BSD_COMP is defined; just including sys/filio.h is simpler.
1319 # We avoid AC_HEADER_DIRENT since we really only care about dirent.h
1320 # for now. If you change this, you also must update natFile.cc.
1321 AC_CHECK_HEADERS([unistd.h bstring.h sys/time.h sys/types.h fcntl.h \
1322 sys/ioctl.h sys/filio.h sys/stat.h sys/select.h \
1323 sys/socket.h netinet/in.h arpa/inet.h netdb.h net/if.h \
1324 pwd.h sys/config.h stdint.h langinfo.h locale.h \
1325 dirent.h sys/rw_lock.h ifaddrs.h])
1326 AC_CHECK_HEADERS(inttypes.h, [
1327 AC_DEFINE(HAVE_INTTYPES_H, 1, [Define if <inttypes.h> is available])
1328 AC_DEFINE(JV_HAVE_INTTYPES_H, 1, [Define if <inttypes.h> is available])
1329 ])
1330 AC_HEADER_SYS_WAIT
1331
1332 AC_CHECK_TYPE([ssize_t], [int])
1333
1334 AC_MSG_CHECKING([for in_addr_t])
1335 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1336 #if STDC_HEADERS
1337 #include <stdlib.h>
1338 #include <stddef.h>
1339 #endif
1340 #if HAVE_NETINET_IN_H
1341 #include <netinet/in.h>
1342 #endif]], [[in_addr_t foo;]])],
1343 [AC_DEFINE(HAVE_IN_ADDR_T, 1,
1344 [Define to 1 if 'in_addr_t' is defined in sys/types.h or netinet/in.h.])
1345 AC_MSG_RESULT(yes)],
1346 [AC_MSG_RESULT(no)])
1347
1348 AC_MSG_CHECKING([whether struct ip_mreq is in netinet/in.h])
1349 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[struct ip_mreq mreq;]])],
1350 [AC_DEFINE(HAVE_STRUCT_IP_MREQ, 1,
1351 [Define if struct ip_mreq is defined in netinet/in.h.])
1352 AC_MSG_RESULT(yes)],
1353 [AC_MSG_RESULT(no)])
1354
1355 AC_MSG_CHECKING([whether struct ipv6_mreq is in netinet/in.h])
1356 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[struct ipv6_mreq mreq6;]])],
1357 [AC_DEFINE(HAVE_STRUCT_IPV6_MREQ, 1,
1358 [Define if struct ipv6_mreq is defined in netinet/in.h.])
1359 AC_MSG_RESULT(yes)],
1360 [AC_MSG_RESULT(no)])
1361
1362 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
1363 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[struct sockaddr_in6 addr6;]])],
1364 [AC_DEFINE(HAVE_INET6, 1,
1365 [Define if inet6 structures are defined in netinet/in.h.])
1366 AC_MSG_RESULT(yes)],
1367 [AC_MSG_RESULT(no)])
1368
1369 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
1370 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _POSIX_PII_SOCKET
1371 #include <sys/types.h>
1372 #include <sys/socket.h>]], [[socklen_t x = 5;]])],
1373 [AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define it socklen_t typedef is in sys/socket.h.])
1374 AC_MSG_RESULT(yes)],
1375 [AC_MSG_RESULT(no)])
1376
1377 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
1378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm tim; tim.tm_gmtoff = 0;]])],
1379 [AC_DEFINE(STRUCT_TM_HAS_GMTOFF, 1, [Define if struct tm has tm_gmtoff field.])
1380 AC_MSG_RESULT(yes)],
1381 [AC_MSG_RESULT(no)
1382 AC_MSG_CHECKING([for global timezone variable])
1383 dnl FIXME: we don't want a link check here because that won't work
1384 dnl when cross-compiling. So instead we make an assumption that
1385 dnl the header file will mention timezone if it exists.
1386 dnl Don't find the win32 function timezone
1387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[void i(){long z2 = 2*timezone;}]])],
1388 [AC_DEFINE(HAVE_TIMEZONE, 1, [Define if global 'timezone' exists.])
1389 AC_MSG_RESULT(yes)],
1390 [AC_MSG_RESULT(no)
1391 AC_MSG_CHECKING([for global _timezone variable])
1392 dnl FIXME: As above, don't want link check
1393 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[long z2 = _timezone;]])],
1394 [AC_DEFINE(HAVE_UNDERSCORE_TIMEZONE, 1,
1395 [Define if your platform has the global _timezone variable.])
1396 AC_MSG_RESULT(yes)],
1397 [AC_MSG_RESULT(no)])])])
1398
1399 AC_FUNC_ALLOCA
1400
1401 AC_CHECK_PROGS(PERL, perl, false)
1402
1403 SYSDEP_SOURCES=
1404 SIGNAL_HANDLER_AUX=
1405
1406 case "${host}" in
1407 i?86-*-linux*)
1408 SIGNAL_HANDLER=include/i386-signal.h
1409 ;;
1410 sparc*-sun-solaris*)
1411 SIGNAL_HANDLER=include/sparc-signal.h
1412 ;;
1413 # ia64-*)
1414 # SYSDEP_SOURCES=sysdep/ia64.c
1415 # test -d sysdep || mkdir sysdep
1416 # ;;
1417 hppa*-*-linux*)
1418 SIGNAL_HANDLER=include/pa-signal.h
1419 ;;
1420 hppa*-hp-hpux*)
1421 SIGNAL_HANDLER=include/hppa-signal.h
1422 ;;
1423 ia64-*-linux*)
1424 SIGNAL_HANDLER=include/dwarf2-signal.h
1425 ;;
1426 powerpc*-*-linux*)
1427 SIGNAL_HANDLER=include/powerpc-signal.h
1428 ;;
1429 alpha*-*-linux*)
1430 SIGNAL_HANDLER=include/dwarf2-signal.h
1431 ;;
1432 s390*-*-linux*)
1433 SIGNAL_HANDLER=include/s390-signal.h
1434 ;;
1435 x86_64*-*-linux*)
1436 SIGNAL_HANDLER=include/x86_64-signal.h
1437 SIGNAL_HANDLER_AUX=include/i386-signal.h
1438 ;;
1439 sparc*-*-linux*)
1440 SIGNAL_HANDLER=include/dwarf2-signal.h
1441 ;;
1442 sh*-*-linux*)
1443 SIGNAL_HANDLER=include/sh-signal.h
1444 ;;
1445 *mingw*)
1446 SIGNAL_HANDLER=include/win32-signal.h
1447 ;;
1448 mips*-*-linux*)
1449 SIGNAL_HANDLER=include/mips-signal.h
1450 ;;
1451 powerpc*-*-darwin*)
1452 SIGNAL_HANDLER=include/darwin-signal.h
1453 ;;
1454 *)
1455 SIGNAL_HANDLER=include/default-signal.h
1456 ;;
1457 esac
1458
1459 # If we're using sjlj exceptions, forget what we just learned.
1460 if test "$enable_sjlj_exceptions" = yes; then
1461 SIGNAL_HANDLER=include/default-signal.h
1462 SIGNAL_HANDLER_AUX=
1463 fi
1464
1465 AC_SUBST(SYSDEP_SOURCES)
1466
1467 if test -z "$SIGNAL_HANDLER_AUX"; then
1468 SIGNAL_HANDLER_AUX=$SIGNAL_HANDLER
1469 fi
1470
1471 AC_CONFIG_LINKS(include/java-signal.h:$SIGNAL_HANDLER
1472 include/java-signal-aux.h:$SIGNAL_HANDLER_AUX)
1473
1474 if test "${multilib}" = "yes"; then
1475 multilib_arg="--enable-multilib"
1476 else
1477 multilib_arg=
1478 fi
1479
1480 # See if we support thread-local storage.
1481 GCC_CHECK_TLS
1482
1483 # For _Unwind_GetIPInfo.
1484 GCC_CHECK_UNWIND_GETIPINFO
1485
1486 # Check if linker supports static linking on a per library basis
1487 LD_START_STATIC_SPEC=
1488 LD_FINISH_STATIC_SPEC=
1489 if $LD --help 2>&1 | grep -q -e -call_shared ; then
1490 if $LD --help 2>&1 | grep -q -e -non_shared ; then
1491 LD_START_STATIC_SPEC='%{static-libgcj:-non_shared}'
1492 LD_FINISH_STATIC_SPEC='%{static-libgcj:-call_shared}'
1493 fi
1494 fi
1495 AC_SUBST(LD_START_STATIC_SPEC)
1496 AC_SUBST(LD_FINISH_STATIC_SPEC)
1497
1498 here=`${PWDCMD-pwd}`
1499 AC_SUBST(here)
1500
1501 # We get this from the environment.
1502 AC_SUBST(GCJFLAGS)
1503
1504 AC_CONFIG_FILES([
1505 Makefile
1506 libgcj.pc
1507 libgcj.spec
1508 libgcj-test.spec
1509 gcj/Makefile
1510 include/Makefile
1511 testsuite/Makefile
1512 ])
1513
1514 AC_CONFIG_FILES([scripts/jar], [chmod +x scripts/jar])
1515
1516 AC_CONFIG_COMMANDS([default],
1517 [# Only add multilib support code if we just rebuilt top-level Makefile.
1518 case " $CONFIG_FILES " in
1519 *" Makefile "*)
1520 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
1521 ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
1522 ;;
1523 esac
1524 for ac_multi_file in $CONFIG_FILES; do
1525 case $ac_multi_file in
1526 */Makefile)
1527 grep "^MULTI[[^ ]]* =" Makefile >> "$ac_multi_file" ;;
1528 esac
1529 done
1530 ],
1531 srcdir=${srcdir}
1532 host=${host}
1533 target=${target}
1534 with_multisubdir=${with_multisubdir}
1535 ac_configure_args="${multilib_arg} ${ac_configure_args}"
1536 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1537 libgcj_basedir=${libgcj_basedir}
1538 CC="${CC}"
1539 CXX="${CXX}"
1540 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
1541 )
1542
1543 AC_OUTPUT