]> granicus.if.org Git - gc/commitdiff
2010-02-24 Ivan Maidanski <ivmai@mail.ru> (really Jack Andrews)
authorivmai <ivmai>
Wed, 24 Feb 2010 07:01:48 +0000 (07:01 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:53 +0000 (21:06 +0400)
* CMakeLists.txt: New file (adding CMake support).
* tests/CMakeLists.txt: Ditto.
* doc/README.cmake: Ditto.

CMakeLists.txt [new file with mode: 0644]
ChangeLog
doc/README.cmake [new file with mode: 0644]
tests/CMakeLists.txt [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..47560ea
--- /dev/null
@@ -0,0 +1,210 @@
+
+# (C) Jack Andrews 2008
+# licensed under GPL 2.0
+#
+#  get cmake and run:
+#    cmake -G "Visual Studio 8 2005"
+#  in the same dir as this file
+#  this will generate gc.sln
+#
+
+PROJECT(gc)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+ADD_DEFINITIONS("-D_CRT_SECURE_NO_DEPRECATE
+                 -DALL_INTERIOR_POINTERS
+                 -DGC_BUILD
+")
+
+#LIBATOMIC #TODO
+#ADD_LIBRARY(atomic_ops STATIC )
+#SET_TARGET_PROPERTIES(atomic_ops PROPERTIES COMPILE_FLAGS -DNO_DEBUGGING)
+
+
+#LIBGC
+
+INCLUDE_DIRECTORIES(include)
+INCLUDE_DIRECTORIES(libatomic_ops\src)
+
+SET(LIBS)
+OPTION(enable_threads "TODO" NO)
+IF(enable_threads)
+        FIND_PACKAGE(Threads REQUIRED)
+        MESSAGE("Thread Model: ${CMAKE_THREAD_LIBS_INIT}" )
+        INCLUDE_DIRECTORIES(${Threads_INCLUDE_DIR})
+        SET(LIBS ${LIBS} ${Threads_LIBRARIES})
+ENDIF(enable_threads)
+
+OPTION(enable_parallel_mark "Parallelize marking and free list construction" NO)
+
+#IF(Threads_FOUND)
+#       ADD_DEFINITIONS("")
+#ELSE
+#       MESSAGE("Parallel mark requires enable_threads ON" )
+#ENDIF(Threads_FOUND)
+
+IF(enable_parallel_mark)
+ENDIF(enable_parallel_mark)
+
+OPTION(enable_cplusplus "install C++ support" NO)
+
+SET(_HOST ${CMAKE_HOST_SYSTEM_PROCESSOR}--${CMAKE_SYSTEM}) #FIXME missing the vendor field.Use lowercase
+
+STRING(TOLOWER ${_HOST} HOST)
+MESSAGE("HOST = ${HOST}")
+
+#Thread Detection. Relying on cmake for lib an includes.
+#TODO check cmake detection
+IF(CMAKE_USE_PTHREADS_INIT)
+        IF( "HOST" MATCHES x86-.*-linux.*|ia64-.*-linux.*|i586-.*-linux.*|i686-.*-linux.*|x86_64-.*-linux.*|alpha-.*-linux.*|sparc.*-.*-linux.*)
+                ADD_DEFINITIONS("-DGC_LINUX_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+                IF (${enable_parallel_mark})
+                        ADD_DEFINITIONS("-DPARALLEL_MARK")
+                ENDIF()
+                ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
+                MESSAGE("Explicit GC_INIT() calls may be required.")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-linux.*)
+                ADD_DEFINITIONS("-DGC_LINUX_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-aix.*)
+                ADD_DEFINITIONS("-DGC_AIX_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-hpux11.*)
+                MESSAGE("Only HP/UX 11 POSIX threads are supported.")
+                ADD_DEFINITIONS("-DGC_HPUX_THREADS")
+                ADD_DEFINITIONS("-D_POSIX_C_SOURCE=199506L") #TODO test -DVAR=value. Alternative is COMPILE_DEFINITIONS property
+                IF (${enable_parallel_mark})
+                        ADD_DEFINITIONS("-DPARALLEL_MARK")
+                ENDIF()
+                MESSAGE("Explicit GC_INIT() calls may be required.")
+                ADD_DEFINITIONS("-D_REENTRANT") #TODO
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-hpux10.*)
+                MESSAGE("Only HP/UX 11 POSIX threads are supported.")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-openbsd.*)
+                ADD_DEFINITIONS("-DGC_OPENBSD_THREADS")
+                #FIXME openbsd_threads=true
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-freebsd.*)
+                MESSAGE("FreeBSD does not yet fully support threads with Boehm GC.")
+                ADD_DEFINITIONS("-DGC_FREEBSD_THREADS")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-kfreebsd.*-gnu)
+                ADD_DEFINITIONS("-DGC_FREEBSD_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+                IF (${enable_parallel_mark})
+                        ADD_DEFINITIONS("-DPARALLEL_MARK")
+                ENDIF()
+                ADD_DEFINITIONS(THREAD_LOCAL_ALLOC")
+                ADD_DEFINITIONS(USE_COMPILER_TLS")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-gnu.*)
+                ADD_DEFINITIONS("-DGC_GNU_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+                ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-netbsd.*)
+                MESSAGE("Only on NetBSD 2.0 or later.")
+                ADD_DEFINITIONS("-DGC_NETBSD_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+                ADD_DEFINITIONS("-D_PTHREADS")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-solaris.*)
+                ADD_DEFINITIONS("-DGC_SOLARIS_THREADS")
+                ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
+#TODO
+#       if test "$GCC" != yes; then
+#          CFLAGS="$CFLAGS -O"
+#          need_atomic_ops_asm=true
+#        fi
+
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-irix.*)
+                ADD_DEFINITIONS("-DGC_IRIX_THREADS")
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-cygwin.*)
+                ADD_DEFINITIONS("-DGC_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+                IF (${enable_parallel_mark})
+                        ADD_DEFINITIONS("-DPARALLEL_MARK")
+                ENDIF()
+                ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
+
+#TODO
+#       win32_threads=true
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-darwin.*)
+                ADD_DEFINITIONS("-DGC_DARWIN_THREADS")
+                ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
+                MESSAGE("Explicit GC_INIT() calls may be required.")
+                # Parallel-mark is currently unreliable on Darwin; ignore request
+                #IF (${enable_parallel_mark})
+                #       ADD_DEFINITIONS("-DPARALLEL_MARK")
+                #ENDIF()
+                #TODO
+                #darwin_threads=true
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-osf*)
+                ADD_DEFINITIONS("-DGC_OSF1_THREADS")
+                IF (${enable_parallel_mark})
+                        ADD_DEFINITIONS("-DPARALLEL_MARK")
+                        ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
+                        MESSAGE("Explicit GC_INIT() calls may be required.")
+                        # May want to enable it in other cases, too.
+                        # Measurements haven't yet been done.
+                ENDIF()
+        ENDIF()
+        IF ( "HOST" MATCHES .*-.*-linux.*)
+                ADD_DEFINITIONS("-DGC_LINUX_THREADS")
+                ADD_DEFINITIONS("-D_REENTRANT")
+        ENDIF()
+ENDIF(CMAKE_USE_PTHREADS_INIT)
+
+IF(CMAKE_USE_WIN32_THREADS_INIT)
+        ADD_DEFINITIONS("-DGC_THREADS")
+        #win32_threads=true   TODO
+        IF (${enable_parallel_mark})
+                ADD_DEFINITIONS("-DPARALLEL_MARK")
+                ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC")
+        ENDIF()
+        ADD_DEFINITIONS("-DEMPTY_GETENV_RESULTS") #TODO test
+ENDIF(CMAKE_USE_WIN32_THREADS_INIT)
+
+OPTION(enable_gcj_support "Support for gcj" NO)
+IF(enable_gcj_support)
+        #TODO AM_CONDITIONAL(ENABLE_GCJ_SUPPORT,     [test x"$enable_gcj_support" != xno])
+        ADD_DEFINITIONS("-DGC_GCJ_SUPPORT")
+ENDIF(enable_gcj_support)
+
+SET(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c
+        mark_rts.c headers.c mark.c obj_map.c blacklst.c finalize.c
+        new_hblk.c dbg_mlc.c malloc.c stubborn.c dyn_load.c
+        typd_mlc.c ptr_chck.c gc_cpp.cc mallocx.c checksums.c
+        win32_threads.c)
+
+ADD_LIBRARY(          gc-lib   STATIC      ${SRC})
+SET_TARGET_PROPERTIES(gc-lib   PROPERTIES
+                      COMPILE_DEFINITIONS GC_NOT_DLL)
+#TODO TARGET_LINK_LIBRARIES(...  ...  ${LIBS})
+
+ADD_LIBRARY(          gcmt-lib STATIC      ${SRC})
+SET_TARGET_PROPERTIES(gcmt-lib PROPERTIES
+                      COMPILE_DEFINITIONS GC_NOT_DLL)
+
+ADD_LIBRARY(          gcmt-dll  SHARED     ${SRC})
+
+IF(WIN32)
+  ADD_EXECUTABLE(cord cord/cordbscs.c cord/cordxtra.c cord/de.c cord/de_win.c)
+  SET_TARGET_PROPERTIES(cord PROPERTIES WIN32_EXECUTABLE TRUE)
+  SET_TARGET_PROPERTIES(cord    PROPERTIES
+                      COMPILE_DEFINITIONS GC_NOT_DLL)
+  TARGET_LINK_LIBRARIES(cord gc-lib)
+ENDIF(WIN32)
+
+ADD_SUBDIRECTORY(tests)
index a2f78ed56b0da58b2b7b246b6018e89766e4bbc2..10394784121789663c06ddf30e8ef6f20b5496d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-02-24  Ivan Maidanski <ivmai@mail.ru> (really Jack Andrews)
+
+       * CMakeLists.txt: New file (adding CMake support).
+       * tests/CMakeLists.txt: Ditto.
+       * doc/README.cmake: Ditto.
+
 2010-02-19  Ivan Maidanski <ivmai@mail.ru> (really Bruce Mitchener)
 
        * configure.ac (darwin): Don't define HAS_PPC_THREAD_STATE...
diff --git a/doc/README.cmake b/doc/README.cmake
new file mode 100644 (file)
index 0000000..de6f6b7
--- /dev/null
@@ -0,0 +1,42 @@
+
+CMAKE
+-----
+
+Win32 binaries (both 32- and 64-bit) can be built using CMake.  CMake is an
+open-source tool like automake - it generates makefiles.
+
+
+CMake will generate:
+
+  Borland Makefiles
+  MSYS Makefiles
+  MinGW Makefiles
+  NMake Makefiles
+  Unix Makefiles
+  . Visual Studio project files
+    Visual Studio 6
+    Visual Studio 7
+    Visual Studio 7 .NET 2003
+    Visual Studio 8 2005
+    Visual Studio 8 2005 Win64
+    Visual Studio 9 2008
+    Visual Studio 9 2008 Win64
+  Watcom WMake
+
+
+BUILD PROCESS
+-------------
+
+ . install cmake (cmake.org)
+ . add directory containing cmake.exe to %PATH%
+ . run cmake from the gc root directory, passing the target with -G:
+   eg.
+      > cmake -G "Visual Studio 8 2005"
+   use the gc.sln file genereated by cmake to build gc
+
+
+INPUT
+-----
+
+The main input to cmake are the CMakeLists.txt files in each directory.  For
+help, goto cmake.org.
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644 (file)
index 0000000..dcb1470
--- /dev/null
@@ -0,0 +1,6 @@
+# (C) Jack Andrews 2008
+# licensed under GPL 2.0
+
+ADD_DEFINITIONS(-DGC_NOT_DLL)
+ADD_EXECUTABLE(gctest WIN32 test.c)
+TARGET_LINK_LIBRARIES(gctest gc-lib)