#define TRACE_ARGS_NUM
[cacao.git] / configure.in
1 dnl autoconf; autoheader; automake
2
3 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT(cacao, 0.40, cacao@complang.tuwien.ac.at)
5 AC_CONFIG_SRCDIR(src/cacao/cacao.c)
6 AC_CANONICAL_HOST
7 AC_PREREQ(2.59)
8 AM_INIT_AUTOMAKE
9
10 AM_CONFIG_HEADER([config.h])
11
12 AC_PREFIX_DEFAULT(/usr/local/cacao)
13
14 dnl system type
15
16 case "$host_cpu" in
17 alpha* )
18         ARCH_DIR="alpha"
19         STATIC_CLASSPATH="1"
20         CFLAGS="-mieee -D__ALPHA__"
21         AC_DEFINE([TRACE_ARGS_NUM], 6, [Defines integer argument register count])
22         AC_DEFINE([USE_CODEMMAP], 1, [use code mmap])
23         ;;
24
25 i386* | i486* | i586* | i686* )
26         ARCH_DIR="i386"
27         STATIC_CLASSPATH="0"
28         CFLAGS="-D__I386__"
29         ;;
30
31 mips* )
32         ARCH_DIR="mips"
33         STATIC_CLASSPATH="1"
34         CFLAGS="-64 -O2 -OPT:Olimit=0 -g -woff 1110,1164,1515 -D__MIPS__"
35         LIBS="-lelfutil"
36         AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
37         ;;
38
39 powerpc* | ppc* )
40         ARCH_DIR="powerpc"
41         STATIC_CLASSPATH="1"
42         CFLAGS="-D__POWERPC__"
43         AC_DEFINE([TRACE_ARGS_NUM], 8, [Defines integer argument register count])
44         ;;
45
46 x86_64* )
47         ARCH_DIR="x86_64"
48         STATIC_CLASSPATH="1"
49         CFLAGS="-D__X86_64__"
50         ;;
51
52 sparc* | * )
53         AC_MSG_ERROR($host_cpu systems are not supported at this time)
54         ;;
55 esac
56
57 case "$host_os" in
58 *linux* | *Linux* )
59         CFLAGS="-ansi -pedantic -Wall -Wno-long-long -O0 -g3 $CFLAGS -D__LINUX__ -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE"
60         ;;
61 *darwin* )
62         CFLAGS="-ansi -pedantic -Wall -Wno-long-long -O0 -g3 $CFLAGS -D__DARWIN__"
63         ;;
64 *irix* )
65         CFLAGS="$CFLAGS -D__IRIX__"
66         ;;
67 * )
68         ;;
69 esac
70
71
72 AC_DEFINE_UNQUOTED([ARCH_DIR], "$ARCH_DIR", [Architecture directory])
73 AC_SUBST(ARCH_DIR)
74
75 AC_ARG_ENABLE([dynamicclasspath], [AS_HELP_STRING(--disable-dynamicclasspath, link classpath native code static even on platforms supporting dynamic loading)], [use_dynamicclasspath=$enableval], [use_dynamicclasspath=yes])
76 dnl force static classpath linking ??
77 AC_MSG_CHECKING(Link classpath static)
78 if test "xno" == "x$use_dynamicclasspath"; then
79   STATIC_CLASSPATH="1"
80 fi
81
82 if test "$STATIC_CLASSPATH" == "1"; then
83         AC_MSG_RESULT(yes)
84 else
85         AC_MSG_RESULT(no)
86 fi
87 AC_SUBST(STATIC_CLASSPATH)
88
89 dnl Checks for programs.
90 AC_PROG_CC
91 AM_PROG_AS
92 AC_PROG_RANLIB
93 AC_PROG_MAKE_SET
94
95 dnl Checks for header files.
96 AC_HEADER_DIRENT
97 AC_HEADER_STDC
98 AC_CHECK_HEADERS([fcntl.h])
99 AC_CHECK_HEADERS([sys/time.h])
100 AC_CHECK_HEADERS([unistd.h])
101 AC_CHECK_HEADERS([sys/ioctl.h])
102
103 dnl Checks for typedefs, structures, and compiler characteristics.
104 AC_C_CONST
105 AC_C_INLINE
106 AC_TYPE_OFF_T
107 AC_TYPE_SIZE_T
108 AC_HEADER_TIME
109 AC_STRUCT_TM
110
111 dnl Checks for library functions.
112 AC_PROG_GCC_TRADITIONAL
113 AC_FUNC_MEMCMP
114 AC_FUNC_MMAP
115 AC_TYPE_SIGNAL
116 AC_CHECK_FUNCS(getcwd gettimeofday mkdir mktime select socket)
117
118 dnl Checks for libraries.
119 AC_CHECK_LIB(m, fmod)
120
121 dnl Check for mmap header anomalies (missing MAP_FAILED, etc.)
122 if test $ac_cv_func_mmap_fixed_mapped = yes; then
123         AC_CACHE_CHECK(whether MAP_FAILED is defined,
124                        ac_cv_map_failed,
125                        AC_EGREP_CPP(yes, 
126                                     [#include <sys/mman.h>
127                                      #ifdef MAP_FAILED
128                                         yes
129                                      #endif],
130                                     ac_cv_map_failed=yes,
131                                     ac_cv_map_failed=no))
132
133         AC_CACHE_CHECK(whether MAP_ANONYMOUS is defined,
134                        ac_cv_map_anonymous,
135                        AC_EGREP_CPP(yes, 
136                                     [#include <sys/mman.h>
137                                      #ifdef MAP_ANONYMOUS
138                                         yes
139                                      #endif],
140                                     ac_cv_map_anonymous=yes,
141                                     ac_cv_map_anonymous=no))
142
143         AC_CACHE_CHECK(whether MAP_ANON is defined,
144                        ac_cv_map_anon,
145                        AC_EGREP_CPP(yes, 
146                                     [#include <sys/mman.h>
147                                      #ifdef MAP_ANON
148                                         yes
149                                      #endif],
150                                     ac_cv_map_anon=yes,
151                                     ac_cv_map_anon=no))
152
153         if test $ac_cv_map_failed = yes; then
154                 AC_DEFINE([HAVE_MAP_FAILED], 1, [Define if <sys/mman.h> defines MAP_FAILED])
155         fi
156
157         if test $ac_cv_map_anonymous = yes; then
158                 AC_DEFINE([HAVE_MAP_ANONYMOUS], 1, [Define if <sys/mman.h> defines MAP_ANONYMOUS])
159         fi
160
161         if test $ac_cv_map_anon = yes; then
162                 AC_DEFINE([HAVE_MAP_ANON], 1, [Define if <sys/mman.h> defines MAP_ANON])
163         fi
164 fi
165
166
167 dnl Features
168
169 dnl check arguments
170 AC_ARG_ENABLE([threads], [AS_HELP_STRING(--enable-threads,enable threads support (none,green,native) [[default=native]])])
171 AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--disable-__thread,do not use TLS features even when supporting them)], [use__thread=$enableval], [use__thread=yes])
172
173
174 dnl threads
175 AC_MSG_CHECKING(whether to include threads support)
176 enable_threads=${enable_threads:-native}
177 case "$enable_threads" in
178 no | none | single)
179         AC_MSG_RESULT(no)
180         dnl no threads for boehm
181         ac_configure_args="$ac_configure_args --disable-boehm-threads"
182         AM_CONDITIONAL([USE_THREADS], [false])
183         AM_CONDITIONAL([NATIVE_THREADS], [false])
184         ;;
185
186 green | native | posix | pthreads)
187         AC_DEFINE([USE_THREADS], 1, [use threads])
188         AC_DEFINE([EXTERNAL_OVERFLOW], 1, [external overflow])
189         AC_DEFINE([DONT_FREE_FIRST], 1, [don't free first])
190
191         AM_CONDITIONAL([USE_THREADS], [true])
192
193         if test x"$enable_threads" != "xgreen"; then
194                 AC_MSG_RESULT(yes, native)
195                 AC_CHECK_LIB(pthread, main)
196                 AC_DEFINE([NATIVE_THREADS], 1, [use pthreads])
197
198                 CFLAGS="$CFLAGS -D_REENTRANT"
199
200                 dnl tell boehm to support threads as well and classpath to
201                 dnl synchronize VM threads portably
202                 ac_configure_args="$ac_configure_args --enable-boehm-threads=posix --enable-portable-native-sync"
203                 AM_CONDITIONAL([NATIVE_THREADS], [true])
204
205         else
206                 AC_MSG_RESULT(yes, green)
207
208                 dnl no threads for boehm
209                 ac_configure_args="$ac_configure_args --disable-boehm-threads"
210                 AM_CONDITIONAL([NATIVE_THREADS], [false])
211         fi
212     ;;
213 *)
214     AC_MSG_ERROR($enable_threads is an unknown thread package)
215     ;;
216 esac
217
218
219 dnl Check whether the compiler supports the __thread keyword.
220 if test "x$use__thread" != xno; then
221   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
222   [cat > conftest.c <<\EOF
223 __thread int a = 42;
224 EOF
225   if AC_TRY_COMMAND([${CC-cc} $CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
226     ac_cv_gcc___thread=yes 
227   else
228     ac_cv_gcc___thread=no
229   fi
230   rm -f conftest*])
231   if test "$ac_cv_gcc___thread" = yes; then
232     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
233   fi
234 else
235   ac_cv_gcc___thread=no
236 fi
237
238
239 dnl check if zlib should be used
240 AC_ARG_ENABLE([zlib], [AS_HELP_STRING(--enable-zlib,enable zip archive class storage (needs zlib) [[default=yes]])])
241
242 AC_MSG_CHECKING(whether zip archives should be supported)
243 if test x"$enable_zlib" = "xno"; then
244         AC_MSG_RESULT(no)
245         AM_CONDITIONAL([USE_ZLIB], [false])
246 else
247         AC_MSG_RESULT(yes)
248         AC_DEFINE([USE_ZLIB], 1, [use zlib])
249         AC_CHECK_HEADERS([zlib.h])
250         AC_CHECK_LIB(z, main)
251         AM_CONDITIONAL([USE_ZLIB], [true])
252 fi
253
254
255 dnl set some essential classpath options, even if their classpath default is
256 dnl suitable for us
257 ac_configure_args="$ac_configure_args --enable-jni --disable-cni --disable-regen-headers --enable-static --enable-shared --enable-load-library"
258
259
260 dnl check arguments
261 AC_ARG_ENABLE([gtk-peer], [AS_HELP_STRING(--enable-gtk-peer,compile GTK native peers [[default=no]])])
262
263
264 dnl enable gtk peer
265 AC_MSG_CHECKING(whether to use gtk awt peers)
266 if test x"$enable_gtk_peer" = "xyes"; then
267         AC_MSG_RESULT(yes)
268         AC_DEFINE([USE_GTK], 1, [use gtk])
269         AM_CONDITIONAL([USE_GTK_PEER], [true])
270
271 else
272         AC_MSG_RESULT(no)
273         ac_configure_args="$ac_configure_args --disable-gtk-peer"
274         AM_CONDITIONAL([USE_GTK_PEER], [false])
275 fi
276
277
278 if test "x1" == "x$STATIC_CLASSPATH"; then
279         AC_DEFINE([STATIC_CLASSPATH], 1, [use classpath statically linked])
280         AM_CONDITIONAL([STATIC_CLASSPATH], [true])
281
282 else
283         AM_CONDITIONAL([STATIC_CLASSPATH], [false])
284 fi
285
286
287 dnl now configure boehm gc and gnu classpath
288 dnl the export is not my favorite (is there another way?)
289 export CFLAGS
290 AC_CONFIG_SUBDIRS(src/boehm-gc src/classpath)
291
292
293 AC_OUTPUT(Makefile \
294           doc/Makefile \
295           src/Makefile \
296           src/cacao/Makefile \
297           src/cacaoh/Makefile \
298           src/mm/Makefile \
299           src/native/Makefile \
300           src/native/include/Makefile \
301           src/native/tools/Makefile \
302           src/native/vm/Makefile \
303           src/threads/Makefile \
304           src/threads/green/Makefile \
305           src/threads/native/Makefile \
306           src/toolbox/Makefile \
307           src/vm/Makefile \
308           src/vm/jit/Makefile \
309           src/vm/jit/alpha/Makefile \
310           src/vm/jit/i386/Makefile \
311           src/vm/jit/inline/Makefile \
312           src/vm/jit/loop/Makefile \
313           src/vm/jit/mips/Makefile \
314           src/vm/jit/powerpc/Makefile \
315           src/vm/jit/tools/Makefile \
316           src/vm/jit/verify/Makefile \
317           src/vm/jit/x86_64/Makefile \
318           tests/Makefile \
319           tests/jvm98/Makefile \
320           tests/kaffe/Makefile )
321
322
323 ## Local variables:
324 ## mode: m4
325 ## indent-tabs-mode: t
326 ## c-basic-offset: 4
327 ## tab-width: 8
328 ## compile-command: "automake --add-missing"
329 ## End: