- build/dist/install changes
[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 define install prefix
14 CFLAGS="-DINSTALL_PREFIX=\"\\\"$prefix\\\"\""
15
16 dnl system type
17
18 case "$host_cpu" in
19 alpha* )
20         ARCH_DIR="alpha"
21         STATIC_CLASSPATH="1"
22         CFLAGS="-mieee -D__ALPHA__"
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         ;;
37
38 powerpc* | ppc* )
39         ARCH_DIR="powerpc"
40         STATIC_CLASSPATH="1"
41         CFLAGS="-D__POWERPC__"
42         ;;
43
44 x86_64* )
45         ARCH_DIR="x86_64"
46         STATIC_CLASSPATH="1"
47         CFLAGS="$CFLAGS -D__X86_64__"
48         ;;
49
50 sparc* | * )
51         AC_MSG_ERROR($host_cpu systems are not supported at this time)
52         ;;
53 esac
54
55 case "$host_os" in
56 *linux* | *Linux* )
57         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"
58         ;;
59 *darwin* )
60         CFLAGS="-ansi -pedantic -Wall -Wno-long-long -O0 -g3 $CFLAGS -D__DARWIN__"
61         ;;
62 *irix* )
63         CFLAGS="$CFLAGS -D__IRIX__"
64         ;;
65 * )
66         ;;
67 esac
68
69
70 AC_DEFINE_UNQUOTED([ARCH_DIR], "$ARCH_DIR", [Architecture directory])
71 AC_SUBST(ARCH_DIR)
72
73 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])
74 dnl force static classpath linking ??
75 AC_MSG_CHECKING(Link classpath static)
76 if test "xno" == "x$use_dynamicclasspath"; then
77   STATIC_CLASSPATH="1"
78 fi
79
80 if test "$STATIC_CLASSPATH" == "1"; then
81         AC_MSG_RESULT(yes)
82 else
83         AC_MSG_RESULT(no)
84 fi
85 AC_SUBST(STATIC_CLASSPATH)
86
87 dnl Checks for programs.
88 AC_PROG_CC
89 AM_PROG_AS
90 AC_PROG_RANLIB
91 AC_PROG_MAKE_SET
92
93 dnl Checks for header files.
94 AC_HEADER_DIRENT
95 AC_HEADER_STDC
96 AC_CHECK_HEADERS([fcntl.h])
97 AC_CHECK_HEADERS([sys/time.h])
98 AC_CHECK_HEADERS([unistd.h])
99 AC_CHECK_HEADERS([sys/ioctl.h])
100
101 dnl Checks for typedefs, structures, and compiler characteristics.
102 AC_C_CONST
103 AC_C_INLINE
104 AC_TYPE_OFF_T
105 AC_TYPE_SIZE_T
106 AC_HEADER_TIME
107 AC_STRUCT_TM
108
109 dnl Checks for library functions.
110 AC_PROG_GCC_TRADITIONAL
111 AC_FUNC_MEMCMP
112 AC_FUNC_MMAP
113 AC_TYPE_SIGNAL
114 AC_CHECK_FUNCS(getcwd gettimeofday mkdir mktime select socket)
115
116 dnl Checks for libraries.
117 AC_CHECK_LIB(m, fmod)
118
119 dnl Check for mmap header anomalies (missing MAP_FAILED, etc.)
120 if test $ac_cv_func_mmap_fixed_mapped = yes; then
121         AC_CACHE_CHECK(whether MAP_FAILED is defined,
122                        ac_cv_map_failed,
123                        AC_EGREP_CPP(yes, 
124                                     [#include <sys/mman.h>
125                                      #ifdef MAP_FAILED
126                                         yes
127                                      #endif],
128                                     ac_cv_map_failed=yes,
129                                     ac_cv_map_failed=no))
130
131         AC_CACHE_CHECK(whether MAP_ANONYMOUS is defined,
132                        ac_cv_map_anonymous,
133                        AC_EGREP_CPP(yes, 
134                                     [#include <sys/mman.h>
135                                      #ifdef MAP_ANONYMOUS
136                                         yes
137                                      #endif],
138                                     ac_cv_map_anonymous=yes,
139                                     ac_cv_map_anonymous=no))
140
141         AC_CACHE_CHECK(whether MAP_ANON is defined,
142                        ac_cv_map_anon,
143                        AC_EGREP_CPP(yes, 
144                                     [#include <sys/mman.h>
145                                      #ifdef MAP_ANON
146                                         yes
147                                      #endif],
148                                     ac_cv_map_anon=yes,
149                                     ac_cv_map_anon=no))
150
151         if test $ac_cv_map_failed = yes; then
152                 AC_DEFINE([HAVE_MAP_FAILED], 1, [Define if <sys/mman.h> defines MAP_FAILED])
153         fi
154
155         if test $ac_cv_map_anonymous = yes; then
156                 AC_DEFINE([HAVE_MAP_ANONYMOUS], 1, [Define if <sys/mman.h> defines MAP_ANONYMOUS])
157         fi
158
159         if test $ac_cv_map_anon = yes; then
160                 AC_DEFINE([HAVE_MAP_ANON], 1, [Define if <sys/mman.h> defines MAP_ANON])
161         fi
162 fi
163
164
165 dnl Features
166
167 dnl check arguments
168 AC_ARG_ENABLE([threads], [AS_HELP_STRING(--enable-threads,enable threads support (none,green,native) [[default=native]])])
169 AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--disable-__thread,do not use TLS features even when supporting them)], [use__thread=$enableval], [use__thread=yes])
170
171
172 dnl threads
173 AC_MSG_CHECKING(whether to include threads support)
174 enable_threads=${enable_threads:-native}
175 case "$enable_threads" in
176 no | none | single)
177         AC_MSG_RESULT(no)
178         dnl no threads for boehm
179         ac_configure_args="$ac_configure_args --disable-boehm-threads"
180         AM_CONDITIONAL([USE_THREADS], [false])
181         AM_CONDITIONAL([NATIVE_THREADS], [false])
182         ;;
183
184 green | native | posix | pthreads)
185         AC_DEFINE([USE_THREADS], 1, [use threads])
186         AC_DEFINE([EXTERNAL_OVERFLOW], 1, [external overflow])
187         AC_DEFINE([DONT_FREE_FIRST], 1, [don't free first])
188
189         AM_CONDITIONAL([USE_THREADS], [true])
190
191         if test x"$enable_threads" != "xgreen"; then
192                 AC_MSG_RESULT(yes, native)
193                 AC_CHECK_LIB(pthread, main)
194                 AC_DEFINE([NATIVE_THREADS], 1, [use pthreads])
195
196                 CFLAGS="$CFLAGS -D_REENTRANT"
197
198                 dnl tell boehm to support threads as well and classpath to
199                 dnl synchronize VM threads portably
200                 ac_configure_args="$ac_configure_args --enable-boehm-threads=posix --enable-portable-native-sync"
201                 AM_CONDITIONAL([NATIVE_THREADS], [true])
202
203         else
204                 AC_MSG_RESULT(yes, green)
205
206                 dnl no threads for boehm
207                 ac_configure_args="$ac_configure_args --disable-boehm-threads"
208                 AM_CONDITIONAL([NATIVE_THREADS], [false])
209         fi
210     ;;
211 *)
212     AC_MSG_ERROR($enable_threads is an unknown thread package)
213     ;;
214 esac
215
216
217 dnl Check whether the compiler supports the __thread keyword.
218 if test "x$use__thread" != xno; then
219   AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
220   [cat > conftest.c <<\EOF
221 __thread int a = 42;
222 EOF
223   if AC_TRY_COMMAND([${CC-cc} $CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
224     ac_cv_gcc___thread=yes 
225   else
226     ac_cv_gcc___thread=no
227   fi
228   rm -f conftest*])
229   if test "$ac_cv_gcc___thread" = yes; then
230     AC_DEFINE([HAVE___THREAD], 1, [have __thread])
231   fi
232 else
233   ac_cv_gcc___thread=no
234 fi
235
236
237 dnl check if zlib should be used
238 AC_ARG_ENABLE([zlib], [AS_HELP_STRING(--enable-zlib,enable zip archive class storage (needs zlib) [[default=yes]])])
239
240 AC_MSG_CHECKING(whether zip archives should be supported)
241 if test x"$enable_zlib" = "xno"; then
242         AC_MSG_RESULT(no)
243         AM_CONDITIONAL([USE_ZLIB], [false])
244 else
245         AC_MSG_RESULT(yes)
246         AC_DEFINE([USE_ZLIB], 1, [use zlib])
247         AC_CHECK_HEADERS([zlib.h])
248         AC_CHECK_LIB(z, main)
249         AM_CONDITIONAL([USE_ZLIB], [true])
250 fi
251
252
253 dnl check arguments
254 AC_ARG_ENABLE([gtk-peer], [AS_HELP_STRING(--enable-gtk-peer,compile GTK native peers [[default=no]])])
255
256
257 dnl enable gtk peer
258 AC_MSG_CHECKING(whether to use gtk awt peers)
259 if test x"$enable_gtk_peer" = "xyes"; then
260         AC_MSG_RESULT(yes)
261         AC_DEFINE([USE_GTK], 1, [use gtk])
262         AM_CONDITIONAL([USE_GTK_PEER], [true])
263
264 else
265         AC_MSG_RESULT(no)
266         ac_configure_args="$ac_configure_args --disable-gtk-peer"
267         AM_CONDITIONAL([USE_GTK_PEER], [false])
268 fi
269
270
271 if test "x1" == "x$STATIC_CLASSPATH"; then
272         AC_DEFINE([STATIC_CLASSPATH], 1, [use classpath statically linked])
273         AM_CONDITIONAL([STATIC_CLASSPATH], [true])
274
275 else
276         AM_CONDITIONAL([STATIC_CLASSPATH], [false])
277 fi
278
279
280 dnl set some essential classpath options, even if their classpath default is
281 dnl suitable for us
282 ac_configure_args="$ac_configure_args --enable-jni --disable-cni --disable-regen-headers --enable-static --enable-shared --enable-load-library"
283
284
285 dnl now configure boehm gc and gnu classpath
286 dnl the export is not my favorite (is there another way?)
287 export CFLAGS
288 AC_CONFIG_SUBDIRS(src/boehm-gc src/classpath)
289
290
291 AC_OUTPUT(Makefile \
292           doc/Makefile \
293           doc/handbook/Makefile \
294           man/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: