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 Configuring in a subdirectory])
12 AC_ARG_WITH(cross-host,
13 [ --with-cross-host=HOST Configuring with a cross compiler])
17 AM_CONFIG_HEADER(include/config.h)
21 if test -z "$with_target_subdir" || test "$with_target_subdir" = "."; then
28 dnl The -no-testsuite modules omit the test subdir.
29 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
31 dnl See whether the user prefers size or speed for Character.
32 dnl The default is size.
33 AC_ARG_ENABLE(fast-character,
34 [ --enable-fast-character Prefer speed over size for Character],
36 , AC_DEFINE(COMPACT_CHARACTER))
38 dnl See if the user has requested runtime debugging.
39 AC_ARG_ENABLE(libgcj-debug,
40 [ --enable-libgcj-debug Enable runtime debugging code],
41 if test "$enable_libgcj_debug" = yes; then
45 dnl If the target is an eCos system, use the appropriate eCos
47 dnl FIXME: this should not be a local option but a global target
48 dnl system; at present there is no eCos target.
51 [ --with-ecos Enable runtime eCos target support.],
52 TARGET_ECOS="$with_ecos"
55 case "$TARGET_ECOS" in
57 FILE_DESCRIPTOR=natFileDescriptorPosix.cc
61 FILE_DESCRIPTOR=natFileDescriptorEcos.cc
67 AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED))
68 AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED))
69 AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
70 AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED))
73 dnl These may not be defined in a non-ANS conformant embedded system.
74 dnl FIXME: Should these case a runtime exception in that case?
75 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME))
76 AC_EGREP_HEADER(localtime, time.h, AC_DEFINE(HAVE_LOCALTIME))
78 dnl Create the subdirectory for natFileDescriptor.cc, or the attempt
79 dnl to create the link will fail.
80 test -d java || mkdir java
81 test -d java/io || mkdir java/io
82 AC_LINK_FILES(java/io/$FILE_DESCRIPTOR, java/io/natFileDescriptor.cc)
84 dnl Likewise for ConcreteProcess.java and natConcreteProcess.cc.
85 test -d java/lang || mkdir java/lang
86 AC_LINK_FILES(java/lang/${PROCESS}Process.java, java/lang/ConcreteProcess.java)
87 AC_LINK_FILES(java/lang/nat${PROCESS}Process.cc, java/lang/natConcreteProcess.cc)
92 AC_ARG_WITH(system-zlib,
93 [ --with-system-zlib Use installed libz])
97 dnl FIXME: this should be _libs on some hosts.
100 dnl Allow the GC to be disabled. Can be useful when debugging.
101 AC_MSG_CHECKING([for garbage collector to use])
102 AC_ARG_ENABLE(java-gc,
103 changequote(<<,>>)dnl
104 << --enable-java-gc=TYPE choose garbage collector [boehm]>>,
116 GCDEPS='$(top_builddir)/../boehm-gc/libgcjgc.la'
117 # We include the path to the boehm-gc build directory.
118 # See Makefile.am to understand why.
119 GCLIBS="$GCDEPS -L\$(here)/../boehm-gc/$libsubdir"
120 GCINCS='-I$(top_srcdir)/../boehm-gc -I$(top_builddir)/../boehm-gc'
122 dnl We also want to pick up some cpp flags required when including
123 dnl boehm-config.h. Yuck.
124 GCINCS="$GCINCS `cat ../boehm-gc/boehm-cflags`"
127 dnl The POSIX thread support needs to know this.
128 AC_DEFINE(HAVE_BOEHM_GC)
136 AC_MSG_ERROR(unrecognized collector \"$GC\")
144 AC_LINK_FILES(include/$GCHDR, include/java-gc.h)
147 dnl Note that this code is kept in sync with similar code in gcc/configure.in.
148 dnl In particular both packages must make the same decision about which
149 dnl thread package to use.
150 AC_MSG_CHECKING([for threads package to use])
151 AC_ARG_ENABLE(threads, [ --enable-threads=TYPE choose threading package],
153 dnl FIXME: figure out native threads to use here.
156 if test "$THREADS" = yes; then
162 # FIXME: this isn't correct in all cases.
169 # FIXME: for now, choose POSIX, because we implement that.
170 # Later, choose irix threads.
174 # FIXME: for now, choose POSIX, because we implement that.
175 # Later, choose solaris threads.
193 AC_DEFINE(LINUX_THREADS)
199 decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
200 AC_MSG_ERROR(thread package $THREADS not yet supported)
203 AC_MSG_ERROR($THREADS is an unknown thread package)
206 AC_MSG_RESULT($THREADS)
218 THREADOBJS=posix-threads.lo
219 THREADH=posix-threads.h
220 # MIT pthreads doesn't seem to have the mutexattr functions.
221 # But for now we don't check for it. We just assume you aren't
222 # using MIT pthreads.
223 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
227 THREADDEPS='$(top_builddir)/../qthreads/libgcjcoop.la'
228 # We include the path to the qthreads build directory.
229 # See Makefile.am to understand why.
230 THREADLIBS="$THREADDEPS -L\$(here)/../qthreads/$libsubdir"
231 THREADSPEC='-lgcjcoop'
232 THREADOBJS=quick-threads.lo
233 THREADINCS='-I$(top_srcdir)/../qthreads'
234 THREADH=quick-threads.h
238 THREADOBJS=no-threads.lo
242 AC_LINK_FILES(include/$THREADH, include/java-threads.h)
249 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
254 # Find eh-common.h and support headers. If we're in the tree with
255 # gcc, then look there. Otherwise look in compat-include. If all else
256 # fails, just hope the user has set things up somehow.
257 if test -r $srcdir/../gcc/eh-common.h; then
258 EH_COMMON_INCLUDE='-I$(top_srcdir)/../gcc -I$(top_srcdir)/../include'
260 if test -d $srcdir/../compat-include; then
261 EH_COMMON_INCLUDE='-I$(top_srcdir)/../compat-include'
267 if test -n "${with_cross_host}"; then
268 # We are being configured with a cross compiler. AC_REPLACE_FUNCS
269 # may not work correctly, because the compiler may not be able to
272 # We assume newlib. This lets us hard-code the functions we know
274 AC_DEFINE(HAVE_MEMMOVE)
275 AC_DEFINE(HAVE_MEMCPY)
276 AC_DEFINE(HAVE_STRERROR)
277 AC_DEFINE(HAVE_CTIME_R)
278 AC_DEFINE(HAVE_GMTIME_R)
279 AC_DEFINE(HAVE_LOCALTIME_R)
280 dnl This is only for POSIX threads.
281 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
282 dnl We also assume we are using gcc, which provides alloca.
283 AC_DEFINE(HAVE_ALLOCA)
287 # If Canadian cross, then don't pick up tools from the build
289 if test "$build" != "$with_cross_host"; then
292 GCJ="${target_alias}/gcj"
297 # Some POSIX thread systems don't have pthread_mutexattr_settype.
299 AC_CHECK_FUNCS(strerror ioctl select open fsync sleep)
300 AC_CHECK_FUNCS(ctime_r ctime, break)
301 AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r)
302 AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
303 AC_CHECK_FUNCS(inet_aton inet_addr, break)
304 AC_CHECK_FUNCS(inet_pton uname inet_ntoa)
306 AC_CHECK_FUNCS(gethostbyname_r, [
307 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
308 # There are two different kinds of gethostbyname_r.
309 # We look for the one that returns `int'.
310 # Hopefully this check is robust enough.
311 AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
312 AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)])])
314 AC_CHECK_FUNCS(gethostbyaddr_r, [
315 AC_DEFINE(HAVE_GETHOSTBYADDR_R)
316 # There are two different kinds of gethostbyaddr_r.
317 # We look for the one that returns `int'.
318 # Hopefully this check is robust enough.
319 AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
320 AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT)])])
322 AC_CHECK_FUNCS(gethostname, [
323 AC_DEFINE(HAVE_GETHOSTNAME)
324 AC_EGREP_HEADER(gethostname, unistd.h, [
325 AC_DEFINE(HAVE_GETHOSTNAME_DECL)])])
327 # Look for these functions in the thread library.
329 LIBS="$LIBS $THREADLIBS"
330 AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np sched_yield)
331 # Look for sched_yield. Sometimes it is in the posix4 library.
332 AC_CHECK_FUNCS(sched_yield, , [
333 AC_CHECK_LIB(posix4, sched_yield, [
334 AC_DEFINE(HAVE_SCHED_YIELD)
335 THREADLIBS="$THREADLIBS -lposix4"])])
338 # We require a way to get the time.
340 AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
341 if test "$time_found" = no; then
342 AC_MSG_ERROR([no function found to get the time])
345 # We require memmove.
347 AC_CHECK_FUNCS(memmove, memmove_found=yes)
348 if test "$memmove_found" = no; then
349 AC_MSG_ERROR([memmove is required])
354 AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
355 if test "$memcpy_found" = no; then
356 AC_MSG_ERROR([memcpy is required])
359 # Some library-finding code we stole from Tcl.
360 #--------------------------------------------------------------------
361 # Check for the existence of the -lsocket and -lnsl libraries.
362 # The order here is important, so that they end up in the right
363 # order in the command line generated by make. Here are some
364 # special considerations:
365 # 1. Use "connect" and "accept" to check for -lsocket, and
366 # "gethostbyname" to check for -lnsl.
367 # 2. Use each function name only once: can't redo a check because
368 # autoconf caches the results of the last check and won't redo it.
369 # 3. Use -lnsl and -lsocket only if they supply procedures that
370 # aren't already present in the normal libraries. This is because
371 # IRIX 5.2 has libraries, but they aren't needed and they're
372 # bogus: they goof up name resolution if used.
373 # 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
374 # To get around this problem, check for both libraries together
375 # if -lsocket doesn't work by itself.
376 #--------------------------------------------------------------------
378 AC_CACHE_CHECK([for socket libraries], gcj_cv_lib_sockets,
381 unset ac_cv_func_connect
382 AC_CHECK_FUNC(connect, gcj_checkSocket=0, gcj_checkSocket=1)
383 if test "$gcj_checkSocket" = 1; then
384 unset ac_cv_func_connect
385 AC_CHECK_LIB(socket, main, gcj_cv_lib_sockets="-lsocket",
388 if test "$gcj_checkBoth" = 1; then
390 LIBS="$LIBS -lsocket -lnsl"
391 unset ac_cv_func_accept
392 AC_CHECK_FUNC(accept,
394 gcj_cv_lib_sockets="-lsocket -lnsl"])
395 unset ac_cv_func_accept
398 unset ac_cv_func_gethostbyname
400 LIBS="$LIBS $gcj_cv_lib_sockets"
401 AC_CHECK_FUNC(gethostbyname, ,
402 [AC_CHECK_LIB(nsl, main,
403 [gcj_cv_lib_sockets="$gcj_cv_lib_sockets -lnsl"])])
404 unset ac_cv_func_gethostbyname
407 SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
409 if test "$with_system_zlib" = yes; then
410 AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=-lzgcj)
415 # On Solaris, and maybe other architectures, the Boehm collector
417 if test "$GC" = boehm; then
418 AC_CHECK_LIB(dl, main, SYSTEMSPEC="$SYSTEMSPEC -ldl")
421 if test -d "$libgcj_basedir/../gcc/java"; then
433 if test "x$ZLIBSPEC" = "x-lzgcj"; then
434 # We include the path to the zlib build directory.
435 # See Makefile.am to understand why.
436 ZDEPS='$(top_builddir)/../zlib/libzgcj.la'
437 ZLIBS="$ZDEPS -L\$(here)/../zlib/$libsubdir"
438 ZINCS='-I$(top_srcdir)/../zlib'
446 AM_CONDITIONAL(CANADIAN, test "$CANADIAN" = yes)
447 AM_CONDITIONAL(NULL_TARGET, test "$NULL_TARGET" = yes)
448 AM_CONDITIONAL(NATIVE, test "$CANADIAN" = no || test "$NULL_TARGET" = yes)
449 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
450 AC_SUBST(EH_COMMON_INCLUDE)
452 # Determine gcj version number.
453 if test "$GCJ" = ""; then
454 if test -z "${with_multisubdir}"; then
457 builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`
459 dir="`cd ${builddotdot}/../../gcc && pwd`"
460 GCJ="$dir/gcj -B$dir/"
463 gcjvers="`$GCJ -v 2>&1 | sed -n 's/^.*version \([^ ]*\).*$/\1/p'`"
465 AC_DEFINE_UNQUOTED(GCJVERSION, "$gcjvers")
467 AC_SUBST(AM_RUNTESTFLAGS)
469 dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
470 dnl On that system, sys/ioctl.h will not include sys/filio.h unless
471 dnl BSD_COMP is defined; just including sys/filio.h is simpler.
472 AC_CHECK_HEADERS(unistd.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)
473 dnl We avoid AC_HEADER_DIRENT since we really only care about dirent.h
474 dnl for now. If you change this, you also must update natFile.cc.
475 AC_CHECK_HEADERS(dirent.h)
477 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
478 AC_TRY_COMPILE([#include <netinet/in.h>], [struct sockaddr_in6 addr6;],
479 [AC_DEFINE(HAVE_INET6)
483 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
484 AC_TRY_COMPILE([#include <sys/socket.h>], [socklen_t x = 5;],
485 [AC_DEFINE(HAVE_SOCKLEN_T)
489 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
490 AC_TRY_COMPILE([#include <time.h>], [struct tm tim; tim.tm_gmtoff = 0;],
491 [AC_DEFINE(STRUCT_TM_HAS_GMTOFF)
494 AC_MSG_CHECKING([for global timezone variable])
495 dnl FIXME: we don't want a link check here because that won't work
496 dnl when cross-compiling. So instead we make an assumption that
497 dnl the header file will mention timezone if it exists.
498 AC_TRY_COMPILE([#include <time.h>], [long z2 = timezone;],
499 [AC_DEFINE(HAVE_TIMEZONE)
501 [AC_MSG_RESULT(no)])])
505 AC_CHECK_PROGS(PERL, perl, false)
509 SIGNAL_HANDLER=include/i386-signal.h
512 SIGNAL_HANDLER=include/sparc-signal.h
515 SIGNAL_HANDLER=include/default-signal.h
519 AC_LINK_FILES($SIGNAL_HANDLER, include/java-signal.h)
521 if test "${multilib}" = "yes"; then
522 multilib_arg="--enable-multilib"
530 AC_OUTPUT(Makefile libgcj.spec testsuite/Makefile,
531 [if test -n "$CONFIG_FILES"; then
532 ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
537 with_multisubdir=${with_multisubdir}
538 ac_configure_args="${multilib_arg} ${ac_configure_args}"
539 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
540 libgcj_basedir=${libgcj_basedir}