17c72398d38079706dc6c7cf4a3669f1834d82fb
[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 )
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 disassembler support
373 AC_MSG_CHECKING(whether disassembler should be enabled)
374 AC_ARG_ENABLE([disassembler],
375               [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])],
376               [case "${enableval}" in
377                    yes) ENABLE_DISASSEMBLER=yes;;
378                    *) ENABLE_DISASSEMBLER=no;;
379                esac],
380               [ENABLE_DISASSEMBLER=no])
381 AC_MSG_RESULT(${ENABLE_DISASSEMBLER})
382 AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes")
383
384 if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then
385     AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler])
386
387     dnl check for binutils headers and libraries on some architectures for the
388     dnl disassembler
389     case "${ARCH_DIR}" in
390         arm | i386 | powerpc | x86_64 | sparc64 | powerpc64)
391             AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)])
392             AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)])
393             AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)])
394             AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)])
395
396             case "${OS_DIR}" in
397                 cygwin | darwin | netbsd )
398                      AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))])
399                      ;;
400             esac
401
402             AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))])
403             AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))])
404             AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))])
405             AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler])
406             AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true])
407             ;;
408         * )
409             AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
410             ;;
411     esac
412 else
413     AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
414 fi
415
416
417 dnl check for statistics
418 AC_MSG_CHECKING(whether statistics generation should be enabled)
419 AC_ARG_ENABLE([statistics],
420               [AS_HELP_STRING(--enable-statistics,enable statistics generation [[default=no]])],
421               [case "${enableval}" in
422                    yes) ENABLE_STATISTICS=yes;;
423                    *) ENABLE_STATISTICS=no;;
424                esac],
425               [ENABLE_STATISTICS=no])
426 AC_MSG_RESULT(${ENABLE_STATISTICS})
427 AM_CONDITIONAL([ENABLE_STATISTICS], test x"${ENABLE_STATISTICS}" = "xyes")
428
429 if test x"${ENABLE_STATISTICS}" = "xyes"; then
430     AC_DEFINE([ENABLE_STATISTICS], 1, [enable statistics])
431 fi
432
433
434 dnl check for verifier
435 AC_MSG_CHECKING(whether classfile verification should be enabled)
436 AC_ARG_ENABLE([verifier],
437               [AS_HELP_STRING(--disable-verifier,disable classfile verification [[default=yes]])],
438               [case "${enableval}" in
439                    no) ENABLE_VERIFIER=no;;
440                    *) ENABLE_VERIFIER=yes;;
441                esac],
442               [ENABLE_VERIFIER=yes])
443 AC_MSG_RESULT(${ENABLE_VERIFIER})
444 AM_CONDITIONAL([ENABLE_VERIFIER], test x"${ENABLE_VERIFIER}" = "xyes")
445
446 if test x"${ENABLE_VERIFIER}" = "xyes"; then
447     AC_DEFINE([ENABLE_VERIFIER], 1, [enable classfile verification])
448 fi
449
450
451 dnl check for compiler timing
452 AC_MSG_CHECKING(whether real-time timing should be enabled)
453 AC_ARG_ENABLE([rt-timing],
454               [AS_HELP_STRING(--enable-rt-timing,enable real-time timing [[default=no]])],
455               [case "${enableval}" in
456                    yes) ENABLE_RT_TIMING=yes;;
457                    *) ENABLE_RT_TIMING=no;;
458                esac],
459               [ENABLE_RT_TIMING=no])
460 AC_MSG_RESULT(${ENABLE_RT_TIMING})
461 AM_CONDITIONAL([ENABLE_RT_TIMING], test x"${ENABLE_RT_TIMING}" = "xyes")
462
463 if test x"${ENABLE_RT_TIMING}" = "xyes"; then
464     AC_DEFINE([ENABLE_RT_TIMING], 1, [enable real-time timing])
465 fi
466
467
468 dnl check for cycle count statistics
469 AC_MSG_CHECKING(whether cycle count statistics should be enabled)
470 AC_ARG_ENABLE([cycles-stats],
471               [AS_HELP_STRING(--enable-cycles-stats,enable cycle count statistics [[default=no]])],
472               [case "${enableval}" in
473                    yes) ENABLE_CYCLES_STATS=yes;;
474                    *) ENABLE_CYCLES_STATS=no;;
475                esac],
476               [ENABLE_CYCLES_STATS=no])
477 AC_MSG_RESULT(${ENABLE_CYCLES_STATS})
478 AM_CONDITIONAL([ENABLE_CYCLES_STATS], test x"${ENABLE_CYCLES_STATS}" = "xyes")
479
480 if test x"${ENABLE_CYCLES_STATS}" = "xyes"; then
481     AC_DEFINE([ENABLE_CYCLES_STATS], 1, [enable cycle count statistics])
482 fi
483
484
485 dnl check for JVMTI
486 AC_MSG_CHECKING(whether to compile JVMTI support)
487 AC_ARG_ENABLE([jvmti],
488               [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])],
489               [case "${enableval}" in
490                    yes) ENABLE_JVMTI=yes;;
491                    *) ENABLE_JVMTI=no;;
492                esac],
493               [ENABLE_JVMTI=no])
494 AC_MSG_RESULT(${ENABLE_JVMTI})
495 AM_CONDITIONAL([ENABLE_JVMTI], test x"${ENABLE_JVMTI}" = "xyes")
496
497 if test x"${ENABLE_JVMTI}" = "xyes"; then
498     AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI])
499 fi
500
501
502 dnl threads
503 AC_ARG_ENABLE([threads], [AS_HELP_STRING(--enable-threads,enable threads support (none,native) [[default=native]])])
504 AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
505
506 AC_MSG_CHECKING(whether to include threads support)
507 enable_threads=${enable_threads:-native}
508 case "$enable_threads" in
509 no | none | single)
510     AC_MSG_RESULT(no)
511     dnl no threads for boehm
512     ac_configure_args="$ac_configure_args --disable-boehm-threads"
513     AM_CONDITIONAL([ENABLE_THREADS], [false])
514     ;;
515
516 native | posix | pthreads)
517     AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
518     
519     AM_CONDITIONAL([ENABLE_THREADS], [true])
520     
521     AC_MSG_RESULT(yes, native)
522     AC_CHECK_LIB(pthread, main)
523
524     ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
525
526     dnl we changed ARCH_CFLAGS, set CFLAGS again
527     CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
528
529     dnl tell boehm to support threads as well
530     ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
531     ;;
532
533 *)
534     AC_MSG_ERROR($enable_threads is an unknown thread package)
535     ;;
536 esac
537
538
539 dnl Check whether the compiler supports the __thread keyword.
540 if test "x$use__thread" != xno; then
541   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
542   [cat > conftest.c <<\EOF
543 __thread int a = 42;
544 EOF
545   if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
546     ac_cv_gcc___thread=yes 
547   else
548     ac_cv_gcc___thread=no
549   fi
550   rm -f conftest*])
551   if test "$ac_cv_gcc___thread" = yes; then
552     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
553   fi
554 else
555   ac_cv_gcc___thread=no
556 fi
557
558
559 dnl check if if-conversion should be supported
560 AC_MSG_CHECKING(whether if-conversion should be supported)
561 AC_ARG_ENABLE([ifconv],
562               [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=yes]])],
563               [case "${enableval}" in
564                    no) ENABLE_IFCONV=no;;
565                    *) ENABLE_IFCONV=yes;;
566                esac],
567               [ENABLE_IFCONV=yes])
568 AC_MSG_RESULT(${ENABLE_IFCONV})
569 AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes")
570    
571 if test x"${ENABLE_IFCONV}" = "xyes"; then
572     AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion])
573 fi
574
575
576 dnl check for inlining
577 AC_MSG_CHECKING(whether method inlining should be supported)
578 AC_ARG_ENABLE([inlining],
579               [AS_HELP_STRING(--enable-inlining,enable method inlining [[default=no]])],
580               [case "${enableval}" in
581                    yes) ENABLE_INLINING=yes;;
582                    *) ENABLE_INLINING=no;;
583                esac],
584               [ENABLE_INLINING=no])
585 AC_MSG_RESULT(${ENABLE_INLINING})
586 AM_CONDITIONAL([ENABLE_INLINING], test x"${ENABLE_INLINING}" = "xyes")
587
588 if test x"${ENABLE_INLINING}" = "xyes"; then
589     AC_DEFINE([ENABLE_INLINING], 1, [use method inlining])
590 fi
591
592
593 dnl check for loop optimization
594 AC_MSG_CHECKING(whether loop optimization should be supported)
595 AC_ARG_ENABLE([loop],
596               [AS_HELP_STRING(--enable-loop,enable loop optimization [[default=no]])],
597               [case "${enableval}" in
598                    yes) ENABLE_LOOP=yes;;
599                    *) ENABLE_LOOP=no;;
600                esac],
601               [ENABLE_LOOP=no])
602 AC_MSG_RESULT(${ENABLE_LOOP})
603 AM_CONDITIONAL([ENABLE_LOOP], test x"${ENABLE_LOOP}" = "xyes")
604
605 if test x"${ENABLE_LOOP}" = "xyes"; then
606     AC_DEFINE([ENABLE_LOOP], 1, [use loop optimization])
607 fi
608
609
610 dnl check if linear scan register allocator(lsra) with SSA should be used
611 AC_MSG_CHECKING(whether lsra with ssa should be supported)
612 AC_ARG_ENABLE([ssa],
613               [AS_HELP_STRING(--disable-ssa,disable ssa [[default=no]])],
614               [case "${enableval}" in
615                    no) ENABLE_SSA=no;;
616                    *) ENABLE_SSA=yes;;
617                esac],
618               [ENABLE_SSA=no])
619 AC_MSG_RESULT(${ENABLE_SSA})
620 AM_CONDITIONAL([ENABLE_SSA], test x"${ENABLE_SSA}" = "xyes")
621
622 if test x"${ENABLE_SSA}" = "xyes"; then
623     AC_DEFINE([ENABLE_SSA], 1, [enable lsra with ssa])
624     ENABLE_LSRA="no"
625 fi
626
627
628 dnl check if linear scan register allocator(lsra) should be used
629 AC_MSG_CHECKING(whether lsra should be supported)
630 AC_ARG_ENABLE([lsra],
631               [AS_HELP_STRING(--enable-lsra,enable linear scan register allocator [[default=no]])],
632               [case "${enableval}" in
633                    yes) ENABLE_LSRA=yes;;
634                    *) ENABLE_LSRA=no;;
635                esac],
636               [ENABLE_LSRA=no])
637    
638 if test x"${ENABLE_LSRA}" = "xyes"; then
639     if test x"${ENABLE_SSA}" = "xyes"; then
640         ENABLE_LSRA="no"
641     fi
642 fi
643 AC_MSG_RESULT(${ENABLE_LSRA})
644 AM_CONDITIONAL([ENABLE_LSRA], test x"${ENABLE_LSRA}" = "xyes")
645  
646 if test x"${ENABLE_LSRA}" = "xyes"; then
647     AC_DEFINE([ENABLE_LSRA], 1, [enable lsra])
648 fi
649
650
651 dnl check if profiling should be supported
652 AC_MSG_CHECKING(whether profiling should be supported)
653 AC_ARG_ENABLE([profiling],
654               [AS_HELP_STRING(--enable-profiling,enable profiling [[default=no]])],
655               [case "${enableval}" in
656                    yes) ENABLE_PROFILING=yes;;
657                    *) ENABLE_PROFILING=no;;
658                esac],
659               [ENABLE_PROFILING=no])
660 AC_MSG_RESULT(${ENABLE_PROFILING})
661 AM_CONDITIONAL([ENABLE_PROFILING], test x"${ENABLE_PROFILING}" = "xyes")
662    
663 if test x"${ENABLE_PROFILING}" = "xyes"; then
664     AC_DEFINE([ENABLE_PROFILING], 1, [enable profiling])
665 fi
666
667
668 dnl check for instruction scheduler
669 AC_ARG_ENABLE([scheduler], [AS_HELP_STRING(--enable-scheduler,enable instruction scheduler [[default=no]])])
670
671 AC_MSG_CHECKING(whether instruction scheduler should be supported)
672 if test x"${USE_SCHEDULER}" = "x1" -o x"$enable_scheduler" = "xyes"; then
673         case "${ARCH_DIR}" in
674                 xdspcore )
675                         ;;
676                 * )
677                         AC_MSG_ERROR(instruction scheduler is not available for ${ARCH_DIR} code generator)
678                         ;;
679         esac
680
681         AC_MSG_RESULT(yes)
682         AC_DEFINE([USE_SCHEDULER], 1, [use scheduler])
683         AM_CONDITIONAL([USE_SCHEDULER], [true])
684 else
685         AC_MSG_RESULT(no)
686         AM_CONDITIONAL([USE_SCHEDULER], [false])
687 fi
688
689
690 dnl check if zlib should be used
691 AC_MSG_CHECKING(whether ZIP/JAR archives should be supported)
692 AC_ARG_ENABLE([zlib],
693               [AS_HELP_STRING(--disable-zlib,disable ZIP/JAR archive support (needs zlib) [[default=yes]])],
694               [case "${enableval}" in
695                   no) ENABLE_ZLIB=no;;
696                   *) ENABLE_ZLIB=yes;;
697                esac],
698               [ENABLE_ZLIB=yes])
699 AC_MSG_RESULT(${ENABLE_ZLIB})
700
701 if test x"${ENABLE_ZLIB}" = "xyes"; then
702     AC_CHECK_HEADERS([zconf.h],, [AC_MSG_ERROR(cannot find zconf.h)])
703     AC_CHECK_HEADERS([zlib.h],, [AC_MSG_ERROR(cannot find zlib.h)])
704     AC_CHECK_LIB(z, inflate,, [AC_MSG_ERROR(cannot find libz)])
705     AC_DEFINE([ENABLE_ZLIB], 1, [use zlib])
706 fi
707 AM_CONDITIONAL([ENABLE_ZLIB], test x"${ENABLE_ZLIB}" = "xyes")
708
709
710 dnl check if a libjvm.so should be built
711 AC_MSG_CHECKING(whether to build a libjvm.so)
712 AC_ARG_ENABLE([libjvm],
713               [AS_HELP_STRING(--disable-libjvm,build a libjvm.so [[default=yes]])],
714               [case "${enableval}" in
715                   no) ENABLE_LIBJVM=no;;
716                   *) ENABLE_LIBJVM=yes;;
717                esac],
718               [ENABLE_LIBJVM=yes])
719 AC_MSG_RESULT(${ENABLE_LIBJVM})
720 AM_CONDITIONAL([ENABLE_LIBJVM], test x"${ENABLE_LIBJVM}" = "xyes")
721 AC_SUBST(ENABLE_LIBJVM)
722
723 if test x"${ENABLE_LIBJVM}" = "xyes"; then
724     AC_DEFINE([ENABLE_LIBJVM], 1, [enable libjvm.so])
725
726     dnl set AC_ENABLE_SHARED and AC_DISABLE_STATIC properly
727     enable_shared=yes
728     enable_static=no
729 else
730     enable_shared=no
731     enable_static=yes
732 fi
733
734 dnl libtool stuff
735 AC_LIBTOOL_DLOPEN
736 AC_PROG_LIBTOOL
737
738
739 dnl check if CACAO should be linked statically
740 AC_MSG_CHECKING(whether to link CACAO statically)
741 AC_ARG_ENABLE([staticvm],
742               [AS_HELP_STRING(--enable-staticvm,link CACAO statically [[default=no]])],
743               [case "${enableval}" in
744                   yes) ENABLE_STATICVM=yes
745                        AC_DEFINE([ENABLE_STATICVM], 1, [link CACAO statically])
746                        ;;
747                   *) ENABLE_STATICVM=no;;
748                esac],
749               [ENABLE_STATICVM=no])
750 AC_MSG_RESULT(${ENABLE_STATICVM})
751 AM_CONDITIONAL([ENABLE_STATICVM], test x"${ENABLE_STATICVM}" = "xyes")
752 AC_SUBST(ENABLE_STATICVM)
753
754
755 dnl where is CACAO's vm.zip
756 AC_MSG_CHECKING(where CACAO's vm.zip is installed)
757 AC_ARG_WITH([vm-zip],
758             [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]])],
759             [CACAO_VM_ZIP=${withval}],
760             [CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/vm.zip])
761 AC_MSG_RESULT(${CACAO_VM_ZIP})
762 AC_DEFINE_UNQUOTED([CACAO_VM_ZIP], "${CACAO_VM_ZIP}", [CACAO's vm.zip])
763 AC_SUBST(CACAO_VM_ZIP)
764
765
766 dnl is GNU classpath installed somewhere different
767 AC_MSG_CHECKING(where GNU Classpath is installed)
768 AC_ARG_WITH([classpath-prefix],
769             [AS_HELP_STRING(--with-classpath-prefix=<dir>,installation directory of GNU Classpath [[default=/usr/local/classpath]])],
770             [CLASSPATH_PREFIX=${withval}],
771             [CLASSPATH_PREFIX=/usr/local/classpath])
772 AC_MSG_RESULT(${CLASSPATH_PREFIX})
773 AC_DEFINE_UNQUOTED([CLASSPATH_PREFIX], "${CLASSPATH_PREFIX}", [GNU Classpath installation directory])
774 AC_SUBST(CLASSPATH_PREFIX)
775
776
777 dnl where is GNU Classpath's glibj.zip
778 AC_MSG_CHECKING(where GNU Classpath's glibj.zip is installed)
779 AC_ARG_WITH([classpath-glibj-zip],
780             [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]])],
781             [CLASSPATH_GLIBJ_ZIP=${withval}],
782             [CLASSPATH_GLIBJ_ZIP=${CLASSPATH_PREFIX}/share/classpath/glibj.zip])
783 AC_MSG_RESULT(${CLASSPATH_GLIBJ_ZIP})
784 AC_DEFINE_UNQUOTED([CLASSPATH_GLIBJ_ZIP], "${CLASSPATH_GLIBJ_ZIP}", [GNU Classpath's glibj.zip])
785 AC_SUBST(CLASSPATH_GLIBJ_ZIP)
786
787
788 dnl where are the GNU Classpath libraries installed
789 AC_MSG_CHECKING(where GNU Classpath libraries are installed)
790 AC_ARG_WITH([classpath-libdir],
791             [AS_HELP_STRING(--with-classpath-libdir=<dir>,installation directory of GNU Classpath libraries [[default=/usr/local/classpath/lib]])],
792             [CLASSPATH_LIBDIR=${withval}],
793             [CLASSPATH_LIBDIR=${CLASSPATH_PREFIX}/lib])
794 AC_MSG_RESULT(${CLASSPATH_LIBDIR})
795
796 dnl expand CLASSPATH_LIBDIR to something that is usable in C code
797 AS_AC_EXPAND([CLASSPATH_LIBDIR], ${CLASSPATH_LIBDIR})
798 AC_DEFINE_UNQUOTED([CLASSPATH_LIBDIR], "${CLASSPATH_LIBDIR}", [GNU Classpath libraries installation directory])
799 AC_SUBST(CLASSPATH_LIBDIR)
800
801
802 dnl where are the GNU Classpath headers installed
803 AC_MSG_CHECKING(where GNU Classpath headers are installed)
804 AC_ARG_WITH([classpath-includedir],
805             [AS_HELP_STRING(--with-classpath-includedir=<dir>,installation directory of GNU Classpath headers [[default=/usr/local/classpath/include]])],
806             [CLASSPATH_INCLUDEDIR=${withval}],
807             [CLASSPATH_INCLUDEDIR=${CLASSPATH_PREFIX}/include])
808 AC_MSG_RESULT(${CLASSPATH_INCLUDEDIR})
809
810 AC_CHECK_HEADER([${CLASSPATH_INCLUDEDIR}/jni.h],
811                 [AC_DEFINE_UNQUOTED([CLASSPATH_JNI_H], "${CLASSPATH_INCLUDEDIR}/jni.h", [GNU Classpath jni.h header])],
812                 [AC_MSG_ERROR(cannot find jni.h)])
813
814
815 dnl if we compile for a JRE-style directory layout
816 AC_MSG_CHECKING(if we compile for a JRE-style directory layout)
817 AC_ARG_WITH([jre-layout],
818             [AS_HELP_STRING(--with-jre-layout,compile for JRE-style directory layout [[default=no]])],
819             [case "${enableval}" in
820                 yes) WITH_JRE_LAYOUT=yes
821                      AC_DEFINE([WITH_JRE_LAYOUT], 1, [with JRE layout])
822                      ;;
823                 *) WITH_JRE_LAYOUT=no;;
824              esac],
825             [WITH_JRE_LAYOUT=no])
826 AC_MSG_RESULT(${WITH_JRE_LAYOUT})
827
828
829 dnl check if GNU Classpath should be linked statically into CACAO
830 AC_MSG_CHECKING(whether to link GNU Classpath native libraries statically into CACAO)
831 AC_ARG_WITH([static-classpath],
832             [AS_HELP_STRING(--with-static-classpath,link GNU classpath native libraries statically into CACAO [[default=no]])],
833             [case "${enableval}" in
834                 yes) WITH_STATIC_CLASSPATH=yes;;
835                 *) WITH_STATIC_CLASSPATH=no;;
836              esac],
837             [WITH_STATIC_CLASSPATH=no])
838 AC_MSG_RESULT(${WITH_STATIC_CLASSPATH})
839
840 if test x"${WITH_STATIC_CLASSPATH}" = "xyes"; then
841     AC_DEFINE([WITH_STATIC_CLASSPATH], 1, [link GNU classpath native libraries statically into CACAO])
842
843     dnl check for some classpath related stuff when we link statically
844     AM_ICONV_LINK
845 else
846     AC_CHECK_HEADERS([ltdl.h],, [AC_MSG_ERROR(cannot find ltdl.h)])
847     AC_CHECK_LIB(ltdl, lt_dlopen,, [AC_MSG_ERROR(cannot find libltdl)])
848 fi
849 AM_CONDITIONAL([WITH_STATIC_CLASSPATH], test x"${WITH_STATIC_CLASSPATH}" = "xyes")
850 AC_SUBST(WITH_STATIC_CLASSPATH)
851
852
853 dnl check for some programs we need
854 AC_PROG_JAVAC
855 AC_PROG_JAR
856
857
858 dnl finally pass CFLAGS to Makefiles via AM_CFLAGS
859 CFLAGS=$OPT_CFLAGS
860 AM_CFLAGS=$ARCH_CFLAGS
861 AC_SUBST(AM_CFLAGS)
862
863
864 AC_CONFIG_FILES([Makefile]
865                 [contrib/Makefile]
866                 [contrib/setenvinstalled]
867                 [contrib/setenvsource]
868                 [doc/Makefile]
869                 [doc/handbook/Makefile]
870                 [man/Makefile]
871                 [src/Makefile]
872                 [src/cacao/Makefile]
873                 [src/cacaoh/Makefile]
874                 [src/fdlibm/Makefile]
875                 [src/lib/Makefile]
876                 [src/mm/Makefile]
877                 [src/mm/cacao-gc/Makefile]
878                 [src/native/Makefile]
879                 [src/native/include/Makefile]
880                 [src/native/jvmti/Makefile]
881                 [src/native/tools/Makefile]
882                 [src/native/vm/Makefile]
883                 [src/scripts/Makefile]
884                 [src/scripts/java]
885                 [src/threads/Makefile]
886                 [src/threads/native/Makefile]
887                 [src/threads/none/Makefile]
888                 [src/toolbox/Makefile]
889                 [src/vm/Makefile]
890                 [src/vm/jit/Makefile]
891                 [src/vm/jit/allocator/Makefile]
892                 [src/vm/jit/alpha/Makefile]
893                 [src/vm/jit/alpha/freebsd/Makefile]
894                 [src/vm/jit/alpha/linux/Makefile]
895                 [src/vm/jit/i386/Makefile]
896                 [src/vm/jit/i386/cygwin/Makefile]
897                 [src/vm/jit/i386/darwin/Makefile]
898                 [src/vm/jit/i386/freebsd/Makefile]
899                 [src/vm/jit/i386/linux/Makefile]
900                 [src/vm/jit/intrp/Makefile]
901                 [src/vm/jit/inline/Makefile]
902                 [src/vm/jit/loop/Makefile]
903                 [src/vm/jit/mips/Makefile]
904                 [src/vm/jit/mips/irix/Makefile]
905                 [src/vm/jit/mips/linux/Makefile]
906                 [src/vm/jit/optimizing/Makefile]
907                 [src/vm/jit/parisc/Makefile]
908                 [src/vm/jit/powerpc/Makefile]
909                 [src/vm/jit/powerpc/darwin/Makefile]
910                 [src/vm/jit/powerpc/linux/Makefile]
911                 [src/vm/jit/powerpc/netbsd/Makefile]
912                 [src/vm/jit/powerpc64/Makefile]
913                 [src/vm/jit/powerpc64/linux/Makefile]
914                 [src/vm/jit/schedule/Makefile]
915                 [src/vm/jit/sparc64/Makefile]
916                 [src/vm/jit/sparc64/linux/Makefile]
917                 [src/vm/jit/tools/Makefile]
918                 [src/vm/jit/verify/Makefile]
919                 [src/vm/jit/x86_64/Makefile]
920                 [tests/Makefile]
921                 [tests/regression/Makefile]
922                 [tests/regression/codepatching/Makefile]
923                 [tests/regression/jasmin/Makefile]
924                 [tests/regression/native/Makefile])
925
926
927 dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS
928 export OPT_CFLAGS
929 export ARCH_CFLAGS
930 AC_CONFIG_SUBDIRS(src/mm/boehm-gc)
931
932
933 AC_OUTPUT
934
935
936 ## Local variables:
937 ## mode: m4
938 ## indent-tabs-mode: t
939 ## c-basic-offset: 4
940 ## tab-width: 8
941 ## compile-command: "automake --add-missing"
942 ## End: