1 # based on configure.in/Makefile.am, which is:
3 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
5 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 # OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
8 # Permission is hereby granted to use or copy this program
9 # for any purpose, provided the above notices are retained on all copies.
10 # Permission to modify the code and to distribute modified code is granted,
11 # provided the above notices are retained, and a notice that the code was
12 # modified is included with the above copyright notice.
14 # Original author: Tom Tromey
15 # Modified by: Grzegorz Jakacki <jakacki at acm dot org>
17 # This is in sync with the configure.in/Makefile.am at r135583
20 # This is a cmake build file for libgc
21 # Only the functionality needed by mono is supported
25 add_definitions("-g -O2")
27 set(THREADS ${libgc_threads})
31 if (THREADS STREQUAL "no" OR THREADS STREQUAL "none" OR THREADS STREQUAL "single")
35 if (THREADS STREQUAL "posix" OR THREADS STREQUAL "pthreads")
37 set(THREADDLLIBS "-lpthread")
38 if (${host} MATCHES "x86-.*-linux.*|ia64-.*-linux.*|i386-.*-linux.*|i486-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86_64-.*-linux.*|alpha.*-.*-linux.*|s390.*-.*-linux.*|sparc.*-.*-linux.*|powerpc-.*-linux.*")
39 add_definitions(-DGC_LINUX_THREADS -D_REENTRANT)
40 set(parallel_mark_supported yes)
41 add_definitions(-DTHREAD_LOCAL_ALLOC)
42 elseif(${host} MATCHES ".*-linux.*")
43 add_definitions(-DGC_LINUX_THREADS -D_REENTRANT)
44 elseif(${host} MATCHES ".*-aix.*")
45 add_definitions(-DGC_AIX_THREADS -D_REENTRANT)
46 elseif(${host} MATCHES ".*-hpux.*")
47 message("Only HP/UX 11 threads are supported.")
48 add_definitions(-DGC_HPUX_THREADS -D_REENTRANT -D_POSIX_C_SOURCE=199506L)
49 add_definitions(-DTHREAD_LOCAL_ALLOC)
50 set(parallel_mark_supported yes)
51 set(THREADDLLIBS "-lpthread -lrt")
52 elseif(${host} ".*-.*-freebsd.*")
53 add_definitions(-DGC_FREEBSD_THREADS)
54 message(FATAL_ERROR "todo")
55 ### if test "x$PTHREAD_CFLAGS" != "x"; then
56 ### INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
58 ### if test "x$PTHREAD_LIBS" = "x"; then
59 ### THREADDLLIBS=-pthread
61 ### THREADDLLIBS="$PTHREAD_LIBS"
63 elseif(${host} ".*-.*-freebsd.*")
64 add_definitions(-DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS)
65 elseif(${host} ".*-.*-irix.*")
66 add_definitions(-DGC_IRIX_THREADS)
67 elseif(${host} ".*-.*-cygwin.*")
68 add_definitons(-DGC_WIN32_THREADS)
69 elseif(${host} ".*-.*-darwin.*")
70 add_definitons(-DGC_DARWIN_THREADS -DTHREAD_LOCAL_ALLOC)
71 set(parallel_mark_supported yes)
72 elseif(${host} ".*-.*-netbsd.*")
73 add_definitions(-DGC_NETBSD_THREADS -DTHREAD_LOCAL_ALLOC)
74 set(parallel_mark_supported yes)
75 elseif(${host} ".*-.*-osf.*")
76 add_definitions(GC_OSF1_THREADS -DTHREAD_LOCAL_ALLOC)
77 set(parallel_mark_supported yes)
78 add_definitions(-pthread)
79 set(THREADDLLIBS "-lpthread -lrt")
81 message(FATAL_ERROR "Pthreads not supported by the GC on this platform.")
85 if(THREADS STREQUAL "win32")
86 add_definitions(GC_WIN32_THREADS)
87 # Wine getenv may not return NULL for missing entry
88 add_definitions(NO_GETENV)
89 if (enable_win32_dllmain)
90 add_definitions(gc_inside_dll)
94 if(${host} MATCHES "powerpc-.*-darwin.*")
95 set(powerpc_darwin yes)
98 if(parallel_mark_supported AND enable_parallel_mark)
99 add_definitions("-DPARALLEL_MARK")
102 # Configuration of machine-dependent code
104 ac_msg_checking("which machine-dependent code should be used")
109 ### alpha-*-openbsd*)
110 ### machdep="alpha_mach_dep.lo"
111 ### if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
112 ### AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled)
116 ### machdep="alpha_mach_dep.lo"
118 ### i?86-*-solaris2.[[89]]|i?86-*-solaris2.1?)
119 ### AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
122 ### machdep="mips_ultrix_mach_dep.lo"
123 ### AC_DEFINE(STACKBASE, __stackbase)
124 ### AC_DEFINE(DATASTART_IS_ETEXT)
126 ### mips-dec-ultrix*)
127 ### machdep="mips_ultrix_mach-dep.lo"
129 ### mips-nec-sysv*|mips-unknown-sysv*)
134 ### machdep="mips_sgi_mach_dep.lo"
135 ### AC_DEFINE(NO_EXECUTE_PERMISSION)
138 ### machdep="sparc_netbsd_mach_dep.lo"
140 ### sparc-sun-solaris2.3)
141 ### machdep="sparc_mach_dep.lo"
142 ### AC_DEFINE(SUNOS53_SHARED_LIB)
144 ### sparc*-sun-solaris2.*)
145 ### machdep="sparc_mach_dep.lo"
148 ### machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
152 set(machdep "mach_dep.c")
154 ac_msg_result("${machdep}")
156 ac_msg_checking("for threads package to use")
157 ac_msg_result("${THREADS}")
159 # Include defines that have become de facto standard.
160 # ALL_INTERIOR_POINTERS can be overridden in startup code.
161 add_definitions(-DSILENT -DNO_SIGNALS -DNO_EXECUTE_PERMISSION)
162 # AC_DEFINE(ALL_INTERIOR_POINTERS)
164 # By default, make the library as general as possible.
165 add_definitions(-DJAVA_FINALIZATION -DGC_GCJ_SUPPORT -DATOMIC_UNCOLLECTABLE)
167 add_definitions(-D_IN_LIBGC)
169 set(SUBDIRS include doc)
171 foreach(dir ${SUBDIRS})
172 add_subdirectory(${dir})
177 # .. is needed for mono/utils/mono-compiler.h
178 INCLUDE_DIRECTORIES(. .. include)
179 add_definitions(${CPPFLAGS})
182 set(asm_libgc_sources powerpc_darwin_mach_dep.s)
185 set(libmonogc_la_SOURCES
186 allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c
187 dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c
188 malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c
189 obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c
190 solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c
191 backgraph.c win32_threads.c
192 pthread_support.c pthread_stop_world.c darwin_stop_world.c
193 ${asm_libgc_sources} ${machdep})
195 add_library(monogc-static STATIC ${libmonogc_la_SOURCES})
196 target_link_libraries (${THREADDLLIBS} ${UNWINDLIBS})