b0381720f1bbef56f8d1f70165dd2af38618985e
[cacao.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT(cacao, 0.92+cvs, 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         CFLAGS="-O0 -g3"
18 fi
19
20 dnl system type
21 case "$host_cpu" in
22 alpha | alphaev56 | alphapca56 )
23         ARCH_DIR="alpha"
24         CFLAGS="$CFLAGS -mieee -D__ALPHA__"
25         ;;
26
27 arm | armv4tl | armv5b )
28         ARCH_DIR="arm"
29         CFLAGS="$CFLAGS -D__ARM__"
30         ;;
31
32 i386 | i486 | i586 | i686 )
33         ARCH_DIR="i386"
34         CFLAGS="$CFLAGS -D__I386__"
35         ;;
36
37 mips )
38         ARCH_DIR="mips"
39         CFLAGS="$CFLAGS -D__MIPS__"
40         ;;
41
42 powerpc )
43         ARCH_DIR="powerpc"
44         CFLAGS="$CFLAGS -D__POWERPC__"
45         ;;
46
47 x86_64 )
48         ARCH_DIR="x86_64"
49         CFLAGS="$CFLAGS -D__X86_64__"
50         ;;
51
52 xdspcore )
53         ARCH_DIR="xdspcore"
54         ENABLE_STATICVM="yes"
55         CFLAGS="$CFLAGS -D__XDSPCORE__"
56         USE_SCHEDULER="1"
57         ;;
58 * )
59         AC_MSG_ERROR($host_cpu systems are not supported at this time)
60         ;;
61 esac
62
63 dnl host type
64 case "$host_os" in
65 *linux* | *Linux* )
66         OS_DIR="linux"
67         CFLAGS="$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"
68         ;;
69 *darwin* )
70         OS_DIR="darwin"
71         CFLAGS="$CFLAGS -D__DARWIN__ -ansi -pedantic -Wall -Wno-long-long"
72         ;;
73 *freebsd* )
74         OS_DIR="freebsd"
75         CFLAGS="$CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED"
76         ;;
77 *irix* )
78         OS_DIR="irix"
79         CFLAGS="$CFLAGS -D__IRIX__"
80         ;;
81 * )
82         ;;
83 esac
84
85
86 dnl define and substitute some architecture specific variables
87 AC_DEFINE_UNQUOTED([ARCH_DIR], "${ARCH_DIR}", [Architecture directory])
88 AC_SUBST(ARCH_DIR)
89 AC_SUBST(OS_DIR)
90 AC_SUBST(USE_SCHEDULER)
91
92
93 dnl Checks for programs.
94 AC_PROG_CC
95 AM_PROG_AS
96 AC_PROG_LD
97 AC_PROG_LD_GNU
98 AC_PROG_RANLIB
99 AC_DISABLE_SHARED
100 AC_PROG_LN_S
101 AC_PROG_MAKE_SET
102
103 dnl libtool stuff
104 AC_LIBTOOL_DLOPEN
105 AC_LIBLTDL_CONVENIENCE
106 AC_PROG_LIBTOOL
107 AC_SUBST(LIBLTDL)
108
109 dnl Checks for header files.
110 AC_HEADER_DIRENT
111 AC_HEADER_STDC
112 AC_CHECK_HEADERS([fcntl.h])
113 AC_CHECK_HEADERS([sys/time.h])
114 AC_CHECK_HEADERS([unistd.h])
115 AC_CHECK_HEADERS([sys/ioctl.h])
116
117 dnl this is for fdlibm
118 AC_CHECK_HEADERS([stdint.h])
119 AC_CHECK_HEADERS([inttypes.h])
120 AC_CHECK_HEADERS([sys/config.h])
121 AC_CHECK_HEADERS([sys/types.h])
122 AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
123 AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
124 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]))
125 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]))
126
127 dnl Checks for typedefs, structures, and compiler characteristics.
128 AC_C_CONST
129 AC_C_INLINE
130 AC_C_ATTRIBUTE
131 AC_TYPE_OFF_T
132 AC_TYPE_SIZE_T
133 AC_HEADER_TIME
134 AC_STRUCT_TM
135
136 dnl Checks for library functions.
137 AC_PROG_GCC_TRADITIONAL
138 AC_TYPE_SIGNAL
139 AC_FUNC_MEMCMP
140 AC_CHECK_FUNCS(calloc mprotect getpagesize free)
141 AC_CHECK_FUNCS(getcwd gettimeofday)
142
143 dnl Checks for libraries.
144
145 dnl Checking sizeof void *
146 AC_COMPILE_CHECK_SIZEOF(void *)
147 AC_C_BIGENDIAN
148
149 dnl check which ld flags are required to export symbols
150 if test x"$with_gnu_ld" = "xyes"; then
151         EXPORT_SYMBOLS_FLAGS="-Wl,--export-dynamic"
152 else
153         EXPORT_SYMBOLS_FLAGS=""
154 fi
155 AC_SUBST(EXPORT_SYMBOLS_FLAGS)
156
157
158 dnl define install prefix
159 if test "x$prefix" = "xNONE"; then
160         CACAO_INSTALL_PREFIX=$ac_default_prefix
161 else
162         CACAO_INSTALL_PREFIX=$prefix
163 fi
164 AC_DEFINE_UNQUOTED([CACAO_INSTALL_PREFIX], "${CACAO_INSTALL_PREFIX}", [Installation prefix])
165 AC_SUBST(CACAO_INSTALL_PREFIX)
166
167
168 dnl Features
169
170 dnl check arguments
171
172 dnl check for JIT compiler
173 AC_ARG_ENABLE([jit], [AS_HELP_STRING(--disable-jit,disable JIT compiler [[default=yes]])])
174
175 AC_MSG_CHECKING(whether JIT compiled should be compiled)
176 if test x"$enable_jit" = "xno"; then
177         AC_MSG_RESULT(no)
178         AM_CONDITIONAL([ENABLE_JIT], [false])
179 else
180         AC_MSG_RESULT(yes)
181         AC_DEFINE([ENABLE_JIT], 1, [enable JIT compiler])
182         AM_CONDITIONAL([ENABLE_JIT], [true])
183 fi
184
185 dnl check for interpreter
186 AC_ARG_ENABLE([intrp], [AS_HELP_STRING(--enable-intrp,enable interpreter [[default=no]])])
187
188 AC_MSG_CHECKING(whether interpreter should be compiled)
189 if test x"$enable_intrp" = "xyes"; then
190         AC_MSG_RESULT(yes)
191         AC_DEFINE([ENABLE_INTRP], 1, [enable interpreter])
192         AM_CONDITIONAL([ENABLE_INTRP], [true])
193         ENABLE_INTRP="yes"
194 else
195         AC_MSG_RESULT(no)
196         AM_CONDITIONAL([ENABLE_INTRP], [false])
197         ENABLE_INTRP="no"
198 fi
199
200 if test x"${ENABLE_JIT}" = "xno" -a x"${ENABLE_INTRP}" = "xno"; then
201         AC_ERROR(You have to enable at least the JIT or the interpreter.)
202 fi
203 if test x"${ENABLE_JIT}" = "xyes" -a x"${ENABLE_INTRP}" = "xyes"; then
204         AC_ERROR(This is currently not supported. Please disable the JIT or the interpreter.)
205 fi
206
207 dnl check for garbage collector usage
208 AC_ARG_ENABLE([gc], [AS_HELP_STRING(--disable-gc,disable garbage collector (for debugging only!) [[default=yes]])])
209
210 AC_MSG_CHECKING(whether GC should be used)
211 if test x"$enable_gc" = "xno"; then
212         AC_MSG_RESULT(no)
213         AC_DEFINE([DISABLE_GC], 1, [disable grabage collector])
214         AM_CONDITIONAL([DISABLE_GC], [true])
215         DISABLE_GC="yes"
216 else
217         AC_MSG_RESULT(yes)
218         AM_CONDITIONAL([DISABLE_GC], [false])
219         DISABLE_GC="no"
220 fi
221
222 dnl check for dump memory usage
223 AC_ARG_ENABLE([gc], [AS_HELP_STRING(--disable-dump,disable dump memory (for debugging only!) [[default=yes]])])
224
225 AC_MSG_CHECKING(whether dump memory should be used)
226 if test x"$enable_dump" = "xno"; then
227         AC_MSG_RESULT(no)
228         AC_DEFINE([DISABLE_DUMP], 1, [disable dump memory])
229 else
230         AC_MSG_RESULT(yes)
231 fi
232
233 dnl check for statistics
234 AC_ARG_ENABLE([statistics], [AS_HELP_STRING(--disable-statistics,disable statistics generation [[default=yes]])])
235
236 AC_MSG_CHECKING(whether statistics generation should be enabled)
237 if test x"$enable_statistics" = "xno"; then
238         AC_MSG_RESULT(no)
239         AM_CONDITIONAL([STATISTICS], [false])
240 else
241         AC_MSG_RESULT(yes)
242         AC_DEFINE([STATISTICS], 1, [use statistics])
243         AM_CONDITIONAL([STATISTICS], [true])
244 fi
245
246 dnl check for JVMTI
247 AC_ARG_ENABLE([jvmti], [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])])
248
249 AC_MSG_CHECKING(whether to compile JVMTI support)
250 if test x"$enable_jvmti" = "xyes"; then
251         AC_MSG_RESULT(yes)
252         AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI])
253         AM_CONDITIONAL([ENABLE_JVMTI], [true])
254 else
255         AC_MSG_RESULT(no)
256         AM_CONDITIONAL([ENABLE_JVMTI], [false])
257 fi
258
259
260 dnl threads
261 AC_ARG_ENABLE([threads], [AS_HELP_STRING(--enable-threads,enable threads support (none,green,native) [[default=native]])])
262 AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
263
264 AC_MSG_CHECKING(whether to include threads support)
265 enable_threads=${enable_threads:-native}
266 case "$enable_threads" in
267 no | none | single)
268         AC_MSG_RESULT(no)
269         dnl no threads for boehm
270         ac_configure_args="$ac_configure_args --disable-boehm-threads"
271         AM_CONDITIONAL([USE_THREADS], [false])
272         AM_CONDITIONAL([NATIVE_THREADS], [false])
273         ;;
274
275 green | native | posix | pthreads)
276         AC_DEFINE([USE_THREADS], 1, [use threads])
277         AC_DEFINE([EXTERNAL_OVERFLOW], 1, [external overflow])
278         AC_DEFINE([DONT_FREE_FIRST], 1, [don't free first])
279
280         AM_CONDITIONAL([USE_THREADS], [true])
281
282         if test x"$enable_threads" != "xgreen"; then
283                 AC_MSG_RESULT(yes, native)
284                 AC_CHECK_LIB(pthread, main)
285                 AC_DEFINE([NATIVE_THREADS], 1, [use pthreads])
286
287                 CFLAGS="$CFLAGS -D_REENTRANT"
288
289                 dnl tell boehm to support threads as well
290                 ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
291                 AM_CONDITIONAL([NATIVE_THREADS], [true])
292
293         else
294                 AC_MSG_RESULT(yes, green)
295
296                 dnl no threads for boehm
297                 ac_configure_args="$ac_configure_args --disable-boehm-threads"
298                 AM_CONDITIONAL([NATIVE_THREADS], [false])
299         fi
300     ;;
301 *)
302     AC_MSG_ERROR($enable_threads is an unknown thread package)
303     ;;
304 esac
305
306
307 dnl Check whether the compiler supports the __thread keyword.
308 if test "x$use__thread" != xno; then
309   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
310   [cat > conftest.c <<\EOF
311 __thread int a = 42;
312 EOF
313   if AC_TRY_COMMAND([${CC-cc} $CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
314     ac_cv_gcc___thread=yes 
315   else
316     ac_cv_gcc___thread=no
317   fi
318   rm -f conftest*])
319   if test "$ac_cv_gcc___thread" = yes; then
320     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
321   fi
322 else
323   ac_cv_gcc___thread=no
324 fi
325
326
327 dnl check if linear scan register allocator(lsra) should be used
328 AC_ARG_ENABLE([lsra], [AS_HELP_STRING(--enable-lsra,enable linear scan register allocator [[default=yes]])])
329
330 AC_MSG_CHECKING(whether lsra should be supported)
331 if test x"$enable_lsra" = "xno"; then
332         AC_MSG_RESULT(no)
333 else
334         AC_MSG_RESULT(yes)
335         AC_DEFINE([LSRA], 1, [use lsra])
336 fi
337
338
339 dnl check for inlining
340 dnl AC_ARG_ENABLE([inlining], [AS_HELP_STRING(--disable-inlining,disable method inlining [[default=yes]])])
341
342 dnl AC_MSG_CHECKING(whether method inlining should be disabled)
343 dnl if test x"$enable_inlining" = "xno"; then
344 dnl     AC_MSG_RESULT(yes)
345 dnl     AM_CONDITIONAL([USE_INLINING], [false])
346 dnl else
347 dnl     AC_MSG_RESULT(no)
348         AC_DEFINE([USE_INLINING], 1, [use method inlining])
349         AM_CONDITIONAL([USE_INLINING], [true])
350 dnl fi
351
352
353 dnl check for instruction scheduler
354 AC_ARG_ENABLE([scheduler], [AS_HELP_STRING(--enable-scheduler,enable instruction scheduler [[default=no]])])
355
356 AC_MSG_CHECKING(whether instruction scheduler should be supported)
357 if test x"${USE_SCHEDULER}" = "x1" -o x"$enable_scheduler" = "xyes"; then
358         case "${ARCH_DIR}" in
359                 xdspcore )
360                         ;;
361                 * )
362                         AC_MSG_ERROR(instruction scheduler is not available for ${ARCH_DIR} code generator)
363                         ;;
364         esac
365
366         AC_MSG_RESULT(yes)
367         AC_DEFINE([USE_SCHEDULER], 1, [use scheduler])
368         AM_CONDITIONAL([USE_SCHEDULER], [true])
369 else
370         AC_MSG_RESULT(no)
371         AM_CONDITIONAL([USE_SCHEDULER], [false])
372 fi
373
374
375 dnl check if zlib should be used
376 AC_ARG_ENABLE([zlib], [AS_HELP_STRING(--enable-zlib,enable zip archive class storage (needs zlib) [[default=yes]])])
377
378 AC_MSG_CHECKING(whether zip archives should be supported)
379 if test x"$enable_zlib" = "xno"; then
380         AC_MSG_RESULT(no)
381         AM_CONDITIONAL([USE_ZLIB], [false])
382 else
383         AC_MSG_RESULT(yes)
384         AC_DEFINE([USE_ZLIB], 1, [use zlib])
385         AC_CHECK_HEADERS([zlib.h])
386         AC_CHECK_LIB(z, main)
387         AM_CONDITIONAL([USE_ZLIB], [true])
388 fi
389
390
391 dnl check if CACAO should be linked statically
392 AC_ARG_ENABLE([staticvm], [AS_HELP_STRING(--enable-staticvm, link GNU classpath's native libraries statically into CACAO [[default=no]])])
393
394 AC_MSG_CHECKING(whether to link GNU classpath statically into CACAO)
395 if test x"$enable_staticvm" = "xyes"; then
396         ENABLE_STATICVM="yes"
397 else
398         ENABLE_STATICVM="no"
399 fi
400
401 if test x"${ENABLE_STATICVM}" = "xyes"; then
402         AC_MSG_RESULT(yes)
403         AM_CONDITIONAL([ENABLE_STATICVM], [true])
404 else
405         AC_MSG_RESULT(no)
406         AM_CONDITIONAL([ENABLE_STATICVM], [false])
407 fi
408 AC_SUBST(ENABLE_STATICVM)
409
410
411 dnl pass configure options to classpath
412 if test x"${ENABLE_STATICVM}" = "xyes"; then
413         AC_DEFINE([ENABLE_STATICVM], 1, [link CACAO statically])
414         AM_CONDITIONAL([ENABLE_STATICVM], [true])
415
416         dnl check for some classpath related stuff when we link statically
417         AM_ICONV_LINK
418 else
419         AM_CONDITIONAL([ENABLE_STATICVM], [false])
420 fi
421
422
423 dnl is GNU classpath installed somewhere different
424 AC_ARG_WITH([classpath-install-dir], [AS_HELP_STRING(--with-classpath-install-dir=<dir>,installation directory of GNU classpath [[default=/usr/local/classpath]])])
425
426 AC_MSG_CHECKING(where GNU classpath is installed)
427 if test x"$with_classpath_install_dir" != "x"; then
428         if test x"$with_classpath_install_dir" = "xyes"; then
429                 AC_MSG_ERROR(please specify the installation prefix)
430         fi
431         CLASSPATH_INSTALL_DIR="$with_classpath_install_dir"
432 else
433         CLASSPATH_INSTALL_DIR="/usr/local/classpath"
434 fi
435 AC_MSG_RESULT(${CLASSPATH_INSTALL_DIR})
436 AC_DEFINE_UNQUOTED([CLASSPATH_INSTALL_DIR], "${CLASSPATH_INSTALL_DIR}", [GNU classpath installation directory])
437 AC_SUBST(CLASSPATH_INSTALL_DIR)
438
439
440 dnl now configure subpackages
441 dnl the export is not my favorite (is there another way?)
442 export CFLAGS
443 AC_CONFIG_SUBDIRS(src/boehm-gc src/libltdl src/libffi)
444
445 AC_CONFIG_FILES([Makefile]
446                 [contrib/Makefile]
447                 [contrib/setenvinstalled]
448                 [contrib/setenvsource]
449                 [doc/Makefile]
450                 [doc/handbook/Makefile]
451                 [man/Makefile]
452                 [src/Makefile]
453                 [src/cacao/Makefile]
454                 [src/cacaoh/Makefile]
455                 [src/fdlibm/Makefile]
456                 [src/lib/Makefile]
457                 [src/mm/Makefile]
458                 [src/native/Makefile]
459                 [src/native/include/Makefile]
460                 [src/native/jvmti/Makefile]
461                 [src/native/tools/Makefile]
462                 [src/native/vm/Makefile]
463                 [src/scripts/Makefile]
464                 [src/scripts/java]
465                 [src/scripts/rmiregistry]
466                 [src/threads/Makefile]
467                 [src/threads/green/Makefile]
468                 [src/threads/native/Makefile]
469                 [src/toolbox/Makefile]
470                 [src/vm/Makefile]
471                 [src/vm/jit/Makefile]
472                 [src/vm/jit/alpha/Makefile]
473                 [src/vm/jit/i386/Makefile]
474                 [src/vm/jit/i386/linux/Makefile]
475                 [src/vm/jit/i386/freebsd/Makefile]
476                 [src/vm/jit/intrp/Makefile]
477                 [src/vm/jit/inline/Makefile]
478                 [src/vm/jit/loop/Makefile]
479                 [src/vm/jit/mips/Makefile]
480                 [src/vm/jit/mips/irix/Makefile]
481                 [src/vm/jit/mips/linux/Makefile]
482                 [src/vm/jit/powerpc/Makefile]
483                 [src/vm/jit/powerpc/darwin/Makefile]
484                 [src/vm/jit/powerpc/linux/Makefile]
485                 [src/vm/jit/schedule/Makefile]
486                 [src/vm/jit/tools/Makefile]
487                 [src/vm/jit/verify/Makefile]
488                 [src/vm/jit/x86_64/Makefile]
489                 [tests/Makefile]
490                 [tests/codepatching/Makefile]
491                 [tests/native/Makefile]
492                 [tests/regression/Makefile])
493
494 AC_OUTPUT
495
496
497 ## Local variables:
498 ## mode: m4
499 ## indent-tabs-mode: t
500 ## c-basic-offset: 4
501 ## tab-width: 8
502 ## compile-command: "automake --add-missing"
503 ## End: