1 dnl Process this with autoconf to create configure
2 AC_INIT(java/lang/System.java)
4 dnl Can't be done in LIBGCJ_CONFIGURE because that confuses automake.
9 dnl We use these options to decide which functions to include.
10 AC_ARG_WITH(target-subdir,
11 [ --with-target-subdir=SUBDIR
12 configuring in a subdirectory])
13 AC_ARG_WITH(cross-host,
14 [ --with-cross-host=HOST configuring with a cross compiler])
18 AM_CONFIG_HEADER(include/config.h)
22 if test -z "$with_target_subdir" || test "$with_target_subdir" = "."; then
29 dnl The -no-testsuite modules omit the test subdir.
30 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
32 dnl See whether the user prefers size or speed for Character.
33 dnl The default is size.
34 AC_ARG_ENABLE(fast-character,
35 [ --enable-fast-character prefer speed over size for Character],
37 , AC_DEFINE(COMPACT_CHARACTER))
39 dnl See if the user has requested runtime debugging.
40 AC_ARG_ENABLE(libgcj-debug,
41 [ --enable-libgcj-debug enable runtime debugging code],
42 if test "$enable_libgcj_debug" = yes; then
46 dnl See if the user has the enterpreter included.
47 AC_ARG_ENABLE(interpreter,
48 [ --enable-interpreter enable interpreter],
49 if test "$enable_interpreter" = yes; then
50 AC_DEFINE(INTERPRETER)
53 dnl This becomes -lffi if the interpreter is enabled.
57 dnl If the target is an eCos system, use the appropriate eCos
59 dnl FIXME: this should not be a local option but a global target
60 dnl system; at present there is no eCos target.
63 [ --with-ecos enable runtime eCos target support],
64 TARGET_ECOS="$with_ecos"
67 case "$TARGET_ECOS" in
69 FILE_DESCRIPTOR=natFileDescriptorPosix.cc
73 FILE_DESCRIPTOR=natFileDescriptorEcos.cc
79 AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED))
80 AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED))
81 AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
82 AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
85 dnl These may not be defined in a non-ANS conformant embedded system.
86 dnl FIXME: Should these case a runtime exception in that case?
87 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME))
88 AC_EGREP_HEADER(localtime, time.h, AC_DEFINE(HAVE_LOCALTIME))
90 dnl Create the subdirectory for natFileDescriptor.cc, or the attempt
91 dnl to create the link will fail.
92 test -d java || mkdir java
93 test -d java/io || mkdir java/io
94 AC_LINK_FILES(java/io/$FILE_DESCRIPTOR, java/io/natFileDescriptor.cc)
96 dnl Likewise for ConcreteProcess.java and natConcreteProcess.cc.
97 test -d java/lang || mkdir java/lang
98 AC_LINK_FILES(java/lang/${PROCESS}Process.java, java/lang/ConcreteProcess.java)
99 AC_LINK_FILES(java/lang/nat${PROCESS}Process.cc, java/lang/natConcreteProcess.cc)
104 AC_ARG_WITH(system-zlib,
105 [ --with-system-zlib use installed libz])
109 dnl FIXME: this should be _libs on some hosts.
112 dnl Allow the GC to be disabled. Can be useful when debugging.
113 AC_MSG_CHECKING([for garbage collector to use])
114 AC_ARG_ENABLE(java-gc,
115 changequote(<<,>>)dnl
116 << --enable-java-gc=TYPE choose garbage collector [boehm]>>,
128 GCDEPS='$(top_builddir)/../boehm-gc/libgcjgc.la'
129 # We include the path to the boehm-gc build directory.
130 # See Makefile.am to understand why.
131 GCLIBS="$GCDEPS -L\$(here)/../boehm-gc/$libsubdir"
132 GCINCS='-I$(top_srcdir)/../boehm-gc -I$(top_builddir)/../boehm-gc'
134 dnl We also want to pick up some cpp flags required when including
135 dnl boehm-config.h. Yuck.
136 GCINCS="$GCINCS `cat ../boehm-gc/boehm-cflags`"
139 dnl The POSIX thread support needs to know this.
140 AC_DEFINE(HAVE_BOEHM_GC)
148 AC_MSG_ERROR(unrecognized collector \"$GC\")
156 AC_LINK_FILES(include/$GCHDR, include/java-gc.h)
159 dnl Note that this code is kept in sync with similar code in gcc/configure.in.
160 dnl In particular both packages must make the same decision about which
161 dnl thread package to use.
162 AC_MSG_CHECKING([for threads package to use])
163 AC_ARG_ENABLE(threads, [ --enable-threads=TYPE choose threading package],
165 dnl FIXME: figure out native threads to use here.
168 if test "$THREADS" = yes; then
174 # FIXME: this isn't correct in all cases.
181 # FIXME: for now, choose POSIX, because we implement that.
182 # Later, choose irix threads.
186 # FIXME: for now, choose POSIX, because we implement that.
187 # Later, choose solaris threads.
205 AC_DEFINE(LINUX_THREADS)
211 decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
212 AC_MSG_ERROR(thread package $THREADS not yet supported)
215 AC_MSG_ERROR($THREADS is an unknown thread package)
218 AC_MSG_RESULT($THREADS)
230 THREADOBJS=posix-threads.lo
231 THREADH=posix-threads.h
232 # MIT pthreads doesn't seem to have the mutexattr functions.
233 # But for now we don't check for it. We just assume you aren't
234 # using MIT pthreads.
235 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
239 THREADDEPS='$(top_builddir)/../qthreads/libgcjcoop.la'
240 # We include the path to the qthreads build directory.
241 # See Makefile.am to understand why.
242 THREADLIBS="$THREADDEPS -L\$(here)/../qthreads/$libsubdir"
243 THREADSPEC='-lgcjcoop'
244 THREADOBJS=quick-threads.lo
245 THREADINCS='-I$(top_srcdir)/../qthreads'
246 THREADH=quick-threads.h
250 THREADOBJS=no-threads.lo
254 AC_LINK_FILES(include/$THREADH, include/java-threads.h)
261 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
266 # Find eh-common.h and support headers. If we're in the tree with
267 # gcc, then look there. Otherwise look in compat-include. If all else
268 # fails, just hope the user has set things up somehow.
269 if test -r $srcdir/../gcc/eh-common.h; then
270 EH_COMMON_INCLUDE='-I$(top_srcdir)/../gcc -I$(top_srcdir)/../include'
272 if test -d $srcdir/../compat-include; then
273 EH_COMMON_INCLUDE='-I$(top_srcdir)/../compat-include'
279 if test -n "${with_cross_host}"; then
280 # We are being configured with a cross compiler. AC_REPLACE_FUNCS
281 # may not work correctly, because the compiler may not be able to
284 # We assume newlib. This lets us hard-code the functions we know
286 AC_DEFINE(HAVE_MEMMOVE)
287 AC_DEFINE(HAVE_MEMCPY)
288 AC_DEFINE(HAVE_STRERROR)
289 AC_DEFINE(HAVE_CTIME_R)
290 AC_DEFINE(HAVE_GMTIME_R)
291 AC_DEFINE(HAVE_LOCALTIME_R)
292 dnl This is only for POSIX threads.
293 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
294 dnl We also assume we are using gcc, which provides alloca.
295 AC_DEFINE(HAVE_ALLOCA)
299 # If Canadian cross, then don't pick up tools from the build
301 if test "$build" != "$with_cross_host"; then
304 GCJ="${target_alias}/gcj"
309 # Some POSIX thread systems don't have pthread_mutexattr_settype.
311 AC_CHECK_FUNCS(strerror ioctl select open fsync sleep)
312 AC_CHECK_FUNCS(ctime_r ctime, break)
313 AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r)
314 AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
315 AC_CHECK_FUNCS(inet_aton inet_addr, break)
316 AC_CHECK_FUNCS(inet_pton uname inet_ntoa)
318 AC_CHECK_FUNCS(gethostbyname_r, [
319 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
320 # There are two different kinds of gethostbyname_r.
321 # We look for the one that returns `int'.
322 # Hopefully this check is robust enough.
323 AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
324 AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)])
327 *" -D_REENTRANT "*) ;;
329 dnl On DU4.0, gethostbyname_r is only declared with -D_REENTRANT
330 AC_CACHE_CHECK([whether gethostbyname_r declaration requires -D_REENTRANT],
331 [libjava_cv_gethostbyname_r_needs_reentrant],
334 AC_TRY_COMPILE([#include <netdb.h>],
335 [gethostbyname_r("", 0, 0);],
336 [libjava_cv_gethostbyname_r_needs_reentrant=no], [dnl
337 CPPFLAGS_SAVE="$CPPFLAGS"
338 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
339 AC_TRY_COMPILE([#include <netdb.h>], [gethostbyname_r("", 0, 0);],
340 [libjava_cv_gethostbyname_r_needs_reentrant=yes],
341 [libjava_cv_gethostbyname_r_needs_reentrant=fail])
342 CPPFLAGS="$CPPFLAGS_SAVE"
346 if test "x$libjava_cv_gethostbyname_r_needs_reentrant" = xyes; then
347 AC_DEFINE(GETHOSTBYNAME_R_NEEDS_REENTRANT, 1, [Define if gethostbyname_r is only declared if _REENTRANT is defined])
352 AC_CACHE_CHECK([for struct hostent_data],
353 [libjava_cv_struct_hostent_data], [dnl
355 #if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT)
356 # define _REENTRANT 1
358 #include <netdb.h>], [struct hostent_data data;],
359 [libjava_cv_struct_hostent_data=yes],
360 [libjava_cv_struct_hostent_data=no])])
361 if test "x$libjava_cv_struct_hostent_data" = xyes; then
362 AC_DEFINE(HAVE_STRUCT_HOSTENT_DATA, 1,
363 [Define if struct hostent_data is defined in netdb.h])
367 AC_CHECK_FUNCS(gethostbyaddr_r, [
368 AC_DEFINE(HAVE_GETHOSTBYADDR_R)
369 # There are two different kinds of gethostbyaddr_r.
370 # We look for the one that returns `int'.
371 # Hopefully this check is robust enough.
372 AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
373 AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT)])])
375 AC_CHECK_FUNCS(gethostname, [
376 AC_DEFINE(HAVE_GETHOSTNAME)
377 AC_EGREP_HEADER(gethostname, unistd.h, [
378 AC_DEFINE(HAVE_GETHOSTNAME_DECL)])])
380 # Look for these functions in the thread library.
382 LIBS="$LIBS $THREADLIBS"
383 AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np)
385 # Look for sched_yield. Up to Solaris 2.6, it is in libposix4, since
386 # Solaris 7 the name librt is preferred.
387 AC_CHECK_FUNCS(sched_yield, , [
388 AC_CHECK_LIB(rt, sched_yield, [
389 AC_DEFINE(HAVE_SCHED_YIELD)
390 THREADLIBS="$THREADLIBS -lrt"
391 THREADSPECS="$THREADSPECS -lrt"], [
392 AC_CHECK_LIB(posix4, sched_yield, [
393 AC_DEFINE(HAVE_SCHED_YIELD)
394 THREADLIBS="$THREADLIBS -lposix4"
395 THREADSPECS="$THREADSPECS -lposix4"])])])
398 # We require a way to get the time.
400 AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
401 if test "$time_found" = no; then
402 AC_MSG_ERROR([no function found to get the time])
405 AC_CHECK_FUNCS(memmove)
409 AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
410 if test "$memcpy_found" = no; then
411 AC_MSG_ERROR([memcpy is required])
414 # Some library-finding code we stole from Tcl.
415 #--------------------------------------------------------------------
416 # Check for the existence of the -lsocket and -lnsl libraries.
417 # The order here is important, so that they end up in the right
418 # order in the command line generated by make. Here are some
419 # special considerations:
420 # 1. Use "connect" and "accept" to check for -lsocket, and
421 # "gethostbyname" to check for -lnsl.
422 # 2. Use each function name only once: can't redo a check because
423 # autoconf caches the results of the last check and won't redo it.
424 # 3. Use -lnsl and -lsocket only if they supply procedures that
425 # aren't already present in the normal libraries. This is because
426 # IRIX 5.2 has libraries, but they aren't needed and they're
427 # bogus: they goof up name resolution if used.
428 # 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
429 # To get around this problem, check for both libraries together
430 # if -lsocket doesn't work by itself.
431 #--------------------------------------------------------------------
433 AC_CACHE_CHECK([for socket libraries], gcj_cv_lib_sockets,
436 unset ac_cv_func_connect
437 AC_CHECK_FUNC(connect, gcj_checkSocket=0, gcj_checkSocket=1)
438 if test "$gcj_checkSocket" = 1; then
439 unset ac_cv_func_connect
440 AC_CHECK_LIB(socket, main, gcj_cv_lib_sockets="-lsocket",
443 if test "$gcj_checkBoth" = 1; then
445 LIBS="$LIBS -lsocket -lnsl"
446 unset ac_cv_func_accept
447 AC_CHECK_FUNC(accept,
449 gcj_cv_lib_sockets="-lsocket -lnsl"])
450 unset ac_cv_func_accept
453 unset ac_cv_func_gethostbyname
455 LIBS="$LIBS $gcj_cv_lib_sockets"
456 AC_CHECK_FUNC(gethostbyname, ,
457 [AC_CHECK_LIB(nsl, main,
458 [gcj_cv_lib_sockets="$gcj_cv_lib_sockets -lnsl"])])
459 unset ac_cv_func_gethostbyname
462 SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
464 if test "$enable_interpreter" = yes; then
468 if test "$with_system_zlib" = yes; then
469 AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=-lzgcj)
474 # On Solaris, and maybe other architectures, the Boehm collector
476 if test "$GC" = boehm; then
477 AC_CHECK_LIB(dl, main, SYSTEMSPEC="$SYSTEMSPEC -ldl")
480 if test -d "$libgcj_basedir/../gcc/java"; then
492 if test "x$ZLIBSPEC" = "x-lzgcj"; then
493 # We include the path to the zlib build directory.
494 # See Makefile.am to understand why.
495 ZDEPS='$(top_builddir)/../zlib/libzgcj.la'
496 ZLIBS="$ZDEPS -L\$(here)/../zlib/$libsubdir"
497 ZINCS='-I$(top_srcdir)/../zlib'
506 AM_CONDITIONAL(CANADIAN, test "$CANADIAN" = yes)
507 AM_CONDITIONAL(NULL_TARGET, test "$NULL_TARGET" = yes)
508 AM_CONDITIONAL(NATIVE, test "$CANADIAN" = no || test "$NULL_TARGET" = yes)
509 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
510 AC_SUBST(EH_COMMON_INCLUDE)
512 # Determine gcj version number.
513 if test "$GCJ" = ""; then
514 if test -z "${with_multisubdir}"; then
517 builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`
519 dir="`cd ${builddotdot}/../../gcc && pwd`"
520 GCJ="$dir/gcj -B$dir/"
523 gcjvers="`$GCJ -v 2>&1 | sed -n 's/^.*version \([^ ]*\).*$/\1/p'`"
525 AC_DEFINE_UNQUOTED(GCJVERSION, "$gcjvers")
527 # See if gcj supports -fuse-divide-subroutine. gcc 2.95 does not, and
528 # we want to continue to support that version.
529 cat > conftest.java << 'END'
530 public class conftest { }
533 $GCJ -fuse-divide-subroutine -fsyntax-only conftest.java || use_fuse=no
535 if test "$use_fuse" = no; then
539 AC_SUBST(AM_RUNTESTFLAGS)
541 dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
542 dnl On that system, sys/ioctl.h will not include sys/filio.h unless
543 dnl BSD_COMP is defined; just including sys/filio.h is simpler.
544 AC_CHECK_HEADERS(unistd.h bstring.h sys/time.h sys/types.h fcntl.h sys/ioctl.h sys/filio.h sys/stat.h sys/select.h sys/socket.h netinet/in.h arpa/inet.h netdb.h pwd.h sys/config.h inttypes.h stdint.h)
545 dnl We avoid AC_HEADER_DIRENT since we really only care about dirent.h
546 dnl for now. If you change this, you also must update natFile.cc.
547 AC_CHECK_HEADERS(dirent.h)
549 AC_CHECK_TYPE([ssize_t], [int])
551 AC_MSG_CHECKING([for in_addr_t])
552 AC_TRY_COMPILE([#include <sys/types.h>
557 #if HAVE_NETINET_IN_H
558 #include <netinet/in.h>
559 #endif], [in_addr_t foo;],
560 [AC_DEFINE([HAVE_IN_ADDR_T])
564 AC_MSG_CHECKING([whether struct ip_mreq is in netinet/in.h])
565 AC_TRY_COMPILE([#include <netinet/in.h>], [struct ip_mreq mreq;],
566 [AC_DEFINE(HAVE_STRUCT_IP_MREQ)
570 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
571 AC_TRY_COMPILE([#include <netinet/in.h>], [struct sockaddr_in6 addr6;],
572 [AC_DEFINE(HAVE_INET6)
576 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
577 AC_TRY_COMPILE([#include <sys/socket.h>], [socklen_t x = 5;],
578 [AC_DEFINE(HAVE_SOCKLEN_T)
582 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
583 AC_TRY_COMPILE([#include <time.h>], [struct tm tim; tim.tm_gmtoff = 0;],
584 [AC_DEFINE(STRUCT_TM_HAS_GMTOFF)
587 AC_MSG_CHECKING([for global timezone variable])
588 dnl FIXME: we don't want a link check here because that won't work
589 dnl when cross-compiling. So instead we make an assumption that
590 dnl the header file will mention timezone if it exists.
591 AC_TRY_COMPILE([#include <time.h>], [long z2 = timezone;],
592 [AC_DEFINE(HAVE_TIMEZONE)
594 [AC_MSG_RESULT(no)])])
598 AC_CHECK_PROGS(PERL, perl, false)
602 SIGNAL_HANDLER=include/i386-signal.h
605 SIGNAL_HANDLER=include/sparc-signal.h
608 SIGNAL_HANDLER=include/default-signal.h
612 AC_LINK_FILES($SIGNAL_HANDLER, include/java-signal.h)
614 if test "${multilib}" = "yes"; then
615 multilib_arg="--enable-multilib"
623 AC_OUTPUT(Makefile libgcj.spec testsuite/Makefile,
624 [if test -n "$CONFIG_FILES"; then
625 ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
630 with_multisubdir=${with_multisubdir}
631 ac_configure_args="${multilib_arg} ${ac_configure_args}"
632 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
633 libgcj_basedir=${libgcj_basedir}