Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / libgc / configure.ac
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      *-*-kfreebsd*-gnu)
118         AC_DEFINE(GC_FREEBSD_THREADS)
119         INCLUDES="$INCLUDES -pthread"
120         THREADDLLIBS=-pthread
121         AC_DEFINE(_REENTRANT)
122         if test "${enable_parallel_mark}" = yes; then
123                 AC_DEFINE(PARALLEL_MARK)
124         fi
125         AC_DEFINE(THREAD_LOCAL_ALLOC)
126         AC_DEFINE(USE_COMPILER_TLS)
127         ;;
128       *-*-freebsd*)
129         AC_DEFINE(GC_FREEBSD_THREADS)
130         if test "x$PTHREAD_CFLAGS" != "x"; then
131                 AM_CPPFLAGS="$AM_CPPFLAGS $PTHREAD_CFLAGS"
132         fi
133         if test "x$PTHREAD_LIBS" = "x"; then
134                 THREADDLLIBS=-pthread
135         else
136                 THREADDLLIBS="$PTHREAD_LIBS"
137         fi
138         AC_DEFINE(THREAD_LOCAL_ALLOC)
139         ;;
140      *-*-solaris*)
141         AC_DEFINE(GC_SOLARIS_THREADS)
142         AC_DEFINE(GC_SOLARIS_PTHREADS)
143         ;;
144      *-*-irix*)
145         AC_DEFINE(GC_IRIX_THREADS)
146         ;;
147      *-*-cygwin*)
148         AC_DEFINE(GC_WIN32_THREADS)
149         ;;
150      *-*-darwin*)
151         AC_DEFINE(GC_DARWIN_THREADS)
152         AC_DEFINE(THREAD_LOCAL_ALLOC)
153         if test "${enable_parallel_mark}" = yes; then
154           AC_DEFINE(PARALLEL_MARK)
155         fi
156         ;;
157      *-*-netbsd*)
158         AC_DEFINE(GC_NETBSD_THREADS)
159         if test "${enable_parallel_mark}" = yes; then
160           AC_DEFINE(PARALLEL_MARK)
161         fi
162         AC_DEFINE(THREAD_LOCAL_ALLOC)
163         ;;
164      *-*-openbsd*)
165         AC_DEFINE(GC_OPENBSD_THREADS)
166         if test "${enable_parallel_mark}" = yes; then
167           AC_DEFINE(PARALLEL_MARK)
168         fi
169         AC_DEFINE(THREAD_LOCAL_ALLOC)
170         ;;
171      *-*-osf*)
172         AC_DEFINE(GC_OSF1_THREADS)
173         if test "${enable_parallel_mark}" = yes; then
174           AC_DEFINE(PARALLEL_MARK)
175           AC_DEFINE(THREAD_LOCAL_ALLOC)
176           # May want to enable it in other cases, too.
177           # Measurements havent yet been done.
178         fi
179         AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
180         THREADDLLIBS="-lpthread -lrt"
181         ;;
182       *)
183         AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
184         ;;
185     esac
186     ;;
187  win32)
188     AC_DEFINE(GC_WIN32_THREADS)
189     dnl Wine getenv may not return NULL for missing entry
190     AC_DEFINE(NO_GETENV)
191         if test "${enable_win32_dllmain}" = yes; then
192            AC_DEFINE(GC_INSIDE_DLL)
193         fi
194     ;;
195  dgux386)
196     THREADS=dgux386
197     AC_MSG_RESULT($THREADDLLIBS)
198     # Use pthread GCC  switch
199     THREADDLLIBS=-pthread
200     if test "${enable_parallel_mark}" = yes; then
201         AC_DEFINE(PARALLEL_MARK)
202     fi
203     AC_DEFINE(THREAD_LOCAL_ALLOC)
204     AC_DEFINE(GC_DGUX386_THREADS)
205     AC_DEFINE(DGUX_THREADS)
206     # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
207     AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
208     ;;
209  aix)
210     THREADS=posix
211     THREADDLLIBS=-lpthread
212     AC_DEFINE(GC_AIX_THREADS)
213     AC_DEFINE(_REENTRANT)
214     ;;
215  decosf1 | irix | mach | os2 | solaris | dce | vxworks)
216     AC_MSG_ERROR(thread package $THREADS not yet supported)
217     ;;
218  *)
219     AC_MSG_ERROR($THREADS is an unknown thread package)
220     ;;
221 esac
222 AC_SUBST(THREADDLLIBS)
223
224 case "$host" in 
225    powerpc-*-darwin*)
226       powerpc_darwin=true
227       ;;
228 esac
229 AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
230
231 # Check if the GCC builtin __sync_bool_compare_and_swap is available.
232 # It is preferred in gc_locks.h for PPC as GCC 4.4 has a problem with the inline assembly there.
233 AC_MSG_CHECKING(for __sync_bool_compare_and_swap)
234 AC_TRY_COMPILE([],[
235 volatile unsigned int foo = 0;
236 unsigned int r1 = __sync_bool_compare_and_swap(&foo, 0, 1);
237 return 0;
238 ], [
239 AC_MSG_RESULT(yes)
240 AC_DEFINE(HAS___SYNC_BOOL_COMPARE_AND_SWAP)
241 ], [
242 AC_MSG_RESULT(no)
243 ])
244
245 AC_MSG_CHECKING(for xlc)
246 AC_TRY_COMPILE([],[
247  #ifndef __xlC__
248  # error
249  #endif
250 ], [compiler_xlc=yes], [compiler_xlc=no])
251 AC_MSG_RESULT($compiler_xlc)
252 AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
253 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
254   # the darwin stack-frame-walking code is completely broken on xlc
255   AC_DEFINE(DARWIN_DONT_PARSE_STACK)
256 fi
257
258 # We never want libdl on darwin. It is a fake libdl that just ends up making
259 # dyld calls anyway
260 case "$host" in
261   *-*-darwin*) ;;
262   *) 
263     AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
264     ;;
265 esac
266
267 AC_SUBST(EXTRA_TEST_LIBS)
268
269 target_all=libgc.la
270 AC_SUBST(target_all)
271
272 dnl If the target is an eCos system, use the appropriate eCos
273 dnl I/O routines.
274 dnl FIXME: this should not be a local option but a global target
275 dnl system; at present there is no eCos target.
276 TARGET_ECOS="no"
277 AC_ARG_WITH(ecos,
278 [  --with-ecos             enable runtime eCos target support],
279 TARGET_ECOS="$with_ecos"
280 )
281
282 addobjs=
283 addlibs=
284 addincludes=
285 addtests=
286 CXXAM_CPPFLAGS=
287 case "$TARGET_ECOS" in
288    no)
289       ;;
290    *)
291       AC_DEFINE(ECOS)
292       CXXINCLUDES="-I${TARGET_ECOS}/include"
293       addobjs="$addobjs ecos.lo"
294       ;;
295 esac
296
297 if test "${enable_cplusplus}" = yes; then
298       addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h"
299       addtests="$addtests test_cpp"
300 fi
301
302 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
303
304 AC_SUBST(CXX)
305
306 AC_SUBST(AM_CPPFLAGS)
307 AC_SUBST(CXXINCLUDES)
308
309 # Configuration of shared libraries
310 #
311 AC_MSG_CHECKING(whether to build shared libraries)
312 AC_ENABLE_SHARED
313
314 case "$host" in
315  alpha-*-openbsd*)
316      enable_shared=no
317      AC_MSG_RESULT(no)
318      ;;
319  *)
320      AC_MSG_RESULT(yes)
321      ;;
322 esac
323
324 # Configuration of machine-dependent code
325 #
326 AC_MSG_CHECKING(which machine-dependent code should be used) 
327 machdep=
328 case "$host" in
329  alpha-*-openbsd*)
330     machdep="alpha_mach_dep.lo"
331     if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
332        AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
333     fi
334     ;;
335  alpha*-*-linux*)
336     machdep="alpha_mach_dep.lo"
337     ;;
338  i?86-*-solaris2.[[89]] | i?86-*-solaris2.1?)
339     AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
340     ;;
341  mipstx39-*-elf*)
342     machdep="mips_ultrix_mach_dep.lo"
343     AC_DEFINE(STACKBASE, __stackbase)
344     AC_DEFINE(DATASTART_IS_ETEXT)
345     ;;
346  mips-dec-ultrix*)
347     machdep="mips_ultrix_mach-dep.lo"
348     ;;
349  mips-nec-sysv*|mips-unknown-sysv*)
350     ;;
351  mips*-*-linux*) 
352     ;; 
353  mips-*-*)
354     machdep="mips_sgi_mach_dep.lo"
355     AC_DEFINE(NO_EXECUTE_PERMISSION)
356     ;;
357  sparc-*-netbsd*)
358     machdep="sparc_netbsd_mach_dep.lo"
359     ;;
360  sparc-sun-solaris2.3)
361     machdep="sparc_mach_dep.lo"
362     AC_DEFINE(SUNOS53_SHARED_LIB)
363     ;;
364  sparc*-sun-solaris2.*)
365     machdep="sparc_mach_dep.lo"
366     ;;
367  ia64-*-*)
368      machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
369         target_ia64=true
370     ;;
371  *-*-nacl*)
372     AC_DEFINE(NO_EXECUTE_PERMISSION)
373     ;;
374 esac
375 if test x"$machdep" = x; then
376 AC_MSG_RESULT($machdep)
377    machdep="mach_dep.lo"
378 fi
379 addobjs="$addobjs $machdep"
380 #
381 # Adding object files directly to _LIBADD breaks -j builds, so we need to add the sources
382 # instead, but _SOURCES can't contain autoconf substitutions, so add them using automake
383 # conditionals.
384 #
385 #AC_SUBST(addobjs)
386 AC_SUBST(addincludes)
387 AC_SUBST(addlibs)
388 AC_SUBST(addtests)
389
390 AM_CONDITIONAL(TARGET_IA64,test x$target_ia64 = xtrue)
391
392 AC_PROG_LIBTOOL
393 # Use dolt (http://dolt.freedesktop.org/) instead of libtool for building.
394 DOLT
395
396 #
397 # Check for AViiON Machines running DGUX
398 #
399 ac_is_dgux=no
400 AC_CHECK_HEADER(sys/dg_sys_info.h,
401 [ac_is_dgux=yes;])
402
403     ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
404 if test $ac_is_dgux = yes; then
405     if test "$enable_full_debug" = "yes"; then
406       CFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
407       CXXFLAGS="-g -mstandard -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
408     else
409       CFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
410       CXXFLAGS="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
411     fi
412     AC_SUBST(CFLAGS)
413     AC_SUBST(CXXFLAGS)
414 fi
415
416 dnl We use these options to decide which functions to include.
417 AC_ARG_WITH(target-subdir,
418 [  --with-target-subdir=SUBDIR
419                           configuring with a cross compiler])
420 AC_ARG_WITH(cross-host,
421 [  --with-cross-host=HOST  configuring with a cross compiler])
422
423 # automake wants to see AC_EXEEXT.  But we don't need it.  And having
424 # it is actually a problem, because the compiler we're passed can't
425 # necessarily do a full link.  So we fool automake here.
426 if false; then
427   # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
428   # to nothing, so nothing would remain between `then' and `fi' if it
429   # were not for the `:' below.
430   :
431   AC_EXEEXT
432 fi
433
434 AC_MSG_CHECKING([for threads package to use])
435 AC_MSG_RESULT($THREADS)
436
437 dnl As of 4.13a2, the collector will not properly work on Solaris when
438 dnl built with gcc and -O.  So we remove -O in the appropriate case.
439 dnl Not needed anymore on Solaris.
440 AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
441 case "$host" in
442  *aix*)
443     if test "$GCC" = yes; then
444        AC_MSG_RESULT(yes)
445        new_CFLAGS=
446        for i in $CFLAGS; do
447           case "$i" in
448            -O*)
449               ;;
450            *)
451               new_CFLAGS="$new_CFLAGS $i"
452               ;;
453           esac
454        done
455        CFLAGS="$new_CFLAGS"
456     else
457        AC_MSG_RESULT(no)
458     fi
459     ;;
460  *) AC_MSG_RESULT(no) ;;
461 esac
462
463 dnl We need to override the top-level CFLAGS.  This is how we do it.
464 MY_CFLAGS="$CFLAGS"
465 AC_SUBST(MY_CFLAGS)
466
467 dnl Include defines that have become de facto standard.
468 dnl ALL_INTERIOR_POINTERS can be overridden in startup code.
469 AC_DEFINE(SILENT)
470 AC_DEFINE(NO_SIGNALS)
471 AC_DEFINE(NO_EXECUTE_PERMISSION)
472 dnl AC_DEFINE(ALL_INTERIOR_POINTERS)
473
474 dnl By default, make the library as general as possible.
475 AC_DEFINE(JAVA_FINALIZATION)
476 AC_DEFINE(GC_GCJ_SUPPORT)
477 AC_DEFINE(ATOMIC_UNCOLLECTABLE)
478
479 dnl This is something of a hack.  When cross-compiling we turn off
480 dnl some functionality.  We also enable the "small" configuration.
481 dnl These is only correct when targetting an embedded system.  FIXME.
482 if test -n "${with_cross_host}"; then
483    AC_DEFINE(NO_SIGSET)
484    AC_DEFINE(NO_CLOCK)
485    AC_DEFINE(SMALL_CONFIG)
486    AC_DEFINE(NO_DEBUGGING)
487 fi
488
489 UNWINDLIBS=
490 AC_ARG_ENABLE(full-debug,
491 [  --enable-full-debug  include full support for pointer backtracing etc.],
492 [ if test "$enable_full_debug" = "yes"; then
493     AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.")
494     AC_DEFINE(KEEP_BACK_PTRS)
495     AC_DEFINE(DBG_HDRS_ALL)
496     case $host in
497       ia64-*-linux* )
498         AC_DEFINE(MAKE_BACK_GRAPH)
499         AC_DEFINE(SAVE_CALL_COUNT, 8)
500         AC_CHECK_LIB(unwind, backtrace, [
501           AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
502           UNWINDLIBS=-lunwind
503           AC_MSG_WARN("Client code may need to link against libunwind.")
504         ])
505       ;;
506       x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
507         AC_DEFINE(MAKE_BACK_GRAPH)
508         AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
509         AC_DEFINE(SAVE_CALL_COUNT, 8)
510       ;;
511       i[3456]86-*-dgux*)
512         AC_DEFINE(MAKE_BACK_GRAPH)
513       ;;
514     esac ]
515   fi)
516
517 AC_SUBST(UNWINDLIBS)
518
519 AC_ARG_ENABLE(redirect-malloc,
520 [  --enable-redirect-malloc  redirect malloc and friends to GC routines])
521
522 if test "${enable_redirect_malloc}" = yes; then
523     if test "${enable_full_debug}" = yes; then
524         AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement)
525         AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement)
526         AC_DEFINE(REDIRECT_FREE, GC_debug_free)
527     else
528         AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
529     fi
530 fi
531
532 AC_DEFINE(_IN_LIBGC)
533
534 AC_ARG_ENABLE(gc-assertions,
535 [  --enable-gc-assertions  collector-internal assertion checking])
536 if test "${enable_gc_assertions}" = yes; then
537     AC_DEFINE(GC_ASSERTIONS)
538 fi
539
540 AC_ARG_ENABLE(quiet-build, [  --enable-quiet-build  Enable quiet libgc build (on by default)], enable_quiet_build=$enableval, enable_quiet_build=yes)
541 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
542
543 AC_ARG_ENABLE(werror, [  --enable-werror Pass -Werror to the C compiler], werror_flag=$enableval, werror_flag=no)
544 if test x$werror_flag = xyes; then
545         WERROR_CFLAGS="-Werror"
546 fi
547 AC_SUBST([WERROR_CFLAGS])
548
549 if test "${multilib}" = "yes"; then
550   multilib_arg="--enable-multilib"
551 else
552   multilib_arg=
553 fi
554
555 AC_OUTPUT(Makefile
556 m4/Makefile
557 include/Makefile
558 include/private/Makefile
559 doc/Makefile,,
560 srcdir=${srcdir}
561 host=${host}
562 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
563 CC="${CC}"
564 DEFS="$DEFS"
565 )