Imported GNU Classpath 0.92
[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
885 if test -d sysdep; then true; else mkdir sysdep; fi
886 AC_CONFIG_LINKS(sysdep/locks.h:sysdep/$sysdeps_dir/locks.h)
887 AC_CONFIG_LINKS(sysdep/backtrace.h:$fallback_backtrace_h)
888 AC_CONFIG_LINKS(sysdep/descriptor.h:$descriptor_h)
889
890 HASH_SYNC_SPEC=
891 # Hash synchronization is only useful with posix threads right now.
892 if test "$enable_hash_synchronization" = yes && test "$THREADS" != "none"; then
893 HASH_SYNC_SPEC=-fhash-synchronization
894 AC_DEFINE(JV_HASH_SYNCHRONIZATION, 1, [Define if hash synchronization is in use])
895 fi
896 AC_SUBST(HASH_SYNC_SPEC)
897
898 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
899
900 # We're in the tree with gcc, and need to include some of its headers.
901 GCC_UNWIND_INCLUDE='-I$(libgcj_basedir)/../gcc'
902
903 if test "x${with_newlib}" = "xyes"; then
904 # We are being configured with a cross compiler. AC_REPLACE_FUNCS
905 # may not work correctly, because the compiler may not be able to
906 # link executables.
907
908 # We assume newlib. This lets us hard-code the functions we know
909 # we'll have.
910 AC_DEFINE(HAVE_MEMMOVE, 1, [Define if you have memmove.])
911 AC_DEFINE(HAVE_MEMCPY, 1, [Define if you have memcpy.])
912 AC_DEFINE(HAVE_STRERROR, 1, [Define if you have strerror.])
913 AC_DEFINE(HAVE_TIME, 1, [Define if you have time.])
914 AC_DEFINE(HAVE_GMTIME_R, 1, [Define if you have the 'gmtime_r' function])
915 AC_DEFINE(HAVE_LOCALTIME_R, 1, [Define if you have the 'localtime_r' function.])
916 AC_DEFINE(HAVE_USLEEP_DECL, 1, [Define if usleep is declared in <unistd.h>.])
917 # This is only for POSIX threads.
918 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT, 1, [Define if using POSIX threads that have the mutexattr functions.])
919 # We also assume we are using gcc, which provides alloca.
920 AC_DEFINE(HAVE_ALLOCA)
921
922 # Assume we do not have getuid and friends.
923 AC_DEFINE(NO_GETUID, 1, [Define if getuid() and friends are missing.])
924 PLATFORMNET=NoNet
925 else
926 AC_CHECK_FUNCS([strerror ioctl select fstat open fsync sleep opendir \
927 gmtime_r localtime_r readdir_r getpwuid_r getcwd \
928 access stat lstat mkdir rename rmdir unlink utime chmod readlink \
929 nl_langinfo setlocale \
930 inet_pton uname inet_ntoa \
931 fork execvp pipe sigaction ftruncate mmap \
932 getifaddrs])
933 AC_CHECK_FUNCS(inet_aton inet_addr, break)
934 AC_CHECK_HEADERS(execinfo.h unistd.h dlfcn.h)
935 # Do an additional check on dld, HP-UX for example has dladdr in libdld.sl
936 AC_CHECK_LIB(dl, dladdr, [
937 AC_DEFINE(HAVE_DLADDR, 1, [Define if you have dladdr()])], [
938 AC_CHECK_LIB(dld, dladdr, [
939 AC_DEFINE(HAVE_DLADDR, 1, [Define if you have dladdr()])])])
940
941 if test x"$build" = x"$host"; then
942 AC_CHECK_FILES(/proc/self/exe, [
943 AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])])
944 else
945 case $host in
946 *-linux*)
947 AC_DEFINE(HAVE_PROC_SELF_EXE, 1, [Define if you have /proc/self/exe])
948 ;;
949 esac
950 fi
951
952 AM_ICONV
953 AM_LC_MESSAGES
954 AC_STRUCT_TIMEZONE
955
956 AC_CHECK_FUNCS(gethostbyname_r, [
957 AC_DEFINE(HAVE_GETHOSTBYNAME_R, 1,
958 [Define if you have the 'gethostbyname_r' function.])
959 # There are two different kinds of gethostbyname_r.
960 # We look for the one that returns `int'.
961 # Hopefully this check is robust enough.
962 AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
963 AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT, 1, [Define if gethostbyname_r returns 'int'.])])
964
965 case " $GCINCS " in
966 *" -D_REENTRANT "*) ;;
967 *)
968 dnl On DU4.0, gethostbyname_r is only declared with -D_REENTRANT
969 AC_CACHE_CHECK([whether gethostbyname_r declaration requires -D_REENTRANT],
970 [libjava_cv_gethostbyname_r_needs_reentrant],
971 [ AC_LANG_PUSH(C++)
972 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
973 [[gethostbyname_r("", 0, 0);]])],
974 [libjava_cv_gethostbyname_r_needs_reentrant=no], [dnl
975 CPPFLAGS_SAVE="$CPPFLAGS"
976 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
977 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[gethostbyname_r("", 0, 0);]])],
978 [libjava_cv_gethostbyname_r_needs_reentrant=yes],
979 [libjava_cv_gethostbyname_r_needs_reentrant=fail])
980 CPPFLAGS="$CPPFLAGS_SAVE"
981 ])
982 AC_LANG_POP(C++)
983 ])
984 if test "x$libjava_cv_gethostbyname_r_needs_reentrant" = xyes; then
985 AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
986 fi
987 ;;
988 esac
989
990 AC_CACHE_CHECK([for struct hostent_data],
991 [libjava_cv_struct_hostent_data], [dnl
992 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
993 #if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT)
994 # define _REENTRANT 1
995 #endif
996 #include <netdb.h>]], [[struct hostent_data data;]])],
997 [libjava_cv_struct_hostent_data=yes],
998 [libjava_cv_struct_hostent_data=no])])
999 if test "x$libjava_cv_struct_hostent_data" = xyes; then
1000 AC_DEFINE(HAVE_STRUCT_HOSTENT_DATA, 1,
1001 [Define if struct hostent_data is defined in netdb.h])
1002 fi
1003 ])
1004
1005 # FIXME: libjava source code expects to find a prototype for
1006 # gethostbyaddr_r in netdb.h. The outer check ensures that
1007 # HAVE_GETHOSTBYADDR_R will not be defined if the prototype fails
1008 # to exist where expected. (The root issue: AC_CHECK_FUNCS assumes C
1009 # linkage check is enough, yet C++ code requires proper prototypes.)
1010 AC_EGREP_HEADER(gethostbyaddr_r, netdb.h, [
1011 AC_CHECK_FUNCS(gethostbyaddr_r, [
1012 AC_DEFINE(HAVE_GETHOSTBYADDR_R, 1,
1013 [Define if you have the 'gethostbyaddr_r' function.])
1014 # There are two different kinds of gethostbyaddr_r.
1015 # We look for the one that returns `int'.
1016 # Hopefully this check is robust enough.
1017 AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
1018 AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT, 1,
1019 [Define if gethostbyaddr_r returns 'int'.])])])])
1020
1021 AC_CHECK_FUNCS(gethostname, [
1022 AC_DEFINE(HAVE_GETHOSTNAME, 1,
1023 [Define if you have the 'gethostname' function.])
1024 AC_EGREP_HEADER(gethostname, unistd.h, [
1025 AC_DEFINE(HAVE_GETHOSTNAME_DECL, 1,
1026 [Define if gethostname is declared in <unistd.h>.])])])
1027
1028 AC_CHECK_FUNCS(usleep, [
1029 AC_EGREP_HEADER(usleep, unistd.h, [
1030 AC_DEFINE(HAVE_USLEEP_DECL, 1,
1031 [Define if usleep is declared in <unistd.h>.])])])
1032
1033 # Look for these functions in the thread library, but only bother
1034 # if using POSIX threads.
1035 if test "$THREADS" = posix; then
1036 save_LIBS="$LIBS"
1037 LIBS="$LIBS $THREADLIBS"
1038 # Some POSIX thread systems don't have pthread_mutexattr_settype.
1039 # E.g., Solaris.
1040 AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
1041
1042 # Look for sched_yield. Up to Solaris 2.6, it is in libposix4, since
1043 # Solaris 7 the name librt is preferred.
1044 AC_CHECK_FUNCS(sched_yield, , [
1045 AC_CHECK_LIB(rt, sched_yield, [
1046 AC_DEFINE(HAVE_SCHED_YIELD)
1047 THREADLIBS="$THREADLIBS -lrt"
1048 THREADSPEC="$THREADSPEC -lrt"], [
1049 AC_CHECK_LIB(posix4, sched_yield, [
1050 AC_DEFINE(HAVE_SCHED_YIELD)
1051 THREADLIBS="$THREADLIBS -lposix4"
1052 THREADSPEC="$THREADSPEC -lposix4"])])])
1053
1054 AC_CHECK_LIB(rt, clock_gettime, [
1055 AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])
1056 case "$THREADSPEC" in
1057 *-lrt*) ;;
1058 *)
1059 THREADSPEC="$THREADSPEC -lrt"
1060 THREADLIBS="$THREADLIBS -lrt"
1061 ;;
1062 esac])
1063
1064 LIBS="$save_LIBS"
1065
1066 # We can save a little space at runtime if the mutex has m_count
1067 # or __m_count. This is a nice hack for Linux.
1068 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[
1069 extern pthread_mutex_t *mutex; int q = mutex->m_count;
1070 ]])], AC_DEFINE(PTHREAD_MUTEX_HAVE_M_COUNT, 1,
1071 [Define if pthread_mutex_t has m_count member.]), [
1072 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[
1073 extern pthread_mutex_t *mutex; int q = mutex->__m_count;
1074 ]])], AC_DEFINE(PTHREAD_MUTEX_HAVE___M_COUNT, 1,
1075 [Define if pthread_mutex_t has __m_count member.]))])
1076 fi
1077
1078 # We require a way to get the time.
1079 time_found=no
1080 AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
1081 if test "$time_found" = no; then
1082 AC_MSG_ERROR([no function found to get the time])
1083 fi
1084
1085 AC_CHECK_FUNCS(memmove)
1086
1087 # We require memcpy.
1088 memcpy_found=no
1089 AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
1090 if test "$memcpy_found" = no; then
1091 AC_MSG_ERROR([memcpy is required])
1092 fi
1093 # Do an additional check on dld, HP-UX for example has dlopen in libdld.sl
1094 AC_CHECK_LIB(dl, dlopen, [
1095 AC_DEFINE(HAVE_DLOPEN, 1, [Define if dlopen is available])], [
1096 AC_CHECK_LIB(dld, dlopen, [
1097 AC_DEFINE(HAVE_DLOPEN, 1, [Define if dlopen is available])])])
1098
1099 # Some library-finding code we stole from Tcl.
1100 #--------------------------------------------------------------------
1101 # Check for the existence of the -lsocket and -lnsl libraries.
1102 # The order here is important, so that they end up in the right
1103 # order in the command line generated by make. Here are some
1104 # special considerations:
1105 # 1. Use "connect" and "accept" to check for -lsocket, and
1106 # "gethostbyname" to check for -lnsl.
1107 # 2. Use each function name only once: can't redo a check because
1108 # autoconf caches the results of the last check and won't redo it.
1109 # 3. Use -lnsl and -lsocket only if they supply procedures that
1110 # aren't already present in the normal libraries. This is because
1111 # IRIX 5.2 has libraries, but they aren't needed and they're
1112 # bogus: they goof up name resolution if used.
1113 # 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
1114 # To get around this problem, check for both libraries together
1115 # if -lsocket doesn't work by itself.
1116 #--------------------------------------------------------------------
1117
1118 AC_CACHE_CHECK([for socket libraries], gcj_cv_lib_sockets,
1119 [gcj_cv_lib_sockets=
1120 gcj_checkBoth=0
1121 unset ac_cv_func_connect
1122 AC_CHECK_FUNC(connect, gcj_checkSocket=0, gcj_checkSocket=1)
1123 if test "$gcj_checkSocket" = 1; then
1124 unset ac_cv_func_connect
1125 AC_CHECK_LIB(socket, main, gcj_cv_lib_sockets="-lsocket",
1126 gcj_checkBoth=1)
1127 fi
1128 if test "$gcj_checkBoth" = 1; then
1129 gcj_oldLibs=$LIBS
1130 LIBS="$LIBS -lsocket -lnsl"
1131 unset ac_cv_func_accept
1132 AC_CHECK_FUNC(accept,
1133 [gcj_checkNsl=0
1134 gcj_cv_lib_sockets="-lsocket -lnsl"])
1135 unset ac_cv_func_accept
1136 LIBS=$gcj_oldLibs
1137 fi
1138 unset ac_cv_func_gethostbyname
1139 gcj_oldLibs=$LIBS
1140 LIBS="$LIBS $gcj_cv_lib_sockets"
1141 AC_CHECK_FUNC(gethostbyname, ,
1142 [AC_CHECK_LIB(nsl, main,
1143 [gcj_cv_lib_sockets="$gcj_cv_lib_sockets -lnsl"])])
1144 unset ac_cv_func_gethostbyname
1145 LIBS=$gcj_oldLIBS
1146 ])
1147 SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
1148
1149 if test "$with_system_zlib" = yes; then
1150 AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=)
1151 fi
1152
1153 # Test for Gtk stuff, if asked for.
1154 if test "$use_gtk_awt" = yes; then
1155 PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4)
1156 AC_SUBST(GTK_CFLAGS)
1157 AC_SUBST(GTK_LIBS)
1158
1159 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.4 gthread-2.0 >= 2.4)
1160 AC_SUBST(GLIB_CFLAGS)
1161 AC_SUBST(GLIB_LIBS)
1162
1163 PKG_CHECK_MODULES(LIBART, libart-2.0 >= 2.1)
1164 AC_SUBST(LIBART_CFLAGS)
1165 AC_SUBST(LIBART_LIBS)
1166
1167 # We require the XTest Extension to support java.awt.Robot.
1168 AC_CHECK_LIB([Xtst], [XTestQueryExtension], [true],
1169 [AC_MSG_ERROR([libXtst not found, required by java.awt.Robot])],
1170 [${X_LIBS}])
1171 fi
1172
1173 # On Solaris, and maybe other architectures, the Boehm collector
1174 # requires -ldl.
1175 if test "$GC" = boehm; then
1176 AC_CHECK_LIB(dl, main, SYSTEMSPEC="$SYSTEMSPEC -ldl")
1177 fi
1178 fi
1179
1180 # Use a semicolon as CLASSPATH separator for MinGW, otherwise a colon.
1181 case $build in
1182 *-mingw32) CLASSPATH_SEPARATOR=';' ;;
1183 *) CLASSPATH_SEPARATOR=':' ;;
1184 esac
1185 AC_SUBST(CLASSPATH_SEPARATOR)
1186
1187 # We must search the source tree for java.lang, since we still don't
1188 # have libgcj.jar nor java/lang/*.class
1189 GCJ_SAVE_CPPFLAGS=$CPPFLAGS
1190 CPPFLAGS="$CPPFLAGS -I`${PWDCMD-pwd}` -I`cd $srcdir && ${PWDCMD-pwd}`"
1191
1192 # Since some classes depend on this one, we need its source available
1193 # before we can do any GCJ compilation test :-(
1194 if test ! -f gnu/classpath/Configuration.java; then
1195 test -d gnu || mkdir gnu
1196 test -d gnu/classpath || mkdir gnu/classpath
1197 # Note that it is not crucial that all the values here be correct.
1198 sed -e "s,@prefix@,$prefix," \
1199 -e "s,@VERSION@,$VERSION," \
1200 -e "s,@LIBDEBUG@,false," \
1201 -e "s,@INIT_LOAD_LIBRARY@,false," \
1202 -e "s,@@,$LIBGCJDEBUG," \
1203 -e "s,@default_toolkit@,$TOOLKIT," \
1204 -e "s,@JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@,false," \
1205 -e "s,@GTK_CAIRO_ENABLED@,false," \
1206 < $srcdir/classpath/gnu/classpath/Configuration.java.in \
1207 > gnu/classpath/Configuration.java
1208 # We do not want to redirect the output of the grep below to /dev/null,
1209 # but we add /dev/null to the input list so that grep will print the
1210 # filename of Configuration.java in case it finds any matches.
1211 if grep '@.*@' gnu/classpath/Configuration.java /dev/null; then
1212 AC_MSG_ERROR([configure.ac is missing the substitutions above])
1213 fi
1214 fi
1215
1216 LT_AC_PROG_GCJ
1217
1218 # Now remove it.
1219 rm -f gnu/classpath/Configuration.java
1220
1221 CPPFLAGS=$GCJ_SAVE_CPPFLAGS
1222
1223 AC_CHECK_SIZEOF(void *)
1224
1225 AC_C_BIGENDIAN
1226
1227 ZLIBS=
1228 SYS_ZLIBS=
1229 ZINCS=
1230
1231 if test -z "$ZLIBSPEC"; then
1232 # Use zlib from the GCC tree.
1233 ZINCS='-I$(top_srcdir)/../zlib'
1234 ZLIBS=../zlib/libzgcj_convenience.la
1235 else
1236 # System's zlib.
1237 SYS_ZLIBS="$ZLIBSPEC"
1238 fi
1239 AC_SUBST(ZLIBS)
1240 AC_SUBST(SYS_ZLIBS)
1241 AC_SUBST(ZINCS)
1242 AC_SUBST(DIVIDESPEC)
1243 AC_SUBST(CHECKREFSPEC)
1244 AC_SUBST(EXCEPTIONSPEC)
1245 AC_SUBST(BACKTRACESPEC)
1246 AC_SUBST(IEEESPEC)
1247
1248 AM_CONDITIONAL(NATIVE, test "$NATIVE" = yes)
1249 AM_CONDITIONAL(NEEDS_DATA_START, test "$NEEDS_DATA_START" = yes && test "$NATIVE" = yes)
1250 AC_SUBST(GCC_UNWIND_INCLUDE)
1251
1252 # Process the option "--enable-version-specific-runtime-libs"
1253 # Calculate toolexeclibdir
1254 case ${version_specific_libs} in
1255 yes)
1256 # Need the gcc compiler version to know where to install libraries
1257 # and header files if --enable-version-specific-runtime-libs option
1258 # is selected.
1259 includedir='$(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include/'
1260 toolexecdir='$(libdir)/gcc/$(target_noncanonical)'
1261 toolexecmainlibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
1262 toolexeclibdir=$toolexecmainlibdir
1263 ;;
1264 no)
1265 if test -n "$with_cross_host" &&
1266 test x"$with_cross_host" != x"no"; then
1267 # Install a library built with a cross compiler in tooldir, not libdir.
1268 toolexecdir='$(exec_prefix)/$(target_noncanonical)'
1269 toolexecmainlibdir='$(toolexecdir)/lib'
1270 else
1271 toolexecdir='$(libdir)/gcc-lib/$(target_noncanonical)'
1272 toolexecmainlibdir='$(libdir)'
1273 fi
1274 multi_os_directory=`$CC -print-multi-os-directory`
1275 case $multi_os_directory in
1276 .) toolexeclibdir=$toolexecmainlibdir ;; # Avoid trailing /.
1277 *) toolexeclibdir=$toolexecmainlibdir/$multi_os_directory ;;
1278 esac
1279 ;;
1280 esac
1281 AC_SUBST(toolexecdir)
1282 AC_SUBST(toolexecmainlibdir)
1283 AC_SUBST(toolexeclibdir)
1284
1285 # Determine where the standard .db file and GNU Classpath JNI
1286 # libraries are found.
1287 multi_os_directory=`$CC -print-multi-os-directory`
1288 case $multi_os_directory in
1289 .)
1290 dbexecdir='$(libdir)/gcj-$(gcc_version)' # Avoid /.
1291 ac_configure_args="$ac_configure_args --with-native-libdir=\$\(libdir\)/gcj-`cat $srcdir/../gcc/BASE-VER`"
1292 ;;
1293 *)
1294 dbexecdir='$(libdir)/'$multi_os_directory'/gcj-$(gcc_version)'
1295 ac_configure_args="$ac_configure_args --with-native-libdir=\$\(libdir\)/$multi_os_directory/gcj-`cat $srcdir/../gcc/BASE-VER`"
1296 ;;
1297 esac
1298 AC_SUBST(dbexecdir)
1299
1300 # Determine gcj version number.
1301 gcjversion=`$GCJ -v 2>&1 | sed -n 's/^.*version \([[^ ]]*\).*$/\1/p'`
1302 GCJVERSION=$gcjversion
1303 AC_SUBST(GCJVERSION)
1304 AC_DEFINE_UNQUOTED(GCJVERSION, "$GCJVERSION", [Short GCJ version ID])
1305
1306 AC_DEFINE(JV_VERSION, "1.4.2", [Compatibility version string])
1307 AC_DEFINE(JV_API_VERSION, "1.4", [API compatibility version string])
1308
1309 TL_AC_GXX_INCLUDE_DIR
1310
1311 # We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
1312 # On that system, sys/ioctl.h will not include sys/filio.h unless
1313 # BSD_COMP is defined; just including sys/filio.h is simpler.
1314 # We avoid AC_HEADER_DIRENT since we really only care about dirent.h
1315 # for now. If you change this, you also must update natFile.cc.
1316 AC_CHECK_HEADERS([unistd.h bstring.h sys/time.h sys/types.h fcntl.h \
1317 sys/ioctl.h sys/filio.h sys/stat.h sys/select.h \
1318 sys/socket.h netinet/in.h arpa/inet.h netdb.h net/if.h \
1319 pwd.h sys/config.h stdint.h langinfo.h locale.h \
1320 dirent.h sys/rw_lock.h ifaddrs.h])
1321 AC_CHECK_HEADERS(inttypes.h, [
1322 AC_DEFINE(HAVE_INTTYPES_H, 1, [Define if <inttypes.h> is available])
1323 AC_DEFINE(JV_HAVE_INTTYPES_H, 1, [Define if <inttypes.h> is available])
1324 ])
1325 AC_HEADER_SYS_WAIT
1326
1327 AC_CHECK_TYPE([ssize_t], [int])
1328
1329 AC_MSG_CHECKING([for in_addr_t])
1330 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1331 #if STDC_HEADERS
1332 #include <stdlib.h>
1333 #include <stddef.h>
1334 #endif
1335 #if HAVE_NETINET_IN_H
1336 #include <netinet/in.h>
1337 #endif]], [[in_addr_t foo;]])],
1338 [AC_DEFINE(HAVE_IN_ADDR_T, 1,
1339 [Define to 1 if 'in_addr_t' is defined in sys/types.h or netinet/in.h.])
1340 AC_MSG_RESULT(yes)],
1341 [AC_MSG_RESULT(no)])
1342
1343 AC_MSG_CHECKING([whether struct ip_mreq is in netinet/in.h])
1344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[struct ip_mreq mreq;]])],
1345 [AC_DEFINE(HAVE_STRUCT_IP_MREQ, 1,
1346 [Define if struct ip_mreq is defined in netinet/in.h.])
1347 AC_MSG_RESULT(yes)],
1348 [AC_MSG_RESULT(no)])
1349
1350 AC_MSG_CHECKING([whether struct ipv6_mreq is in netinet/in.h])
1351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[struct ipv6_mreq mreq6;]])],
1352 [AC_DEFINE(HAVE_STRUCT_IPV6_MREQ, 1,
1353 [Define if struct ipv6_mreq is defined in netinet/in.h.])
1354 AC_MSG_RESULT(yes)],
1355 [AC_MSG_RESULT(no)])
1356
1357 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
1358 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[struct sockaddr_in6 addr6;]])],
1359 [AC_DEFINE(HAVE_INET6, 1,
1360 [Define if inet6 structures are defined in netinet/in.h.])
1361 AC_MSG_RESULT(yes)],
1362 [AC_MSG_RESULT(no)])
1363
1364 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
1365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _POSIX_PII_SOCKET
1366 #include <sys/types.h>
1367 #include <sys/socket.h>]], [[socklen_t x = 5;]])],
1368 [AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define it socklen_t typedef is in sys/socket.h.])
1369 AC_MSG_RESULT(yes)],
1370 [AC_MSG_RESULT(no)])
1371
1372 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
1373 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm tim; tim.tm_gmtoff = 0;]])],
1374 [AC_DEFINE(STRUCT_TM_HAS_GMTOFF, 1, [Define if struct tm has tm_gmtoff field.])
1375 AC_MSG_RESULT(yes)],
1376 [AC_MSG_RESULT(no)
1377 AC_MSG_CHECKING([for global timezone variable])
1378 dnl FIXME: we don't want a link check here because that won't work
1379 dnl when cross-compiling. So instead we make an assumption that
1380 dnl the header file will mention timezone if it exists.
1381 dnl Don't find the win32 function timezone
1382 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[void i(){long z2 = 2*timezone;}]])],
1383 [AC_DEFINE(HAVE_TIMEZONE, 1, [Define if global 'timezone' exists.])
1384 AC_MSG_RESULT(yes)],
1385 [AC_MSG_RESULT(no)
1386 AC_MSG_CHECKING([for global _timezone variable])
1387 dnl FIXME: As above, don't want link check
1388 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[long z2 = _timezone;]])],
1389 [AC_DEFINE(HAVE_UNDERSCORE_TIMEZONE, 1,
1390 [Define if your platform has the global _timezone variable.])
1391 AC_MSG_RESULT(yes)],
1392 [AC_MSG_RESULT(no)])])])
1393
1394 AC_FUNC_ALLOCA
1395
1396 AC_CHECK_PROGS(PERL, perl, false)
1397
1398 SYSDEP_SOURCES=
1399 SIGNAL_HANDLER_AUX=
1400
1401 case "${host}" in
1402 i?86-*-linux*)
1403 SIGNAL_HANDLER=include/i386-signal.h
1404 ;;
1405 sparc*-sun-solaris*)
1406 SIGNAL_HANDLER=include/sparc-signal.h
1407 ;;
1408 # ia64-*)
1409 # SYSDEP_SOURCES=sysdep/ia64.c
1410 # test -d sysdep || mkdir sysdep
1411 # ;;
1412 hppa*-*-linux*)
1413 SIGNAL_HANDLER=include/pa-signal.h
1414 ;;
1415 hppa*-hp-hpux*)
1416 SIGNAL_HANDLER=include/hppa-signal.h
1417 ;;
1418 ia64-*-linux*)
1419 SIGNAL_HANDLER=include/dwarf2-signal.h
1420 ;;
1421 powerpc*-*-linux*)
1422 SIGNAL_HANDLER=include/powerpc-signal.h
1423 ;;
1424 alpha*-*-linux*)
1425 SIGNAL_HANDLER=include/dwarf2-signal.h
1426 ;;
1427 s390*-*-linux*)
1428 SIGNAL_HANDLER=include/s390-signal.h
1429 ;;
1430 x86_64*-*-linux*)
1431 SIGNAL_HANDLER=include/x86_64-signal.h
1432 SIGNAL_HANDLER_AUX=include/i386-signal.h
1433 ;;
1434 sparc*-*-linux*)
1435 SIGNAL_HANDLER=include/dwarf2-signal.h
1436 ;;
1437 sh*-*-linux*)
1438 SIGNAL_HANDLER=include/sh-signal.h
1439 ;;
1440 *mingw*)
1441 SIGNAL_HANDLER=include/win32-signal.h
1442 ;;
1443 mips*-*-linux*)
1444 SIGNAL_HANDLER=include/mips-signal.h
1445 ;;
1446 *-*-darwin*)
1447 SIGNAL_HANDLER=include/darwin-signal.h
1448 ;;
1449 *)
1450 SIGNAL_HANDLER=include/default-signal.h
1451 ;;
1452 esac
1453
1454 # If we're using sjlj exceptions, forget what we just learned.
1455 if test "$enable_sjlj_exceptions" = yes; then
1456 SIGNAL_HANDLER=include/default-signal.h
1457 SIGNAL_HANDLER_AUX=
1458 fi
1459
1460 AC_SUBST(SYSDEP_SOURCES)
1461
1462 if test -z "$SIGNAL_HANDLER_AUX"; then
1463 SIGNAL_HANDLER_AUX=$SIGNAL_HANDLER
1464 fi
1465
1466 AC_CONFIG_LINKS(include/java-signal.h:$SIGNAL_HANDLER
1467 include/java-signal-aux.h:$SIGNAL_HANDLER_AUX)
1468
1469 if test "${multilib}" = "yes"; then
1470 multilib_arg="--enable-multilib"
1471 else
1472 multilib_arg=
1473 fi
1474
1475 # See if we support thread-local storage.
1476 GCC_CHECK_TLS
1477
1478 # Check if linker supports static linking on a per library basis
1479 LD_START_STATIC_SPEC=
1480 LD_FINISH_STATIC_SPEC=
1481 if $LD --help 2>&1 | grep -q -e -call_shared ; then
1482 if $LD --help 2>&1 | grep -q -e -non_shared ; then
1483 LD_START_STATIC_SPEC='%{static-libgcj:-non_shared}'
1484 LD_FINISH_STATIC_SPEC='%{static-libgcj:-call_shared}'
1485 fi
1486 fi
1487 AC_SUBST(LD_START_STATIC_SPEC)
1488 AC_SUBST(LD_FINISH_STATIC_SPEC)
1489
1490 here=`${PWDCMD-pwd}`
1491 AC_SUBST(here)
1492
1493 # We get this from the environment.
1494 AC_SUBST(GCJFLAGS)
1495
1496 AC_CONFIG_FILES([
1497 Makefile
1498 libgcj.pc
1499 libgcj.spec
1500 libgcj-test.spec
1501 gcj/Makefile
1502 include/Makefile
1503 testsuite/Makefile
1504 ])
1505
1506 AC_CONFIG_FILES([scripts/jar], [chmod +x scripts/jar])
1507
1508 AC_CONFIG_COMMANDS([default],
1509 [# Only add multilib support code if we just rebuilt top-level Makefile.
1510 case " $CONFIG_FILES " in
1511 *" Makefile "*)
1512 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
1513 ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
1514 ;;
1515 esac
1516 for ac_multi_file in $CONFIG_FILES; do
1517 case $ac_multi_file in
1518 */Makefile)
1519 grep "^MULTI[[^ ]]* =" Makefile >> "$ac_multi_file" ;;
1520 esac
1521 done
1522 ],
1523 srcdir=${srcdir}
1524 host=${host}
1525 target=${target}
1526 with_multisubdir=${with_multisubdir}
1527 ac_configure_args="${multilib_arg} ${ac_configure_args}"
1528 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1529 libgcj_basedir=${libgcj_basedir}
1530 CC="${CC}"
1531 CXX="${CXX}"
1532 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
1533 )
1534
1535 AC_OUTPUT