d0a0a718bad6901c42eeaeeade19b948fa65341c
[mono.git] / libgc / CMakeLists.txt
1 # based on configure.in/Makefile.am, which is:
2
3 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
4
5 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 # OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
7
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.
13 #
14 # Original author: Tom Tromey
15 # Modified by: Grzegorz Jakacki <jakacki at acm dot org>
16
17 # This is in sync with the configure.in/Makefile.am at r135583
18
19 #
20 # This is a cmake build file for libgc
21 # Only the functionality needed by mono is supported
22 #
23
24 # FIXME:
25 add_definitions("-g -O2")
26
27 set(THREADS ${libgc_threads})
28
29 set(THREADDLLIBS "")
30
31 if (THREADS STREQUAL "no" OR THREADS STREQUAL "none" OR THREADS STREQUAL "single")
32   set(THREADS none)
33 endif()
34
35 if (THREADS STREQUAL "posix" OR THREADS STREQUAL "pthreads")
36   set(THREADS posix)
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"
57 ###     fi
58 ###     if test "x$PTHREAD_LIBS" = "x"; then
59 ###             THREADDLLIBS=-pthread
60 ###     else
61 ###             THREADDLLIBS="$PTHREAD_LIBS"
62 ###     fi
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")
80   else()
81         message(FATAL_ERROR "Pthreads not supported by the GC on this platform.")
82   endif()
83 endif()
84
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)
91   endif()
92 endif()
93
94 if(${host} MATCHES "powerpc-.*-darwin.*")
95   set(powerpc_darwin yes)
96 endif()
97
98 if(parallel_mark_supported AND enable_parallel_mark)
99   add_definitions("-DPARALLEL_MARK")
100 endif()
101
102 # Configuration of machine-dependent code
103
104 ac_msg_checking("which machine-dependent code should be used")
105
106 ###AC_MSG_CHECKING(
107 ###machdep=
108 ###case "$host" in
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)
113 ###    fi
114 ###    ;;
115 ### alpha*-*-linux*)
116 ###    machdep="alpha_mach_dep.lo"
117 ###    ;;
118 ### i?86-*-solaris2.[[89]]|i?86-*-solaris2.1?)
119 ###    AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED)
120 ###    ;;
121 ### mipstx39-*-elf*)
122 ###    machdep="mips_ultrix_mach_dep.lo"
123 ###    AC_DEFINE(STACKBASE, __stackbase)
124 ###    AC_DEFINE(DATASTART_IS_ETEXT)
125 ###    ;;
126 ### mips-dec-ultrix*)
127 ###    machdep="mips_ultrix_mach-dep.lo"
128 ###    ;;
129 ### mips-nec-sysv*|mips-unknown-sysv*)
130 ###    ;;
131 ### mips*-*-linux*) 
132 ###    ;; 
133 ### mips-*-*)
134 ###    machdep="mips_sgi_mach_dep.lo"
135 ###    AC_DEFINE(NO_EXECUTE_PERMISSION)
136 ###    ;;
137 ### sparc-*-netbsd*)
138 ###    machdep="sparc_netbsd_mach_dep.lo"
139 ###    ;;
140 ### sparc-sun-solaris2.3)
141 ###    machdep="sparc_mach_dep.lo"
142 ###    AC_DEFINE(SUNOS53_SHARED_LIB)
143 ###    ;;
144 ### sparc*-sun-solaris2.*)
145 ###    machdep="sparc_mach_dep.lo"
146 ###    ;;
147 ### ia64-*-*)
148 ###    machdep="mach_dep.lo ia64_save_regs_in_stack.lo"
149 ###    ;;
150 ###esac
151 if(NOT machdep)
152   set(machdep "mach_dep.c")
153 endif()
154 ac_msg_result("${machdep}")
155
156 ac_msg_checking("for threads package to use")
157 ac_msg_result("${THREADS}")
158
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)
163
164 # By default, make the library as general as possible.
165 add_definitions(-DJAVA_FINALIZATION -DGC_GCJ_SUPPORT -DATOMIC_UNCOLLECTABLE)
166
167 add_definitions(-D_IN_LIBGC)
168
169 set(SUBDIRS include doc)
170
171 foreach(dir ${SUBDIRS})
172   add_subdirectory(${dir})
173 endforeach()
174
175 set(top_srcdir ../)
176
177 # .. is needed for mono/utils/mono-compiler.h
178 INCLUDE_DIRECTORIES(. .. include)
179 add_definitions(${CPPFLAGS})
180
181 if(powerpc_darwin)
182   set(asm_libgc_sources powerpc_darwin_mach_dep.s)
183 endif()
184
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})
194
195 add_library(monogc-static STATIC ${libmonogc_la_SOURCES})
196 target_link_libraries (${THREADDLLIBS} ${UNWINDLIBS})