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