* configure.ac: Support mipsel architectures.
[cacao.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT(cacao, 0.97+svn, cacao@cacaojvm.org)
4 AC_CONFIG_SRCDIR(src/cacao/cacao.c)
5 AC_CANONICAL_HOST
6 AC_PREREQ(2.59)
7 AM_INIT_AUTOMAKE([1.9.0])
8 AM_MAINTAINER_MODE
9
10 AM_CONFIG_HEADER([config.h])
11
12 AC_PREFIX_DEFAULT(/usr/local/cacao)
13
14
15 dnl set optimization and debugging for all architectures and systems
16 if test x"$CFLAGS" = "x"; then
17     OPT_CFLAGS="-O0 -g3"
18 else
19     OPT_CFLAGS=$CFLAGS
20 fi
21
22 dnl system type
23 case "$host_cpu" in
24 alpha | alphaev56 | alphapca56 )
25     ARCH_DIR="alpha"
26     ARCH_CFLAGS="-mieee -D__ALPHA__"
27     ;;
28
29 arm | armv4tl | armv5b | armv5l )
30     ARCH_DIR="arm"
31     ARCH_CFLAGS="-D__ARM__"
32     ;;
33
34 hppa2.0 )
35     ARCH_DIR="parisc"
36     ARCH_CFLAGS="-D__PARISC__"
37     ;;
38
39 i386 | i486 | i586 | i686 )
40     ARCH_DIR="i386"
41     ARCH_CFLAGS="-D__I386__"
42     ;;
43
44 mips | mipsel )
45     ARCH_DIR="mips"
46     ARCH_CFLAGS="-D__MIPS__"
47     ;;
48
49 powerpc )
50     ARCH_DIR="powerpc"
51     ARCH_CFLAGS="-D__POWERPC__"
52     ;;
53
54 powerpc64 )
55     ARCH_DIR="powerpc64"
56     ARCH_CFLAGS="-D__POWERPC64__"
57     ;;
58
59 sparc64 )
60     ARCH_DIR="sparc64"
61     ARCH_CFLAGS="-mcpu=v9 -m64 -D__SPARC_64__"
62     ;;
63
64 x86_64 )
65     ARCH_DIR="x86_64"
66     ARCH_CFLAGS="-D__X86_64__"
67     ;;
68
69 xdspcore )
70     ARCH_DIR="xdspcore"
71     ENABLE_STATICVM="yes"
72     ARCH_CFLAGS="-D__XDSPCORE__"
73     USE_SCHEDULER="1"
74     ;;
75
76 * )
77     AC_MSG_ERROR($host_cpu systems are not supported at this time)
78     ;;
79 esac
80
81 dnl host type
82 case "$host_os" in
83 *cygwin* )
84     OS_DIR="cygwin"
85     INTRP_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -Wall -Wno-long-long"
86     ARCH_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -ansi -pedantic -Wall -Wno-long-long"
87     ;;
88
89 *darwin* )
90     OS_DIR="darwin"
91     INTRP_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -Wall -Wno-long-long"
92     ARCH_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -ansi -pedantic -Wall -Wno-long-long"
93     ;;
94
95 *freebsd* )
96     OS_DIR="freebsd"
97     INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
98     ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
99     ;;
100
101 *irix* )
102     OS_DIR="irix"
103     INTRP_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
104     ARCH_CFLAGS="$ARCH_CFLAGS -D__IRIX__"
105     ;;
106
107 *linux* | *Linux* )
108     OS_DIR="linux"
109     INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
110     ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
111     ;;
112
113 *netbsd* )
114     OS_DIR="netbsd"
115     INTRP_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
116     ARCH_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
117     ;;
118
119 * )
120     ;;
121 esac
122
123
124 dnl temporary set the CFLAGS for configure tests (e.g. inline keyword)
125 dnl we set it properly at the end of this file
126 CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
127
128 dnl set interpreter flags
129 AC_SUBST(INTRP_CFLAGS)
130
131 dnl define some stuff required for --fullversion
132 AC_DEFINE_UNQUOTED(VERSION_CONFIGURE_ARGS, "$ac_configure_args", [configure arguments])
133 AC_DEFINE_UNQUOTED(VERSION_CC, "$CC", [CC used])
134 AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS", [CFLAGS used])
135
136
137 dnl define and substitute some architecture specific variables
138 AC_DEFINE_UNQUOTED([ARCH_DIR], "${ARCH_DIR}", [architecture directory])
139 AC_SUBST(ARCH_DIR)
140 AC_SUBST(OS_DIR)
141 AC_SUBST(USE_SCHEDULER)
142
143
144 dnl Checks for programs.
145 AC_PROG_CC
146 AM_PROG_AS
147 AC_PROG_LD
148 AC_PROG_LD_GNU
149 AC_PROG_RANLIB
150 AC_PROG_LN_S
151 AC_PROG_MAKE_SET
152 AM_PROG_MKDIR_P
153
154 dnl Checks for header files.
155 AC_HEADER_DIRENT
156 AC_HEADER_STDC
157 AC_CHECK_HEADERS([fcntl.h])
158 AC_CHECK_HEADERS([sys/time.h])
159 AC_CHECK_HEADERS([unistd.h])
160 AC_CHECK_HEADERS([sys/ioctl.h])
161
162 dnl this is for fdlibm
163 AC_CHECK_HEADERS([stdint.h])
164 AC_CHECK_HEADERS([inttypes.h])
165 AC_CHECK_HEADERS([sys/config.h])
166 AC_CHECK_HEADERS([sys/types.h])
167 AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
168 AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
169 AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
170 AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t]))
171
172 dnl Checks for typedefs, structures, and compiler characteristics.
173 AC_C_CONST
174 AC_C_INLINE
175 AC_C_ATTRIBUTE
176 AC_TYPE_OFF_T
177 AC_TYPE_SIZE_T
178 AC_HEADER_TIME
179 AC_STRUCT_TM
180
181 dnl Checks for library functions.
182 AC_PROG_GCC_TRADITIONAL
183 AC_TYPE_SIGNAL
184 AC_FUNC_MEMCMP
185 AC_FUNC_MMAP
186 AC_CHECK_FUNCS([calloc mmap getpagesize free])
187 AC_CHECK_FUNCS([getcwd gettimeofday])
188 AC_CHECK_FUNCS([scandir])
189 AC_CHECK_FUNCS([isnan])
190
191 dnl Checks for libraries.
192
193 dnl Checking sizeof void *
194 AC_CHECK_SIZEOF(void *)
195 AC_C_BIGENDIAN
196
197
198 dnl define install prefix
199 if test "x$prefix" = "xNONE"; then
200     CACAO_PREFIX=$ac_default_prefix
201 else
202     CACAO_PREFIX=$prefix
203 fi
204 AC_DEFINE_UNQUOTED([CACAO_PREFIX], "${CACAO_PREFIX}", [installation prefix])
205 AC_SUBST(CACAO_PREFIX)
206
207 dnl define libdir prefix
208 if test "x$libdir" = "xNONE"; then
209     CACAO_LIBDIR=$ac_default_libdir
210 else
211     CACAO_LIBDIR=$libdir
212 fi
213 dnl expand CACAO_LIBDIR to something that is usable in C code
214 AS_AC_EXPAND([CACAO_LIBDIR], ${CACAO_LIBDIR})
215 AC_DEFINE_UNQUOTED([CACAO_LIBDIR], "${CACAO_LIBDIR}", [library installation prefix])
216 AC_SUBST(CACAO_LIBDIR)
217
218
219 dnl Features
220
221 dnl check arguments
222
223 dnl check for JIT compiler
224 AC_MSG_CHECKING(whether JIT compiler should be compiled)
225 AC_ARG_ENABLE([jit],
226               [AS_HELP_STRING(--disable-jit,disable JIT compiler [[default=yes]])],
227               [case "${enableval}" in
228                    no) ENABLE_JIT=no;;
229                    *) ENABLE_JIT=yes;;
230                esac],
231               [ENABLE_JIT=yes])
232 AC_MSG_RESULT(${ENABLE_JIT})
233 AM_CONDITIONAL([ENABLE_JIT], test x"${ENABLE_JIT}" = "xyes")
234
235 if test x"${ENABLE_JIT}" = "xyes"; then
236     AC_DEFINE([ENABLE_JIT], 1, [enable JIT compiler])
237 fi
238
239
240 dnl check if softfloat should be used
241 AC_MSG_CHECKING(whether softfloat should be used)
242 AC_ARG_ENABLE([softfloat],
243               [AS_HELP_STRING(--enable-softfloat,use softfloat [[default=no]])],
244               [case "${enableval}" in
245                   yes) ENABLE_SOFTFLOAT=yes;;
246                   *) ENABLE_SOFTFLOAT=no;;
247                esac],
248               [ENABLE_SOFTFLOAT=no])
249 AC_MSG_RESULT(${ENABLE_SOFTFLOAT})
250
251 if test x"${ENABLE_SOFTFLOAT}" = "xyes"; then
252     AC_DEFINE([ENABLE_SOFTFLOAT], 1, [enable softfloat])
253 fi
254
255
256 dnl check for interpreter
257 AC_ARG_ENABLE([intrp], [AS_HELP_STRING(--enable-intrp,enable interpreter [[default=no]])])
258
259 AC_MSG_CHECKING(whether interpreter should be compiled)
260 if test x"$enable_intrp" = "xyes"; then
261     AC_MSG_RESULT(yes)
262     AC_DEFINE([ENABLE_INTRP], 1, [enable interpreter])
263     AM_CONDITIONAL([ENABLE_INTRP], [true])
264     ENABLE_INTRP=yes
265
266     AC_ASM_SKIP16
267
268     dnl check for libffi
269     AC_ARG_WITH([ffi],
270                 [AS_HELP_STRING(--with-ffi,use libffi to call native functions)],
271                 [WITH_FFI=yes
272                  AC_CHECK_HEADERS([ffi.h],, [AC_MSG_ERROR(cannot find ffi.h)])
273                  AC_CHECK_LIB(ffi, ffi_call,, [AC_MSG_ERROR(cannot find libffi)])
274                  AC_DEFINE([WITH_FFI], 1, [use libffi])],
275                 [WITH_FFI=no])
276
277     dnl check for libffcall
278     AC_ARG_WITH([ffcall],
279                 [AS_HELP_STRING(--with-ffcall,use libffcall to call native functions)],
280                 [WITH_FFCALL=yes
281                  AC_CHECK_HEADERS([avcall.h],, [AC_MSG_ERROR(cannot find avcall.h)])
282                  AC_CHECK_LIB(avcall, __builtin_avcall,, [AC_MSG_ERROR(cannot find libavcall (from libffcall))])
283                  AC_DEFINE([WITH_FFCALL], 1, [use libffcall])],
284                 [WITH_FFCALL=no])
285
286     dnl check for libffi or libffcall
287     if test x"${WITH_FFI}" = "xyes" -a x"${WITH_FFCALL}" = "xyes"; then
288         AC_ERROR(Enable only libffi or libffcall.)
289     fi
290     if test x"${WITH_FFI}" = "xno" -a x"${WITH_FFCALL}" = "xno"; then
291         AC_ERROR(Enable one of libffi or libffcall.)
292     fi
293
294 else
295     AC_MSG_RESULT(no)
296     AM_CONDITIONAL([ENABLE_INTRP], [false])
297     ENABLE_INTRP="no"
298 fi
299
300 if test x"${ENABLE_JIT}" = "xno" -a x"${ENABLE_INTRP}" = "xno"; then
301     AC_ERROR(You have to enable at least the JIT or the interpreter.)
302 fi
303
304
305 dnl check for garbage collector usage
306 AC_ARG_ENABLE([gc], [AS_HELP_STRING(--enable-gc,enable garbage collector support (none,boehm,cacao) [[default=boehm]])])
307 AC_MSG_CHECKING(whether GC should be enabled)
308 enable_gc=${enable_gc:-boehm}
309 case "$enable_gc" in
310 no | none)
311     AC_DEFINE([DISABLE_GC], 1, [disable garbage collector])
312     ENABLE_GC=none
313     AC_MSG_RESULT(no)
314     ;;
315
316 boehm)
317     AC_DEFINE([ENABLE_GC_BOEHM], 1, [enable conservative boehm-gc])
318     ENABLE_GC=boehm
319     AC_MSG_RESULT(yes, boehm-gc)
320     ;;
321
322 cacao)
323     AC_DEFINE([ENABLE_GC_CACAO], 1, [enable exact cacao-gc])
324     ENABLE_GC=cacao
325     AC_MSG_RESULT(yes, cacao-gc)
326     ;;
327
328 *)
329     AC_MSG_ERROR($enable_gc is an unknown garbage collector package)
330     ;;
331 esac
332 AM_CONDITIONAL([DISABLE_GC], test x"${ENABLE_GC}" = "xnone")
333 AM_CONDITIONAL([ENABLE_GC_BOEHM], test x"${ENABLE_GC}" = "xboehm")
334 AM_CONDITIONAL([ENABLE_GC_CACAO], test x"${ENABLE_GC}" = "xcacao")
335
336
337 dnl check for dump memory usage
338 AC_MSG_CHECKING(whether dump memory should be disabled)
339 AC_ARG_ENABLE([dump],
340               [AS_HELP_STRING(--disable-dump,disable dump memory (for debugging only!) [[default=yes]])],
341               [case "${enableval}" in
342                    no)
343                        DISABLE_DUMP=yes
344                        AC_DEFINE([DISABLE_DUMP], 1, [disable dump memory])
345                        ;;
346                    *) DISABLE_DUMP=no;;
347                esac],
348                [DISABLE_DUMP=no])
349 AC_MSG_RESULT(${DISABLE_DUMP})
350
351
352 dnl check for debug
353 AC_MSG_CHECKING(whether debug code generation should be enabled)
354 AC_ARG_ENABLE([debug],
355               [AS_HELP_STRING(--disable-debug,disable debug code generation [[default=yes]])],
356               [case "${enableval}" in
357                    no) NDEBUG=yes
358                        AC_DEFINE([NDEBUG], 1, [disable debug code])
359                        ;;
360                    *) NDEBUG=no;;
361                esac],
362               [NDEBUG=no])
363
364 if test x"${NDEBUG}" = "xno"; then
365     AC_MSG_RESULT(yes)
366 else
367     AC_MSG_RESULT(no)
368 fi
369 AM_CONDITIONAL([NDEBUG], test x"${NDEBUG}" = "xyes")
370
371
372 dnl check for memcheck support
373 AC_MSG_CHECKING(whether debugging memory checks should be enabled)
374 AC_ARG_ENABLE([memcheck],
375               [AS_HELP_STRING(--enable-memcheck,enable debugging memory checks [[default=no]])],
376               [case "${enableval}" in
377                    yes) ENABLE_MEMCHECK=yes;;
378                    *) ENABLE_MEMCHECK=no;;
379                esac],
380               [ENABLE_MEMCHECK=no])
381 AC_MSG_RESULT(${ENABLE_MEMCHECK})
382 AM_CONDITIONAL([ENABLE_MEMCHECK], test x"${ENABLE_MEMCHECK}" = "xyes")
383
384 if test x"${ENABLE_MEMCHECK}" = "xyes"; then
385     AC_DEFINE([ENABLE_MEMCHECK], 1, [perform debugging memory checks])
386 fi
387
388
389 dnl check for disassembler support
390 AC_MSG_CHECKING(whether disassembler should be enabled)
391 AC_ARG_ENABLE([disassembler],
392               [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])],
393               [case "${enableval}" in
394                    yes) ENABLE_DISASSEMBLER=yes;;
395                    *) ENABLE_DISASSEMBLER=no;;
396                esac],
397               [ENABLE_DISASSEMBLER=no])
398 AC_MSG_RESULT(${ENABLE_DISASSEMBLER})
399 AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes")
400
401 if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then
402     AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler])
403
404     dnl check for binutils headers and libraries on some architectures for the
405     dnl disassembler
406     case "${ARCH_DIR}" in
407         arm | i386 | powerpc | x86_64 | sparc64 | powerpc64)
408             AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)])
409             AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)])
410             AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)])
411             AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)])
412
413             case "${OS_DIR}" in
414                 cygwin | darwin | netbsd )
415                      AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))])
416                      ;;
417             esac
418
419             AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))])
420             AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))])
421             AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))])
422             AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler])
423             AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true])
424             ;;
425         * )
426             AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
427             ;;
428     esac
429 else
430     AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
431 fi
432
433
434 dnl check for statistics
435 AC_MSG_CHECKING(whether statistics generation should be enabled)
436 AC_ARG_ENABLE([statistics],
437               [AS_HELP_STRING(--enable-statistics,enable statistics generation [[default=no]])],
438               [case "${enableval}" in
439                    yes) ENABLE_STATISTICS=yes;;
440                    *) ENABLE_STATISTICS=no;;
441                esac],
442               [ENABLE_STATISTICS=no])
443 AC_MSG_RESULT(${ENABLE_STATISTICS})
444 AM_CONDITIONAL([ENABLE_STATISTICS], test x"${ENABLE_STATISTICS}" = "xyes")
445
446 if test x"${ENABLE_STATISTICS}" = "xyes"; then
447     AC_DEFINE([ENABLE_STATISTICS], 1, [enable statistics])
448 fi
449
450
451 dnl check for verifier
452 AC_MSG_CHECKING(whether classfile verification should be enabled)
453 AC_ARG_ENABLE([verifier],
454               [AS_HELP_STRING(--disable-verifier,disable classfile verification [[default=yes]])],
455               [case "${enableval}" in
456                    no) ENABLE_VERIFIER=no;;
457                    *) ENABLE_VERIFIER=yes;;
458                esac],
459               [ENABLE_VERIFIER=yes])
460 AC_MSG_RESULT(${ENABLE_VERIFIER})
461 AM_CONDITIONAL([ENABLE_VERIFIER], test x"${ENABLE_VERIFIER}" = "xyes")
462
463 if test x"${ENABLE_VERIFIER}" = "xyes"; then
464     AC_DEFINE([ENABLE_VERIFIER], 1, [enable classfile verification])
465 fi
466
467
468 dnl check for compiler timing
469 AC_MSG_CHECKING(whether real-time timing should be enabled)
470 AC_ARG_ENABLE([rt-timing],
471               [AS_HELP_STRING(--enable-rt-timing,enable real-time timing [[default=no]])],
472               [case "${enableval}" in
473                    yes) ENABLE_RT_TIMING=yes;;
474                    *) ENABLE_RT_TIMING=no;;
475                esac],
476               [ENABLE_RT_TIMING=no])
477 AC_MSG_RESULT(${ENABLE_RT_TIMING})
478 AM_CONDITIONAL([ENABLE_RT_TIMING], test x"${ENABLE_RT_TIMING}" = "xyes")
479
480 if test x"${ENABLE_RT_TIMING}" = "xyes"; then
481     AC_DEFINE([ENABLE_RT_TIMING], 1, [enable real-time timing])
482 fi
483
484
485 dnl check for cycle count statistics
486 AC_MSG_CHECKING(whether cycle count statistics should be enabled)
487 AC_ARG_ENABLE([cycles-stats],
488               [AS_HELP_STRING(--enable-cycles-stats,enable cycle count statistics [[default=no]])],
489               [case "${enableval}" in
490                    yes) ENABLE_CYCLES_STATS=yes;;
491                    *) ENABLE_CYCLES_STATS=no;;
492                esac],
493               [ENABLE_CYCLES_STATS=no])
494 AC_MSG_RESULT(${ENABLE_CYCLES_STATS})
495 AM_CONDITIONAL([ENABLE_CYCLES_STATS], test x"${ENABLE_CYCLES_STATS}" = "xyes")
496
497 if test x"${ENABLE_CYCLES_STATS}" = "xyes"; then
498     AC_DEFINE([ENABLE_CYCLES_STATS], 1, [enable cycle count statistics])
499 fi
500
501
502 dnl check for JVMTI
503 AC_MSG_CHECKING(whether to compile JVMTI support)
504 AC_ARG_ENABLE([jvmti],
505               [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])],
506               [case "${enableval}" in
507                    yes) ENABLE_JVMTI=yes;;
508                    *) ENABLE_JVMTI=no;;
509                esac],
510               [ENABLE_JVMTI=no])
511 AC_MSG_RESULT(${ENABLE_JVMTI})
512 AM_CONDITIONAL([ENABLE_JVMTI], test x"${ENABLE_JVMTI}" = "xyes")
513
514 if test x"${ENABLE_JVMTI}" = "xyes"; then
515     AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI])
516 fi
517
518
519 dnl threads
520 AC_ARG_ENABLE([threads], [AS_HELP_STRING(--enable-threads,enable threads support (none,native) [[default=native]])])
521 AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
522
523 AC_MSG_CHECKING(whether to include threads support)
524 enable_threads=${enable_threads:-native}
525 case "$enable_threads" in
526 no | none | single)
527     AC_MSG_RESULT(no)
528     dnl no threads for boehm
529     ac_configure_args="$ac_configure_args --disable-boehm-threads"
530     AM_CONDITIONAL([ENABLE_THREADS], [false])
531     ;;
532
533 native | posix | pthreads)
534     AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
535     
536     AM_CONDITIONAL([ENABLE_THREADS], [true])
537     
538     AC_MSG_RESULT(yes, native)
539     AC_CHECK_LIB(pthread, main)
540
541     ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
542
543     dnl we changed ARCH_CFLAGS, set CFLAGS again
544     CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
545
546     dnl tell boehm to support threads as well
547     ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
548     ;;
549
550 *)
551     AC_MSG_ERROR($enable_threads is an unknown thread package)
552     ;;
553 esac
554
555
556 dnl Check whether the compiler supports the __thread keyword.
557 if test "x$use__thread" != xno; then
558   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
559   [cat > conftest.c <<\EOF
560 __thread int a = 42;
561 EOF
562   if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
563     ac_cv_gcc___thread=yes 
564   else
565     ac_cv_gcc___thread=no
566   fi
567   rm -f conftest*])
568   if test "$ac_cv_gcc___thread" = yes; then
569     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
570   fi
571 else
572   ac_cv_gcc___thread=no
573 fi
574
575
576 dnl check if if-conversion should be supported
577 AC_MSG_CHECKING(whether if-conversion should be supported)
578 AC_ARG_ENABLE([ifconv],
579               [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=yes]])],
580               [case "${enableval}" in
581                    no) ENABLE_IFCONV=no;;
582                    *) ENABLE_IFCONV=yes;;
583                esac],
584               [ENABLE_IFCONV=yes])
585 AC_MSG_RESULT(${ENABLE_IFCONV})
586 AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes")
587    
588 if test x"${ENABLE_IFCONV}" = "xyes"; then
589     AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion])
590 fi
591
592
593 dnl check for inlining
594 AC_MSG_CHECKING(whether method inlining should be supported)
595 AC_ARG_ENABLE([inlining],
596               [AS_HELP_STRING(--enable-inlining,enable method inlining [[default=no]])],
597               [case "${enableval}" in
598                    yes) ENABLE_INLINING=yes;;
599                    *) ENABLE_INLINING=no;;
600                esac],
601               [ENABLE_INLINING=no])
602 AC_MSG_RESULT(${ENABLE_INLINING})
603 AM_CONDITIONAL([ENABLE_INLINING], test x"${ENABLE_INLINING}" = "xyes")
604
605 if test x"${ENABLE_INLINING}" = "xyes"; then
606     AC_DEFINE([ENABLE_INLINING], 1, [use method inlining])
607 fi
608
609
610 dnl check for loop optimization
611 AC_MSG_CHECKING(whether loop optimization should be supported)
612 AC_ARG_ENABLE([loop],
613               [AS_HELP_STRING(--enable-loop,enable loop optimization [[default=no]])],
614               [case "${enableval}" in
615                    yes) ENABLE_LOOP=yes;;
616                    *) ENABLE_LOOP=no;;
617                esac],
618               [ENABLE_LOOP=no])
619 AC_MSG_RESULT(${ENABLE_LOOP})
620 AM_CONDITIONAL([ENABLE_LOOP], test x"${ENABLE_LOOP}" = "xyes")
621
622 if test x"${ENABLE_LOOP}" = "xyes"; then
623     AC_DEFINE([ENABLE_LOOP], 1, [use loop optimization])
624 fi
625
626
627 dnl check if linear scan register allocator(lsra) with SSA should be used
628 AC_MSG_CHECKING(whether lsra with ssa should be supported)
629 AC_ARG_ENABLE([ssa],
630               [AS_HELP_STRING(--disable-ssa,disable ssa [[default=no]])],
631               [case "${enableval}" in
632                    no) ENABLE_SSA=no;;
633                    *) ENABLE_SSA=yes;;
634                esac],
635               [ENABLE_SSA=no])
636 AC_MSG_RESULT(${ENABLE_SSA})
637 AM_CONDITIONAL([ENABLE_SSA], test x"${ENABLE_SSA}" = "xyes")
638
639 if test x"${ENABLE_SSA}" = "xyes"; then
640     AC_DEFINE([ENABLE_SSA], 1, [enable lsra with ssa])
641     ENABLE_LSRA="no"
642 fi
643
644
645 dnl check if linear scan register allocator(lsra) should be used
646 AC_MSG_CHECKING(whether lsra should be supported)
647 AC_ARG_ENABLE([lsra],
648               [AS_HELP_STRING(--enable-lsra,enable linear scan register allocator [[default=no]])],
649               [case "${enableval}" in
650                    yes) ENABLE_LSRA=yes;;
651                    *) ENABLE_LSRA=no;;
652                esac],
653               [ENABLE_LSRA=no])
654    
655 if test x"${ENABLE_LSRA}" = "xyes"; then
656     if test x"${ENABLE_SSA}" = "xyes"; then
657         ENABLE_LSRA="no"
658     fi
659 fi
660 AC_MSG_RESULT(${ENABLE_LSRA})
661 AM_CONDITIONAL([ENABLE_LSRA], test x"${ENABLE_LSRA}" = "xyes")
662  
663 if test x"${ENABLE_LSRA}" = "xyes"; then
664     AC_DEFINE([ENABLE_LSRA], 1, [enable lsra])
665 fi
666
667
668 dnl check if profiling should be supported
669 AC_MSG_CHECKING(whether profiling should be supported)
670 AC_ARG_ENABLE([profiling],
671               [AS_HELP_STRING(--enable-profiling,enable profiling [[default=no]])],
672               [case "${enableval}" in
673                    yes) ENABLE_PROFILING=yes;;
674                    *) ENABLE_PROFILING=no;;
675                esac],
676               [ENABLE_PROFILING=no])
677 AC_MSG_RESULT(${ENABLE_PROFILING})
678 AM_CONDITIONAL([ENABLE_PROFILING], test x"${ENABLE_PROFILING}" = "xyes")
679    
680 if test x"${ENABLE_PROFILING}" = "xyes"; then
681     AC_DEFINE([ENABLE_PROFILING], 1, [enable profiling])
682 fi
683
684
685 dnl check for instruction scheduler
686 AC_ARG_ENABLE([scheduler], [AS_HELP_STRING(--enable-scheduler,enable instruction scheduler [[default=no]])])
687
688 AC_MSG_CHECKING(whether instruction scheduler should be supported)
689 if test x"${USE_SCHEDULER}" = "x1" -o x"$enable_scheduler" = "xyes"; then
690         case "${ARCH_DIR}" in
691                 xdspcore )
692                         ;;
693                 * )
694                         AC_MSG_ERROR(instruction scheduler is not available for ${ARCH_DIR} code generator)
695                         ;;
696         esac
697
698         AC_MSG_RESULT(yes)
699         AC_DEFINE([USE_SCHEDULER], 1, [use scheduler])
700         AM_CONDITIONAL([USE_SCHEDULER], [true])
701 else
702         AC_MSG_RESULT(no)
703         AM_CONDITIONAL([USE_SCHEDULER], [false])
704 fi
705
706
707 dnl check if zlib should be used
708 AC_MSG_CHECKING(whether ZIP/JAR archives should be supported)
709 AC_ARG_ENABLE([zlib],
710               [AS_HELP_STRING(--disable-zlib,disable ZIP/JAR archive support (needs zlib) [[default=yes]])],
711               [case "${enableval}" in
712                   no) ENABLE_ZLIB=no;;
713                   *) ENABLE_ZLIB=yes;;
714                esac],
715               [ENABLE_ZLIB=yes])
716 AC_MSG_RESULT(${ENABLE_ZLIB})
717
718 if test x"${ENABLE_ZLIB}" = "xyes"; then
719     AC_CHECK_HEADERS([zconf.h],, [AC_MSG_ERROR(cannot find zconf.h)])
720     AC_CHECK_HEADERS([zlib.h],, [AC_MSG_ERROR(cannot find zlib.h)])
721     AC_CHECK_LIB(z, inflate,, [AC_MSG_ERROR(cannot find libz)])
722     AC_DEFINE([ENABLE_ZLIB], 1, [use zlib])
723 fi
724 AM_CONDITIONAL([ENABLE_ZLIB], test x"${ENABLE_ZLIB}" = "xyes")
725
726
727 dnl check if a libjvm.so should be built
728 AC_MSG_CHECKING(whether to build a libjvm.so)
729 AC_ARG_ENABLE([libjvm],
730               [AS_HELP_STRING(--disable-libjvm,build a libjvm.so [[default=yes]])],
731               [case "${enableval}" in
732                   no) ENABLE_LIBJVM=no;;
733                   *) ENABLE_LIBJVM=yes;;
734                esac],
735               [ENABLE_LIBJVM=yes])
736 AC_MSG_RESULT(${ENABLE_LIBJVM})
737 AM_CONDITIONAL([ENABLE_LIBJVM], test x"${ENABLE_LIBJVM}" = "xyes")
738 AC_SUBST(ENABLE_LIBJVM)
739
740 if test x"${ENABLE_LIBJVM}" = "xyes"; then
741     AC_DEFINE([ENABLE_LIBJVM], 1, [enable libjvm.so])
742
743     dnl set AC_ENABLE_SHARED and AC_DISABLE_STATIC properly
744     enable_shared=yes
745     enable_static=no
746 else
747     enable_shared=no
748     enable_static=yes
749 fi
750
751 dnl libtool stuff
752 AC_LIBTOOL_DLOPEN
753 AC_PROG_LIBTOOL
754
755
756 dnl check if CACAO should be linked statically
757 AC_MSG_CHECKING(whether to link CACAO statically)
758 AC_ARG_ENABLE([staticvm],
759               [AS_HELP_STRING(--enable-staticvm,link CACAO statically [[default=no]])],
760               [case "${enableval}" in
761                   yes) ENABLE_STATICVM=yes
762                        AC_DEFINE([ENABLE_STATICVM], 1, [link CACAO statically])
763                        ;;
764                   *) ENABLE_STATICVM=no;;
765                esac],
766               [ENABLE_STATICVM=no])
767 AC_MSG_RESULT(${ENABLE_STATICVM})
768 AM_CONDITIONAL([ENABLE_STATICVM], test x"${ENABLE_STATICVM}" = "xyes")
769 AC_SUBST(ENABLE_STATICVM)
770
771
772 dnl where is CACAO's vm.zip
773 AC_MSG_CHECKING(where CACAO's vm.zip is installed)
774 AC_ARG_WITH([vm-zip],
775             [AS_HELP_STRING(--with-vm-zip,path to CACAO's vm.zip (includes the name of the file and may be flat) [[default=/usr/local/cacao/share/cacao/vm.zip]])],
776             [CACAO_VM_ZIP=${withval}],
777             [CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/vm.zip])
778 AC_MSG_RESULT(${CACAO_VM_ZIP})
779 AC_DEFINE_UNQUOTED([CACAO_VM_ZIP], "${CACAO_VM_ZIP}", [CACAO's vm.zip])
780 AC_SUBST(CACAO_VM_ZIP)
781
782
783 dnl is GNU classpath installed somewhere different
784 AC_MSG_CHECKING(where GNU Classpath is installed)
785 AC_ARG_WITH([classpath-prefix],
786             [AS_HELP_STRING(--with-classpath-prefix=<dir>,installation directory of GNU Classpath [[default=/usr/local/classpath]])],
787             [CLASSPATH_PREFIX=${withval}],
788             [CLASSPATH_PREFIX=/usr/local/classpath])
789 AC_MSG_RESULT(${CLASSPATH_PREFIX})
790 AC_DEFINE_UNQUOTED([CLASSPATH_PREFIX], "${CLASSPATH_PREFIX}", [GNU Classpath installation directory])
791 AC_SUBST(CLASSPATH_PREFIX)
792
793
794 dnl where is GNU Classpath's glibj.zip
795 AC_MSG_CHECKING(where GNU Classpath's glibj.zip is installed)
796 AC_ARG_WITH([classpath-glibj-zip],
797             [AS_HELP_STRING(--with-classpath-glibj-zip,path to GNU Classpath's glibj.zip (includes the name of the file and may be flat) [[default=/usr/local/classpath/share/classpath/glibj.zip]])],
798             [CLASSPATH_GLIBJ_ZIP=${withval}],
799             [CLASSPATH_GLIBJ_ZIP=${CLASSPATH_PREFIX}/share/classpath/glibj.zip])
800 AC_MSG_RESULT(${CLASSPATH_GLIBJ_ZIP})
801 AC_DEFINE_UNQUOTED([CLASSPATH_GLIBJ_ZIP], "${CLASSPATH_GLIBJ_ZIP}", [GNU Classpath's glibj.zip])
802 AC_SUBST(CLASSPATH_GLIBJ_ZIP)
803
804
805 dnl where are the GNU Classpath libraries installed
806 AC_MSG_CHECKING(where GNU Classpath libraries are installed)
807 AC_ARG_WITH([classpath-libdir],
808             [AS_HELP_STRING(--with-classpath-libdir=<dir>,installation directory of GNU Classpath libraries [[default=/usr/local/classpath/lib]])],
809             [CLASSPATH_LIBDIR=${withval}],
810             [CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/lib])
811 AC_MSG_RESULT(${CLASSPATH_LIBDIR})
812
813 dnl expand CLASSPATH_LIBDIR to something that is usable in C code
814 AS_AC_EXPAND([CLASSPATH_LIBDIR], ${CLASSPATH_LIBDIR})
815 AC_DEFINE_UNQUOTED([CLASSPATH_LIBDIR], "${CLASSPATH_LIBDIR}", [GNU Classpath libraries installation directory])
816 AC_SUBST(CLASSPATH_LIBDIR)
817
818
819 dnl where are the GNU Classpath headers installed
820 AC_MSG_CHECKING(where GNU Classpath headers are installed)
821 AC_ARG_WITH([classpath-includedir],
822             [AS_HELP_STRING(--with-classpath-includedir=<dir>,installation directory of GNU Classpath headers [[default=/usr/local/classpath/include]])],
823             [CLASSPATH_INCLUDEDIR=${withval}],
824             [CLASSPATH_INCLUDEDIR=${CLASSPATH_PREFIX}/include])
825 AC_MSG_RESULT(${CLASSPATH_INCLUDEDIR})
826
827 AC_CHECK_HEADER([${CLASSPATH_INCLUDEDIR}/jni.h],
828                 [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_H], "${CLASSPATH_INCLUDEDIR}/jni.h", [GNU Classpath jni.h header])],
829                 [AC_MSG_ERROR(cannot find jni.h)])
830
831
832 dnl if we compile for a JRE-style directory layout
833 AC_MSG_CHECKING(if we compile for a JRE-style directory layout)
834 AC_ARG_WITH([jre-layout],
835             [AS_HELP_STRING(--with-jre-layout,compile for JRE-style directory layout [[default=no]])],
836             [case "${enableval}" in
837                 yes) WITH_JRE_LAYOUT=yes
838                      AC_DEFINE([WITH_JRE_LAYOUT], 1, [with JRE layout])
839                      ;;
840                 *) WITH_JRE_LAYOUT=no;;
841              esac],
842             [WITH_JRE_LAYOUT=no])
843 AC_MSG_RESULT(${WITH_JRE_LAYOUT})
844
845
846 dnl check if GNU Classpath should be linked statically into CACAO
847 AC_MSG_CHECKING(whether to link GNU Classpath native libraries statically into CACAO)
848 AC_ARG_WITH([static-classpath],
849             [AS_HELP_STRING(--with-static-classpath,link GNU classpath native libraries statically into CACAO [[default=no]])],
850             [case "${enableval}" in
851                 yes) WITH_STATIC_CLASSPATH=yes;;
852                 *) WITH_STATIC_CLASSPATH=no;;
853              esac],
854             [WITH_STATIC_CLASSPATH=no])
855 AC_MSG_RESULT(${WITH_STATIC_CLASSPATH})
856
857 if test x"${WITH_STATIC_CLASSPATH}" = "xyes"; then
858     AC_DEFINE([WITH_STATIC_CLASSPATH], 1, [link GNU classpath native libraries statically into CACAO])
859
860     dnl check for some classpath related stuff when we link statically
861     AM_ICONV_LINK
862 else
863     AC_CHECK_HEADERS([ltdl.h],, [AC_MSG_ERROR(cannot find ltdl.h)])
864     AC_CHECK_LIB(ltdl, lt_dlopen,, [AC_MSG_ERROR(cannot find libltdl)])
865 fi
866 AM_CONDITIONAL([WITH_STATIC_CLASSPATH], test x"${WITH_STATIC_CLASSPATH}" = "xyes")
867 AC_SUBST(WITH_STATIC_CLASSPATH)
868
869
870 dnl check for some programs we need
871 AC_PROG_JAVAC
872 AC_PROG_JAR
873
874
875 dnl finally pass CFLAGS to Makefiles via AM_CFLAGS
876 CFLAGS=$OPT_CFLAGS
877 AM_CFLAGS=$ARCH_CFLAGS
878 AC_SUBST(AM_CFLAGS)
879
880
881 AC_CONFIG_FILES([Makefile]
882                 [contrib/Makefile]
883                 [contrib/setenvinstalled]
884                 [contrib/setenvsource]
885                 [doc/Makefile]
886                 [doc/handbook/Makefile]
887                 [man/Makefile]
888                 [src/Makefile]
889                 [src/cacao/Makefile]
890                 [src/cacaoh/Makefile]
891                 [src/fdlibm/Makefile]
892                 [src/lib/Makefile]
893                 [src/mm/Makefile]
894                 [src/mm/cacao-gc/Makefile]
895                 [src/native/Makefile]
896                 [src/native/include/Makefile]
897                 [src/native/jvmti/Makefile]
898                 [src/native/tools/Makefile]
899                 [src/native/vm/Makefile]
900                 [src/scripts/Makefile]
901                 [src/scripts/java]
902                 [src/threads/Makefile]
903                 [src/threads/native/Makefile]
904                 [src/threads/none/Makefile]
905                 [src/toolbox/Makefile]
906                 [src/vm/Makefile]
907                 [src/vm/jit/Makefile]
908                 [src/vm/jit/allocator/Makefile]
909                 [src/vm/jit/alpha/Makefile]
910                 [src/vm/jit/alpha/freebsd/Makefile]
911                 [src/vm/jit/alpha/linux/Makefile]
912                 [src/vm/jit/i386/Makefile]
913                 [src/vm/jit/i386/cygwin/Makefile]
914                 [src/vm/jit/i386/darwin/Makefile]
915                 [src/vm/jit/i386/freebsd/Makefile]
916                 [src/vm/jit/i386/linux/Makefile]
917                 [src/vm/jit/intrp/Makefile]
918                 [src/vm/jit/inline/Makefile]
919                 [src/vm/jit/loop/Makefile]
920                 [src/vm/jit/mips/Makefile]
921                 [src/vm/jit/mips/irix/Makefile]
922                 [src/vm/jit/mips/linux/Makefile]
923                 [src/vm/jit/optimizing/Makefile]
924                 [src/vm/jit/parisc/Makefile]
925                 [src/vm/jit/powerpc/Makefile]
926                 [src/vm/jit/powerpc/darwin/Makefile]
927                 [src/vm/jit/powerpc/linux/Makefile]
928                 [src/vm/jit/powerpc/netbsd/Makefile]
929                 [src/vm/jit/powerpc64/Makefile]
930                 [src/vm/jit/powerpc64/linux/Makefile]
931                 [src/vm/jit/schedule/Makefile]
932                 [src/vm/jit/sparc64/Makefile]
933                 [src/vm/jit/sparc64/linux/Makefile]
934                 [src/vm/jit/tools/Makefile]
935                 [src/vm/jit/verify/Makefile]
936                 [src/vm/jit/x86_64/Makefile]
937                 [tests/Makefile]
938                 [tests/regression/Makefile]
939                 [tests/regression/codepatching/Makefile]
940                 [tests/regression/jasmin/Makefile]
941                 [tests/regression/native/Makefile])
942
943
944 dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS
945 export OPT_CFLAGS
946 export ARCH_CFLAGS
947 AC_CONFIG_SUBDIRS(src/mm/boehm-gc)
948
949
950 AC_OUTPUT
951
952
953 ## Local variables:
954 ## mode: m4
955 ## indent-tabs-mode: t
956 ## c-basic-offset: 4
957 ## tab-width: 8
958 ## compile-command: "automake --add-missing"
959 ## End: