Merge pull request #484 from roji/transactions_pspe
[mono.git] / libgc / configure.in
1 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
2
3 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
4 # OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
5
6 # Permission is hereby granted to use or copy this program
7 # for any purpose,  provided the above notices are retained on all copies.
8 # Permission to modify the code and to distribute modified code is granted,
9 # provided the above notices are retained, and a notice that the code was
10 # modified is included with the above copyright notice.
11 #
12 # Original author: Tom Tromey
13 # Modified by: Grzegorz Jakacki <jakacki at acm dot org>
14
15 dnl Process this file with autoconf to produce configure.
16
17 AC_PREREQ([2.53])
18 AC_INIT([libgc-mono], [6.6], [Hans_Boehm@hp.com])
19
20 AM_INIT_AUTOMAKE([1.9 no-define foreign])
21 AC_CONFIG_SRCDIR(gcj_mlc.c)
22 AC_CONFIG_MACRO_DIR([m4])
23 AC_CANONICAL_HOST
24
25 AC_SUBST(PACKAGE)
26 AC_SUBST(GC_VERSION)
27
28 AC_PROG_CC
29 AC_PROG_CXX
30
31 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
32
33 dnl automake 1.6 and later need the AM_PROG_AS macro.
34 ifdef([AM_PROG_AS],[AM_PROG_AS],[])
35 AC_CHECK_TOOL(AR, ar)
36 AC_CHECK_TOOL(RANLIB, ranlib, :)  # :)
37
38 AC_PROG_INSTALL
39
40 AM_MAINTAINER_MODE
41
42 . [$]{srcdir}/configure.host
43
44 # We use a separate variable to pass down CPPFLAGS and CFLAGS from the main mono 
45 # configure, because of autoconf brokeness
46 if test "x$CPPFLAGS_FOR_LIBGC" != "x"; then
47    CPPFLAGS=$CPPFLAGS_FOR_LIBGC
48 fi
49 if test "x$CFLAGS_FOR_LIBGC" != "x"; then
50    CFLAGS=$CFLAGS_FOR_LIBGC
51 fi
52
53 GC_CFLAGS=${gc_cflags}
54 AC_SUBST(GC_CFLAGS)
55
56 case $enable_embed_check in
57 no) ;;
58 *) AC_MSG_ERROR([This module is now part of 'mono' and cannot be built as a stand-alone module any longer.]) ;;
59 esac
60
61 THREADS=$with_libgc_threads
62
63 AC_ARG_ENABLE(win32-dllmain,
64 [  --enable-win32-dllmain    Define the DllMain function in win32_threads.c even if the collector is not built as a dll],
65 )
66
67 AC_ARG_ENABLE(parallel-mark,
68 [  --enable-parallel-mark       parallelize marking and free list construction],
69    [case "$THREADS" in
70       no | none | single)
71         AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
72         ;;
73     esac]
74 )
75
76 AC_ARG_ENABLE(cplusplus,
77 [  --enable-cplusplus           install C++ support],
78 )
79
80 AM_CPPFLAGS=-I${srcdir}/include
81 THREADDLLIBS=
82 ## Libraries needed to support dynamic loading and/or threads.
83 case "$THREADS" in
84  no | none | single)
85     THREADS=none
86     ;;
87  posix | pthreads)
88     THREADS=posix
89     AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
90     case "$host" in
91      x86-*-linux* | ia64-*-linux* | i386-*-linux* | i486-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha*-*-linux* | s390*-*-linux* | sparc*-*-linux* | powerpc-*-linux*)
92         AC_DEFINE(GC_LINUX_THREADS)
93         AC_DEFINE(_REENTRANT)
94         if test "${enable_parallel_mark}" = yes; then
95           AC_DEFINE(PARALLEL_MARK)
96         fi
97         AC_DEFINE(THREAD_LOCAL_ALLOC)
98         ;;
99      *-*-linux* | *-*-nacl*)
100         AC_DEFINE(GC_LINUX_THREADS)
101         AC_DEFINE(_REENTRANT)
102         ;;
103      *-*-aix*)
104         AC_DEFINE(GC_AIX_THREADS)
105         AC_DEFINE(_REENTRANT)
106         ;;
107      *-*-hpux*)
108         AC_MSG_WARN("Only HP/UX 11 threads are supported.")
109         AC_DEFINE(GC_HPUX_THREADS)
110         AC_DEFINE(_POSIX_C_SOURCE,199506L)
111         if test "${enable_parallel_mark}" = yes; then
112           AC_DEFINE(PARALLEL_MARK)
113         fi
114         AC_DEFINE(THREAD_LOCAL_ALLOC)
115         THREADDLLIBS="-lpthread -lrt"
116         ;;
117       *-*-freebsd*)
118         AC_DEFINE(GC_FREEBSD_THREADS)
119         if test "x$PTHREAD_CFLAGS" != "x"; then
120                 AM_CPPFLAGS="$AM_CPPFLAGS $PTHREAD_CFLAGS"
121         fi
122         if test "x$PTHREAD_LIBS" = "x"; then
123                 THREADDLLIBS=-pthread
124         else
125                 THREADDLLIBS="$PTHREAD_LIBS"
126         fi
127         AC_DEFINE(THREAD_LOCAL_ALLOC)
128         ;;
129      *-*-solaris*)
130         AC_DEFINE(GC_SOLARIS_THREADS)
131         AC_DEFINE(GC_SOLARIS_PTHREADS)
132         ;;
133      *-*-irix*)
134         AC_DEFINE(GC_IRIX_THREADS)
135         ;;
136      *-*-cygwin*)
137         AC_DEFINE(GC_WIN32_THREADS)
138         ;;
139      *-*-darwin*)
140         AC_DEFINE(GC_DARWIN_THREADS)
141         AC_DEFINE(THREAD_LOCAL_ALLOC)
142         if test "${enable_parallel_mark}" = yes; then
143           AC_DEFINE(PARALLEL_MARK)
144         fi
145         ;;
146      *-*-netbsd*)
147         AC_DEFINE(GC_NETBSD_THREADS)
148         if test "${enable_parallel_mark}" = yes; then
149           AC_DEFINE(PARALLEL_MARK)
150         fi
151         AC_DEFINE(THREAD_LOCAL_ALLOC)
152         ;;
153      *-*-openbsd*)
154         AC_DEFINE(GC_OPENBSD_THREADS)
155         if test "${enable_parallel_mark}" = yes; then
156           AC_DEFINE(PARALLEL_MARK)
157         fi
158         AC_DEFINE(THREAD_LOCAL_ALLOC)
159         ;;
160      *-*-osf*)
161         AC_DEFINE(GC_OSF1_THREADS)
162         if test "${enable_parallel_mark}" = yes; then
163           AC_DEFINE(PARALLEL_MARK)
164           AC_DEFINE(THREAD_LOCAL_ALLOC)
165           # May want to enable it in other cases, too.
166           # Measurements havent yet been done.
167         fi
168         AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
169         THREADDLLIBS="-lpthread -lrt"
170         ;;
171       *)
172         AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
173         ;;
174     esac
175     ;;
176  win32)
177     AC_DEFINE(GC_WIN32_THREADS)
178     dnl Wine getenv may not return NULL for missing entry
179     AC_DEFINE(NO_GETENV)
180         if test "${enable_win32_dllmain}" = yes; then
181            AC_DEFINE(GC_INSIDE_DLL)
182         fi
183     ;;
184  dgux386)
185     THREADS=dgux386
186     AC_MSG_RESULT($THREADDLLIBS)
187     # Use pthread GCC  switch
188     THREADDLLIBS=-pthread
189     if test "${enable_parallel_mark}" = yes; then
190         AC_DEFINE(PARALLEL_MARK)
191     fi
192     AC_DEFINE(THREAD_LOCAL_ALLOC)
193     AC_DEFINE(GC_DGUX386_THREADS)
194     AC_DEFINE(DGUX_THREADS)
195     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
196     AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
197     ;;
198  aix)
199     THREADS=posix
200     THREADDLLIBS=-lpthread
201     AC_DEFINE(GC_AIX_THREADS)
202     AC_DEFINE(_REENTRANT)
203     ;;
204  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
205     AC_MSG_ERROR(thread package $THREADS not yet supported)
206     ;;
207  *)
208     AC_MSG_ERROR($THREADS is an unknown thread package)
209     ;;
210 esac
211 AC_SUBST(THREADDLLIBS)
212
213 case "$host" in 
214    powerpc-*-darwin*)
215       powerpc_darwin=true
216       ;;
217 esac
218 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
219
220 AC_MSG_CHECKING(for xlc)
221 AC_TRY_COMPILE([],[
222  #ifndef __xlC__
223  # error
224  #endif
225 ], [compiler_xlc=yes], [compiler_xlc=no])
226 AC_MSG_RESULT($compiler_xlc)
227 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
228 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
229   # the darwin stack-frame-walking code is completely broken on xlc
230   AC_DEFINE(DARWIN_DONT_PARSE_STACK)
231 fi
232
233 # We never want libdl on darwin. It is a fake libdl that just ends up making
234 # dyld calls anyway
235 case "$host" in
236   *-*-darwin*) ;;
237   *) 
238     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
239     ;;
240 esac
241
242 AC_SUBST(EXTRA_TEST_LIBS)
243
244 target_all=libgc.la
245 AC_SUBST(target_all)
246
247 dnl If the target is an eCos system, use the appropriate eCos
248 dnl I/O routines.
249 dnl FIXME: this should not be a local option but a global target
250 dnl system; at present there is no eCos target.
251 TARGET_ECOS="no"
252 AC_ARG_WITH(ecos,
253 [  --with-ecos             enable runtime eCos target support],
254 TARGET_ECOS="$with_ecos"
255 )
256
257 addobjs=
258 addlibs=
259 addincludes=
260 addtests=
261 CXXAM_CPPFLAGS=
262 case "$TARGET_ECOS" in
263    no)
264       ;;
265    *)
266       AC_DEFINE(ECOS)
267       CXXINCLUDES="-I${TARGET_ECOS}/include"
268       addobjs="$addobjs ecos.lo"
269       ;;
270 esac
271
272 if test "${enable_cplusplus}" = yes; then
273       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
274       addtests="$addtests test_cpp"
275 fi
276
277 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
278
279 AC_SUBST(CXX)
280
281 AC_SUBST(AM_CPPFLAGS)
282 AC_SUBST(CXXINCLUDES)
283
284 # Configuration of shared libraries
285 #
286 AC_MSG_CHECKING(whether to build shared libraries)
287 AC_ENABLE_SHARED
288
289 case "$host" in
290  alpha-*-openbsd*)
291      enable_shared=no
292      AC_MSG_RESULT(no)
293      ;;
294  *)
295      AC_MSG_RESULT(yes)
296      ;;
297 esac
298
299 # Configuration of machine-dependent code
300 #
301 AC_MSG_CHECKING(which machine-dependent code should be used) 
302 machdep=
303 case "$host" in
304  alpha-*-openbsd*)
305     machdep="alpha_mach_dep.lo"
306     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
307        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
308     fi
309     ;;
310  alpha*-*-linux*)
311     machdep="alpha_mach_dep.lo"
312     ;;
313  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
314     AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
315     ;;
316  mipstx39-*-elf*)
317     machdep="mips_ultrix_mach_dep.lo"
318     AC_DEFINE(STACKBASE, __stackbase)
319     AC_DEFINE(DATASTART_IS_ETEXT)
320     ;;
321  mips-dec-ultrix*)
322     machdep="mips_ultrix_mach-dep.lo"
323     ;;
324  mips-nec-sysv*|mips-unknown-sysv*)
325     ;;
326  mips*-*-linux*) 
327     ;; 
328  mips-*-*)
329     machdep="mips_sgi_mach_dep.lo"
330     AC_DEFINE(NO_EXECUTE_PERMISSION)
331     ;;
332  sparc-*-netbsd*)
333     machdep="sparc_netbsd_mach_dep.lo"
334     ;;
335  sparc-sun-solaris2.3)
336     machdep="sparc_mach_dep.lo"
337     AC_DEFINE(SUNOS53_SHARED_LIB)
338     ;;
339  sparc*-sun-solaris2.*)
340     machdep="sparc_mach_dep.lo"
341     ;;
342  ia64-*-*)
343      machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
344         target_ia64=true
345     ;;
346  *-*-nacl*)
347     AC_DEFINE(NO_EXECUTE_PERMISSION)
348     ;;
349 esac
350 if test x"$machdep" = x; then
351 AC_MSG_RESULT($machdep)
352    machdep="mach_dep.lo"
353 fi
354 addobjs="$addobjs $machdep"
355 #
356 # Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
357 # instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
358 # conditionals.
359 #
360 #AC_SUBST(addobjs)
361 AC_SUBST(addincludes)
362 AC_SUBST(addlibs)
363 AC_SUBST(addtests)
364
365 AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
366
367 AC_PROG_LIBTOOL
368 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
369 DOLT
370
371 #
372 # Check for AViiON Machines running DGUX
373 #
374 ac_is_dgux=no
375 AC_CHECK_HEADER(sys/dg_sys_info.h,
376 [ac_is_dgux=yes;])
377
378     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
379 if test $ac_is_dgux = yes; then
380     if test "$enable_full_debug" = "yes"; then
381       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
382       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
383     else
384       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
385       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
386     fi
387     AC_SUBST(CFLAGS)
388     AC_SUBST(CXXFLAGS)
389 fi
390
391 dnl We use these options to decide which functions to include.
392 AC_ARG_WITH(target-subdir,
393 [  --with-target-subdir=SUBDIR
394                           configuring with a cross compiler])
395 AC_ARG_WITH(cross-host,
396 [  --with-cross-host=HOST  configuring with a cross compiler])
397
398 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
399 # it is actually a problem, because the compiler we're passed can't
400 # necessarily do a full link.  So we fool automake here.
401 if false; then
402   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
403   # to nothing, so nothing would remain between `then' and `fi' if it
404   # were not for the `:' below.
405   :
406   AC_EXEEXT
407 fi
408
409 AC_MSG_CHECKING([for threads package to use])
410 AC_MSG_RESULT($THREADS)
411
412 dnl As of 4.13a2, the collector will not properly work on Solaris when
413 dnl built with gcc and -O.  So we remove -O in the appropriate case.
414 dnl Not needed anymore on Solaris.
415 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
416 case "$host" in
417  *aix*)
418     if test "$GCC" = yes; then
419        AC_MSG_RESULT(yes)
420        new_CFLAGS=
421        for i in $CFLAGS; do
422           case "$i" in
423            -O*)
424               ;;
425            *)
426               new_CFLAGS="$new_CFLAGS $i"
427               ;;
428           esac
429        done
430        CFLAGS="$new_CFLAGS"
431     else
432        AC_MSG_RESULT(no)
433     fi
434     ;;
435  *) AC_MSG_RESULT(no) ;;
436 esac
437
438 dnl We need to override the top-level CFLAGS.  This is how we do it.
439 MY_CFLAGS="$CFLAGS"
440 AC_SUBST(MY_CFLAGS)
441
442 dnl Include defines that have become de facto standard.
443 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
444 AC_DEFINE(SILENT)
445 AC_DEFINE(NO_SIGNALS)
446 AC_DEFINE(NO_EXECUTE_PERMISSION)
447 dnl AC_DEFINE(ALL_INTERIOR_POINTERS)
448
449 dnl By default, make the library as general as possible.
450 AC_DEFINE(JAVA_FINALIZATION)
451 AC_DEFINE(GC_GCJ_SUPPORT)
452 AC_DEFINE(ATOMIC_UNCOLLECTABLE)
453
454 dnl This is something of a hack.  When cross-compiling we turn off
455 dnl some functionality.  We also enable the "small" configuration.
456 dnl These is only correct when targetting an embedded system.  FIXME.
457 if test -n "${with_cross_host}"; then
458    AC_DEFINE(NO_SIGSET)
459    AC_DEFINE(NO_CLOCK)
460    AC_DEFINE(SMALL_CONFIG)
461    AC_DEFINE(NO_DEBUGGING)
462 fi
463
464 UNWINDLIBS=
465 AC_ARG_ENABLE(full-debug,
466 [  --enable-full-debug  include full support for pointer backtracing etc.],
467 [ if test "$enable_full_debug" = "yes"; then
468     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
469     AC_DEFINE(KEEP_BACK_PTRS)
470     AC_DEFINE(DBG_HDRS_ALL)
471     case $host in
472       ia64-*-linux* )
473         AC_DEFINE(MAKE_BACK_GRAPH)
474         AC_DEFINE(SAVE_CALL_COUNT, 8)
475         AC_CHECK_LIB(unwind, backtrace, [
476           AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
477           UNWINDLIBS=-lunwind
478           AC_MSG_WARN("Client code may need to link against libunwind.")
479         ])
480       ;;
481       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
482         AC_DEFINE(MAKE_BACK_GRAPH)
483         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
484         AC_DEFINE(SAVE_CALL_COUNT, 8)
485       ;;
486       i[3456]86-*-dgux*)
487         AC_DEFINE(MAKE_BACK_GRAPH)
488       ;;
489     esac ]
490   fi)
491
492 AC_SUBST(UNWINDLIBS)
493
494 AC_ARG_ENABLE(redirect-malloc,
495 [  --enable-redirect-malloc  redirect malloc and friends to GC routines])
496
497 if test "${enable_redirect_malloc}" = yes; then
498     if test "${enable_full_debug}" = yes; then
499         AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement)
500         AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement)
501         AC_DEFINE(REDIRECT_FREE, GC_debug_free)
502     else
503         AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
504     fi
505 fi
506
507 AC_DEFINE(_IN_LIBGC)
508
509 AC_ARG_ENABLE(gc-assertions,
510 [  --enable-gc-assertions  collector-internal assertion checking])
511 if test "${enable_gc_assertions}" = yes; then
512     AC_DEFINE(GC_ASSERTIONS)
513 fi
514
515 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet libgc build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
516 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
517
518 if test "${multilib}" = "yes"; then
519   multilib_arg="--enable-multilib"
520 else
521   multilib_arg=
522 fi
523
524 AC_OUTPUT(Makefile
525 m4/Makefile
526 include/Makefile
527 include/private/Makefile
528 doc/Makefile,,
529 srcdir=${srcdir}
530 host=${host}
531 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
532 CC="${CC}"
533 DEFS="$DEFS"
534 )