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
60 FILE_DESCRIPTOR=natFileDescriptorEcos.cc
65 AC_EGREP_HEADER(__uint32_t, sys/types.h, AC_DEFINE(HAVE_INT32_DEFINED))
66 AC_EGREP_HEADER(__uint32_t, sys/config.h, AC_DEFINE(HAVE_INT32_DEFINED))
68 dnl These may not be defined in a non-ANS conformant embedded system.
69 dnl FIXME: Should these case a runtime exception in that case?
70 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME))
71 AC_EGREP_HEADER(localtime, time.h, AC_DEFINE(HAVE_LOCALTIME))
73 dnl Create the subdirectory for natFileDescriptor.cc, or the attempt
74 dnl to create the link will fail.
75 test -d java || mkdir java
76 test -d java/io || mkdir java/io
77 AC_LINK_FILES(java/io/$FILE_DESCRIPTOR, java/io/natFileDescriptor.cc)
79 dnl Allow the GC to be disabled. Can be useful when debugging.
80 AC_MSG_CHECKING([for garbage collector to use])
81 AC_ARG_ENABLE(java-gc,
83 << --enable-java-gc=TYPE choose garbage collector [boehm]>>,
94 GCDEPS='$(top_builddir)/../boehm-gc/libgcjgc.la'
96 GCINCS='-I$(top_srcdir)/../boehm-gc -I$(top_builddir)/../boehm-gc'
97 dnl We also want to pick up some cpp flags required when including
98 dnl boehm-config.h. Yuck.
99 GCINCS="$GCINCS `cat ../boehm-gc/boehm-cflags`"
102 dnl The POSIX thread support needs to know this.
103 AC_DEFINE(HAVE_BOEHM_GC)
111 AC_MSG_ERROR(unrecognized collector \"$GC\")
118 AC_LINK_FILES(include/$GCHDR, include/java-gc.h)
121 dnl Note that this code is kept in sync with similar code in gcc/configure.in.
122 dnl In particular both packages must make the same decision about which
123 dnl thread package to use.
124 AC_MSG_CHECKING([for threads package to use])
125 AC_ARG_ENABLE(threads, [ --enable-threads=TYPE choose threading package],
127 dnl FIXME: figure out native threads to use here.
130 if test "$THREADS" = yes; then
136 # FIXME: this isn't correct in all cases.
146 # FIXME: for now, choose POSIX, because we implement that.
147 # Later, choose solaris threads.
165 AC_DEFINE(LINUX_THREADS)
171 decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
172 AC_MSG_ERROR(thread package $THREADS not yet supported)
175 AC_MSG_ERROR($THREADS is an unknown thread package)
178 AC_MSG_RESULT($THREADS)
188 THREADOBJS=posix-threads.lo
189 THREADH=posix-threads.h
190 # MIT pthreads doesn't seem to have the mutexattr functions.
191 # But for now we don't check for it. We just assume you aren't
192 # using MIT pthreads.
193 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
197 THREADDEPS='$(top_builddir)/../qthreads/libgcjcoop.la'
198 THREADLIBS="$THREADDEPS"
199 THREADOBJS=quick-threads.lo
200 THREADINCS='-I$(top_srcdir)/../qthreads'
201 THREADH=quick-threads.h
205 THREADOBJS=no-threads.lo
209 AC_LINK_FILES(include/$THREADH, include/java-threads.h)
215 AM_CONDITIONAL(USING_GCC, test "$GCC" = yes)
220 # Find eh-common.h and support headers. If we're in the tree with
221 # gcc, then look there. Otherwise look in compat-include. If all else
222 # fails, just hope the user has set things up somehow.
223 if test -r $srcdir/../gcc/eh-common.h; then
224 EH_COMMON_INCLUDE='-I$(top_srcdir)/../gcc -I$(top_srcdir)/../include'
226 if test -d $srcdir/../compat-include; then
227 EH_COMMON_INCLUDE='-I$(top_srcdir)/../compat-include'
233 if test -n "${with_cross_host}"; then
234 # We are being configured with a cross compiler. AC_REPLACE_FUNCS
235 # may not work correctly, because the compiler may not be able to
238 # We assume newlib. This lets us hard-code the functions we know
240 AC_DEFINE(HAVE_MEMMOVE)
241 AC_DEFINE(HAVE_MEMCPY)
242 AC_DEFINE(HAVE_STRERROR)
243 AC_DEFINE(HAVE_CTIME_R)
244 AC_DEFINE(HAVE_GMTIME_R)
245 AC_DEFINE(HAVE_LOCALTIME_R)
246 dnl This is only for POSIX threads.
247 AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_INIT)
248 dnl We also assume we are using gcc, which provides alloca.
249 AC_DEFINE(HAVE_ALLOCA)
251 # If Canadian cross, then don't pick up tools from the build
253 if test "$build" != "$with_cross_host"; then
258 # Some POSIX thread systems don't have pthread_mutexattr_settype.
260 AC_CHECK_FUNCS(strerror ioctl select open fsync sleep)
261 AC_CHECK_FUNCS(ctime_r ctime, break)
262 AC_CHECK_FUNCS(gmtime_r localtime_r readdir_r getpwuid_r)
263 AC_CHECK_FUNCS(access stat mkdir rename rmdir unlink realpath)
264 AC_CHECK_FUNCS(inet_aton inet_addr, break)
265 AC_CHECK_FUNCS(inet_pton uname)
267 AC_CHECK_FUNCS(gethostbyname_r, [
268 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
269 # There are two different kinds of gethostbyname_r.
270 # We look for the one that returns `int'.
271 # Hopefully this check is robust enough.
272 AC_EGREP_HEADER(int.*gethostbyname_r, netdb.h, [
273 AC_DEFINE(GETHOSTBYNAME_R_RETURNS_INT)])])
275 AC_CHECK_FUNCS(gethostbyaddr_r, [
276 AC_DEFINE(HAVE_GETHOSTBYADDR_R)
277 # There are two different kinds of gethostbyaddr_r.
278 # We look for the one that returns `int'.
279 # Hopefully this check is robust enough.
280 AC_EGREP_HEADER(int.*gethostbyaddr_r, netdb.h, [
281 AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT)])])
283 AC_CHECK_FUNCS(gethostname, [
284 AC_DEFINE(HAVE_GETHOSTNAME)
285 AC_EGREP_HEADER(gethostname, unistd.h, [
286 AC_DEFINE(HAVE_GETHOSTNAME_DECL)])])
288 # Look for these functions in the thread library.
290 LIBS="$LIBS $THREADLIBS"
291 AC_CHECK_FUNCS(pthread_mutexattr_settype pthread_mutexattr_setkind_np sched_yield)
294 # We require a way to get the time.
296 AC_CHECK_FUNCS(gettimeofday time ftime, time_found=yes)
297 if test "$time_found" = no; then
298 AC_MSG_ERROR([no function found to get the time])
301 # We require memmove.
303 AC_CHECK_FUNCS(memmove, memmove_found=yes)
304 if test "$memmove_found" = no; then
305 AC_MSG_ERROR([memmove is required])
310 AC_CHECK_FUNCS(memcpy, memcpy_found=yes)
311 if test "$memcpy_found" = no; then
312 AC_MSG_ERROR([memcpy is required])
315 test -d "$libgcj_basedir/../gcc/java" || {
321 AM_CONDITIONAL(CANADIAN, test "$CANADIAN" = yes)
322 AM_CONDITIONAL(NULL_TARGET, test "$NULL_TARGET" = yes)
323 AM_CONDITIONAL(NATIVE, test "$CANADIAN" = no || test "$NULL_TARGET" = yes)
325 AC_SUBST(EH_COMMON_INCLUDE)
327 AC_SUBST(AM_RUNTESTFLAGS)
329 dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
330 dnl On that system, sys/ioctl.h will not include sys/filio.h unless
331 dnl BSD_COMP is defined; just including sys/filio.h is simpler.
332 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)
333 dnl We avoid AC_HEADER_DIRENT since we really only care about dirent.h
334 dnl for now. If you change this, you also must update natFile.cc.
335 AC_CHECK_HEADERS(dirent.h)
337 AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
338 AC_TRY_COMPILE([#include <netinet/in.h>], [struct sockaddr_in6 addr6;],
339 [AC_DEFINE(HAVE_INET6)
343 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
344 AC_TRY_COMPILE([#include <sys/socket.h>], [socklen_t x = 5;],
345 [AC_DEFINE(HAVE_SOCKLEN_T)
349 AC_MSG_CHECKING([for tm_gmtoff in struct tm])
350 AC_TRY_COMPILE([#include <time.h>], [struct tm tim; tim.tm_gmtoff = 0;],
351 [AC_DEFINE(STRUCT_TM_HAS_GMTOFF)
354 AC_MSG_CHECKING([for global timezone variable])
355 dnl FIXME: we don't want a link check here because that won't work
356 dnl when cross-compiling. So instead we make an assumption that
357 dnl the header file will mention timezone if it exists.
358 AC_TRY_COMPILE([#include <time.h>], [long z2 = timezone;],
359 [AC_DEFINE(HAVE_TIMEZONE)
361 [AC_MSG_RESULT(no)])])
365 AC_CHECK_PROGS(PERL, perl, false)
369 SIGNAL_HANDLER=include/i386-signal.h
372 SIGNAL_HANDLER=include/sparc-signal.h
375 SIGNAL_HANDLER=include/default-signal.h
379 AC_LINK_FILES($SIGNAL_HANDLER, include/java-signal.h)
381 if test "${multilib}" = "yes"; then
382 multilib_arg="--enable-multilib"
390 AC_OUTPUT(Makefile testsuite/Makefile,
391 [if test -n "$CONFIG_FILES"; then
392 ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
397 with_multisubdir=${with_multisubdir}
398 ac_configure_args="${multilib_arg} ${ac_configure_args}"
399 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
400 libgcj_basedir=${libgcj_basedir}