diff --git a/.gitignore b/.gitignore
index 1e6ed090672ffe53cd006988672d6daf3b794140..975557746738fc77d8bdca381c015a2859f6f806 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,9 @@ lcov
 *.so
 *.d
 *.dylib
+*.gcno
+*.gcda
+*~
 test/var
 test/lib/*.pyc
 test/lib/*/*.pyc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ecb7f08fa2c4d8a3a22132f078069ca44fb3b63d..42231867dddfde65b332da9402d7997e3646bc54 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 2.6)
 
 project(tarantool)
 
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
+set(CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_INCLUDE_PATH})
+
 include(CheckLibraryExists)
 include(CheckIncludeFile)
 include(CheckCCompilerFlag)
@@ -42,20 +45,16 @@ if(NOT CMAKE_BUILD_TYPE)
         FORCE)
 endif()
 
+set(CMAKE_OBJC_FLAGS)
+set(CMAKE_OBJCXX_FLAGS)
+
+include(cmake/utils.cmake)
+
 # the order is significant: we need to know os and compiler to configure libs
 include(cmake/arch.cmake)
 include(cmake/os.cmake)
 include(cmake/compiler.cmake)
-# 
-# Since we *optionally* build bundled libs, a direct build
-# dependency between tarantool_box and libluajit/libobjc won't
-# wor: dadd an empty custom target for this dependency instead.
-# If a bundled objc or luajit is built, it is added to the
-# dependency list of build_bundled_libs target.
-#
-add_custom_target(build_bundled_libs)
-include(cmake/libobjc.cmake)
-include(cmake/luajit.cmake)
+include(cmake/profile.cmake)
 
 check_symbol_exists(MAP_ANON sys/mman.h HAVE_MAP_ANON)
 check_symbol_exists(MAP_ANONYMOUS sys/mman.h HAVE_MAP_ANONYMOUS)
@@ -129,17 +128,6 @@ if (ENABLE_CLIENT)
     set (TARANTOOL_CLIENTS ${TARANTOOL_CLIENTS} "tarantool")
 endif()
 
-option(ENABLE_GCOV "Enable integration with gcov, a code coverage program" OFF)
-if (ENABLE_GCOV)
-    check_library_exists (gcov __gcov_flush  ""  HAVE_GCOV)
-    if (NOT HAVE_GCOV)
-        message (FATAL_ERROR
-                 "ENABLE_GCOV option requested but gcov library is not found")
-    endif()
-    set (GCOV_C_FLAGS "-fprofile-arcs -ftest-coverage")
-    set (GCOV_LDFLAGS "-fprofile-arcs -ftest-coverage")
-endif()
-
 option(ENABLE_TRACE "Enable debug trace of tarantool_box execution to
 a file specified in TARANTOOL_TRACE environment variable" ON)
 
@@ -169,10 +157,126 @@ endif()
 
 option(ENABLE_STATIC "Perform static linking whenever possible." OFF)
 if (ENABLE_STATIC)
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
+    add_compile_flags("C;CXX" "-static")
+endif()
+
+##
+## Third-Party libraries
+##
+
+#
+# Since we *optionally* build bundled libs, a direct build
+# dependency between tarantool_box and libluajit/libobjc won't
+# work: add an empty custom target for this dependency instead.
+# If a bundled objc or luajit is built, it is added to the
+# dependency list of build_bundled_libs target.
+#
+
+add_custom_target(build_bundled_libs)
+
+#
+# LibLUAJIT
+#
+include(luajit)
+
+#
+# LibOBJC
+#
+option(ENABLE_BUNDLED_LIBOBJC "Enable building of the bundled libobjc" ON)
+
+if (ENABLE_BUNDLED_LIBOBJC)
+    include(BuildLibOBJC)
+    libobjc_build()
+    add_dependencies(build_bundled_libs objc)
+    set(HAVE_LIBOBJC_BUNDLED ON)
+    include_directories(${LIBOBJC_INCLUDE_DIR})
+else()
+    if (CMAKE_COMPILER_IS_GNUCC)
+        # Use compiler's objc library
+        add_compile_flags("OBJC;OBJCXX" "-objc")
+        set(LIBOBJC_LIBRARIES objc)
+        message(STATUS "Use gcc Objective-C runtime")
+    else()
+        set(LIBOBJC_FIND_REQUIRED ON)
+        find_package(LibOBJC)
+    endif()
 endif()
 
-add_subdirectory(third_party)
+
+#
+# LibEV
+#
+
+#
+# Currently our code uses libev with #define EV_MULTIPLICITY 0.
+# This option means that libev has a global variable with
+# struct ev_loop data.
+# Such design is not compatible with the dynamic version of libev
+# provided by distros.
+set(ENABLE_BUNDLED_LIBEV ON)
+include(BuildLibEV)
+libev_build()
+add_dependencies(build_bundled_libs ev)
+include_directories(${LIBEV_INCLUDE_DIR})
+
+#
+# LibEIO
+#
+option(ENABLE_BUNDLED_LIBEIO "Enable building of the bundled libeio" ON)
+
+if (ENABLE_BUNDLED_LIBEIO)
+    include(BuildLibEIO)
+    libeio_build()
+    add_dependencies(build_bundled_libs eio)
+else()
+    set(LIBEIO_FIND_REQUIRED ON)
+    find_package(LibEIO)
+endif()
+
+include_directories(${LIBEIO_INCLUDE_DIR})
+
+#
+# LibCORO
+#
+
+#
+# Tarantool uses 'coro' (coroutines) library to implement
+# cooperative multi-tasking. Since coro.h is included
+# universally, define the underlying implementation switch
+# in the top level CMakeLists.txt, to ensure a consistent
+# header file layout across the entire project.
+#
+set(ENABLE_BUNDLED_LIBCORO ON)
+include(BuildLibCORO)
+libcoro_build()
+add_dependencies(build_bundled_libs coro)
+include_directories(${LIBCORO_INCLUDE_DIR})
+
+if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "amd64")
+    add_definitions("-DCORO_ASM")
+else()
+    add_definitions("-DCORO_SJLJ")
+endif()
+
+#
+# LibGOPT
+#
+
+include(BuildLibGOPT)
+libgopt_build()
+add_dependencies(build_bundled_libs gopt)
+
+include_directories(${LIBGOPT_INCLUDE_DIR})
+
+#
+# Third-Party misc
+#
+
+include(BuildMisc)
+libmisc_build()
+add_dependencies(build_bundled_libs misc)
+
+
 add_subdirectory(cfg)
 add_subdirectory(connector)
 add_subdirectory(src)
@@ -189,11 +293,12 @@ include (cmake/cpack.cmake)
 # tarantool info summary (used in server version output)
 #
 set(TARANTOOL_OPTIONS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
-set(TARANTOOL_OPTIONS "${TARANTOOL_OPTIONS} -DENABLE_STATIC=${ENABLE_STATIC} -DENABLE_GCOV=${ENABLE_GCOV}")
+set(TARANTOOL_OPTIONS "${TARANTOOL_OPTIONS} -DENABLE_STATIC=${ENABLE_STATIC}")
 set(TARANTOOL_OPTIONS "${TARANTOOL_OPTIONS} -DENABLE_TRACE=${ENABLE_TRACE} -DENABLE_BACKTRACE=${ENABLE_BACKTRACE}")
 set(TARANTOOL_OPTIONS "${TARANTOOL_OPTIONS} -DENABLE_CLIENT=${ENABLE_CLIENT}")
 set(TARANTOOL_BUILD "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_BUILD_TYPE}")
-set(TARANTOOL_COMPILER ${CMAKE_C_COMPILER})
+set(TARANTOOL_C_COMPILER ${CMAKE_C_COMPILER})
+set(TARANTOOL_CXX_COMPILER ${CMAKE_CXX_COMPILER})
 
 #
 # Output compile-time defines into config.h. Do it at the end
@@ -217,16 +322,25 @@ message (STATUS "Tarantool configuration is complete:")
 message (STATUS "")
 message (STATUS "VERSION: ${PACKAGE_VERSION}")
 message (STATUS "BUILD: ${TARANTOOL_BUILD}")
-message (STATUS "COMPILER: ${TARANTOOL_COMPILER}")
-message (STATUS "CFLAGS:${CMAKE_C_FLAGS} ${core_cflags}")
+message (STATUS "C_COMPILER: ${TARANTOOL_C_COMPILER}")
+message (STATUS "CXX_COMPILER: ${TARANTOOL_CXX_COMPILER}")
+message (STATUS "C_FLAGS:${CMAKE_C_FLAGS} ${TARANTOOL_C_FLAGS}")
+message (STATUS "CXX_FLAGS:${CMAKE_CXX_FLAGS} ${TARANTOOL_CXX_FLAGS}")
+message (STATUS "OBJC_FLAGS:${CMAKE_C_FLAGS} ${CMAKE_OBJC_FLAGS}")
+message (STATUS "OBJCXX_FLAGS:${CMAKE_CXX_FLAGS} ${CMAKE_OBJCXX_FLAGS}")
 message (STATUS "PREFIX: ${CMAKE_INSTALL_PREFIX}")
 message (STATUS "MODULES: ${TARANTOOL_MODULES}")
 message (STATUS "ENABLE_STATIC: ${ENABLE_STATIC}")
 message (STATUS "ENABLE_GCOV: ${ENABLE_GCOV}")
+message (STATUS "ENABLE_GPROF: ${ENABLE_GPROF}")
 message (STATUS "ENABLE_TRACE: ${ENABLE_TRACE}")
 message (STATUS "ENABLE_BACKTRACE: ${ENABLE_BACKTRACE} (symbol resolve: ${HAVE_BFD})")
 message (STATUS "ENABLE_CLIENT: ${ENABLE_CLIENT}")
 message (STATUS "ENABLE_BUNDLED_LUAJIT: ${ENABLE_BUNDLED_LUAJIT}")
+message (STATUS "ENABLE_BUNDLED_LIBOBJC: ${ENABLE_BUNDLED_LIBOBJC}")
+message (STATUS "ENABLE_BUNDLED_LIBEV: ${ENABLE_BUNDLED_LIBEV}")
+message (STATUS "ENABLE_BUNDLED_LIBEIO: ${ENABLE_BUNDLED_LIBEIO}")
+message (STATUS "ENABLE_BUNDLED_LIBCORO: ${ENABLE_BUNDLED_LIBCORO}")
 message (STATUS "ENABLE_DOC: ${ENABLE_DOC}")
 message (STATUS "")
 message (STATUS "To view or modify configuration results, check out CMakeCache.txt.")
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 691ee8424bafc30c535ecdf4c3b7709cf6e86a6a..e9d18a893dd4e2fb61c93a45465f0095148c191b 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -1,4 +1,6 @@
 
+enable_tnt_compile_flags()
+
 # function to build tarantool clients that use connector/c
 # 
 function(tarantool_client client_name)
@@ -7,7 +9,6 @@ function(tarantool_client client_name)
 	add_executable(${client_name} ${client_sources}
 		       ${CMAKE_SOURCE_DIR}/src/errcode.c)
 	set (client_libs tntrpl tntnet tntsql tnt)
-	set_target_properties(${client_name} PROPERTIES COMPILE_FLAGS "${core_cflags}")
 	target_link_libraries (${client_name} ${client_libs})
 endfunction()
 
diff --git a/client/tarantool/CMakeLists.txt b/client/tarantool/CMakeLists.txt
index 55241c935544e7ee01c1959ce2575181567c0731..c8f1a369ac60e870e3beb312771fadf09b82c69c 100644
--- a/client/tarantool/CMakeLists.txt
+++ b/client/tarantool/CMakeLists.txt
@@ -12,8 +12,9 @@ set (cli_sources tc.c tc_opt.c tc_admin.c tc_query.c tc_print.c tc_cli.c tc_stor
 set (cli_libs tntrpl tntnet tntsql tnt gopt ${READLINE_LIBRARIES})
 
 include_directories(${READLINE_INCLUDE_DIR})
-add_executable(${cli} ${cli_sources} ${CMAKE_SOURCE_DIR}/src/errcode.c)
-set_target_properties(${cli} PROPERTIES COMPILE_FLAGS "${core_cflags}")
+list(APPEND cli_sources ${CMAKE_SOURCE_DIR}/src/errcode.c)
+add_executable(${cli} ${cli_sources})
+set_source_files_compile_flags("TARANTOOL" ${cli_sources})
 target_link_libraries (${cli} ${cli_libs})
 
 install (TARGETS ${cli} DESTINATION bin)
diff --git a/client/tarantool_checksum/CMakeLists.txt b/client/tarantool_checksum/CMakeLists.txt
index 55352be6d65c064a1caa5e860522a15a1a997c8f..e24280ad6376a39326fba1143b34e237c9ed3676 100644
--- a/client/tarantool_checksum/CMakeLists.txt
+++ b/client/tarantool_checksum/CMakeLists.txt
@@ -5,17 +5,21 @@ set (util_checksum_sources tc_main.c tc_options.c tc_config.c tc_space.c tc_file
 set (util_checksum_libs tntrpl tntnet tnt gopt)
 
 set_source_files_properties(${CMAKE_SOURCE_DIR}/cfg/tarantool_box_cfg.c
-                            ${CMAKE_SOURCE_DIR}/cfg/prscfg.c
-		            PROPERTIES COMPILE_FLAGS "-Wno-unused" GENERATED True)
+    ${CMAKE_SOURCE_DIR}/cfg/prscfg.c PROPERTIES COMPILE_FLAGS
+    "-Wno-unused-parameter"
+    GENERATED True)
 
 set_source_files_properties(${util_checksum_sources} PROPERTIES OBJECT_DEPENDS
 		            ${CMAKE_SOURCE_DIR}/cfg/tarantool_box_cfg.h)
 
-add_executable(${util_checksum} ${util_checksum_sources}
-               ${CMAKE_SOURCE_DIR}/cfg/tarantool_box_cfg.c
-               ${CMAKE_SOURCE_DIR}/cfg/prscfg.c)
+list(APPEND util_checksum_sources
+    ${CMAKE_SOURCE_DIR}/cfg/tarantool_box_cfg.c
+    ${CMAKE_SOURCE_DIR}/cfg/prscfg.c)
+
+set_source_files_compile_flags(
+    ${util_checksum_sources})
+add_executable(${util_checksum} ${util_checksum_sources})
 
-set_target_properties(${util_checksum} PROPERTIES COMPILE_FLAGS "${core_cflags}")
 
 target_link_libraries (${util_checksum} ${util_checksum_libs})
 
diff --git a/cmake/BuildLibCORO.cmake b/cmake/BuildLibCORO.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..11cc2ae6ee02ada1fd180d782fcbb0714faa7198
--- /dev/null
+++ b/cmake/BuildLibCORO.cmake
@@ -0,0 +1,18 @@
+#
+# A macro to build the bundled libcoro
+macro(libcoro_build)
+    set(coro_src
+        ${PROJECT_SOURCE_DIR}/third_party/coro/coro.c
+    )
+
+    add_library(coro STATIC ${coro_src})
+
+    set(LIBCORO_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party/coro)
+    set(LIBCORO_LIBRARIES coro)
+
+    message(STATUS "Use bundled libcoro includes: ${LIBCORO_INCLUDE_DIR}/coro.h")
+    message(STATUS "Use bundled libcoro library: ${LIBCORO_LIBRARIES}")
+
+    unset(coro_src)
+endmacro(libcoro_build)
+
diff --git a/cmake/BuildLibEIO.cmake b/cmake/BuildLibEIO.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..71ec083fe89afd7156b1e8422415538a00028a2a
--- /dev/null
+++ b/cmake/BuildLibEIO.cmake
@@ -0,0 +1,28 @@
+#
+# A macro to build the bundled libeio
+macro(libeio_build)
+    set(eio_compile_flags)
+
+    set(eio_compile_flags "${eio_compile_flags} -Wno-unused-value")
+    set(eio_compile_flags "${eio_compile_flags} -Wno-dangling-else")
+    set(eio_compile_flags "${eio_compile_flags} -DENABLE_BUNDLED_LIBEIO=1")
+
+    set(eio_src
+        ${PROJECT_SOURCE_DIR}/third_party/tarantool_eio.c
+    )
+
+    add_library(eio STATIC ${eio_src})
+
+    set_target_properties(eio PROPERTIES COMPILE_FLAGS "${eio_compile_flags}")
+
+    set(LIBEIO_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party)
+    set(LIBEIO_LIBRARIES eio)
+
+    message(STATUS "Use bundled libeio includes: "
+        "${LIBEIO_INCLUDE_DIR}/tarantool_eio.h")
+    message(STATUS "Use bundled libeio library: "
+        "${LIBEIO_LIBRARIES}")
+
+    unset(eio_src)
+    unset(eio_compile_flags)
+endmacro(libeio_build)
diff --git a/cmake/BuildLibEV.cmake b/cmake/BuildLibEV.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..59b18d778c3a4e33780c44834b88187b2922119e
--- /dev/null
+++ b/cmake/BuildLibEV.cmake
@@ -0,0 +1,59 @@
+#
+# A macro to build the bundled libev
+macro(libev_build)
+    set(ev_compile_flags)
+    set(ev_link_libraries)
+
+    if (CC_HAS_WNO_UNUSED_RESULT)
+        set(ev_compile_flags "${ev_compile_flags} -Wno-unused-value")
+    endif()
+    if (CC_HAS_WNO_COMMENT)
+        set(ev_compile_flags "${ev_compile_flags} -Wno-comment")
+    endif()
+    if (CC_HAS_FNO_STRICT_ALIASING)
+        set(ev_compile_flags "${ev_compile_flags} -fno-strict-aliasing")
+    endif()
+    if (CC_HAS_WNO_PARENTHESES)
+        set(ev_compile_flags "${ev_compile_flags} -Wno-parentheses")
+    endif()
+    set(ev_compile_flags "${ev_compile_flags} -DENABLE_BUNDLED_LIBEV=1")
+
+    if (TARGET_OS_LINUX)
+        #
+        # Enable Linux-specific event notification API (man inotify)
+        set(ev_compile_flags "${ev_compile_flags} -DEV_USE_INOTIFY")
+    elseif (TARGET_OS_FREEBSD)
+        #
+        # On FreeBSD build libev loop on top of
+        set(ev_compile_flags "${ev_compile_flags} -DEV_USE_KQUEUE")
+    endif()
+
+    list(APPEND ev_link_libraries "m")
+    if (TARGET_OS_DEBIAN_FREEBSD)
+        # libev depends on librt under kFreeBSD
+        list(APPEND ev_link_libraries "rt")
+    else()
+
+    endif()
+
+    set(libev_src
+        ${PROJECT_SOURCE_DIR}/third_party/tarantool_ev.c
+    )
+
+    add_library(ev STATIC ${libev_src})
+
+    set_target_properties(ev PROPERTIES COMPILE_FLAGS "${ev_compile_flags}")
+    target_link_libraries(ev ${ev_link_libraries})
+
+    set(LIBEV_INCLUDE_DIR ${PROJECT_BINARY_DIR}/third_party)
+    set(LIBEV_LIBRARIES ev)
+
+    message(STATUS "Use bundled libev includes: "
+        "${LIBEV_INCLUDE_DIR}/tarantool_ev.h")
+    message(STATUS "Use bundled libev library: "
+        "${LIBEV_LIBRARIES}")
+
+    unset(ev_src)
+    unset(ev_compile_flags)
+    unset(ev_link_libraries)
+endmacro(libev_build)
diff --git a/cmake/BuildLibGOPT.cmake b/cmake/BuildLibGOPT.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..539d0e92e23520f77227345caa55be0bf030be8e
--- /dev/null
+++ b/cmake/BuildLibGOPT.cmake
@@ -0,0 +1,17 @@
+#
+# A macro to build the bundled libgopt
+macro(libgopt_build)
+
+    set(gopt_src ${PROJECT_SOURCE_DIR}/third_party/gopt/gopt.c)
+
+    add_library(gopt STATIC ${gopt_src})
+
+    set(LIBGOPT_INCLUDE_DIR ${PROJECT_BINARY_DIR}/third_party/gopt)
+    set(LIBGOPT_LIBRARIES gopt)
+
+    message(STATUS "Use bundled libgopt includes: ${LIBGOPT_INCLUDE_DIR}/gopt.h")
+    message(STATUS "Use bundled libgopt library: ${LIBGOPT_LIBRARIES}")
+
+    unset(gopt_src)
+endmacro(libgopt_build)
+
diff --git a/cmake/libobjc.cmake b/cmake/BuildLibOBJC.cmake
similarity index 67%
rename from cmake/libobjc.cmake
rename to cmake/BuildLibOBJC.cmake
index a736ab71190af44d1aadd73a0baff2b769234917..b343f95406eb80678c457395df2ee7a1176245d3 100644
--- a/cmake/libobjc.cmake
+++ b/cmake/BuildLibOBJC.cmake
@@ -5,8 +5,6 @@ macro(libobjc_build)
     if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
         set (extra_cflags "${CC_DEBUG_OPT} -O0")
         if (CMAKE_COMPILER_IS_GNUCC)
-            set (extra_cflags "${extra_cflags} -fgnu89-inline")
-        else()
             set (extra_cflags "${extra_cflags} -fno-inline")
         endif()
         set (extra_ldflags "")
@@ -15,9 +13,6 @@ macro(libobjc_build)
         if (CC_HAS_WNO_UNUSED_RESULT)
             set (extra_cflags "${extra_cflags} -Wno-unused-result")
         endif()
-        if (CMAKE_COMPILER_IS_GNUCC)
-                set (extra_cflags "${extra_cflags} -fgnu89-inline")
-        endif()
         set (extra_ldflags "-s")
     endif()
     if (TARGET_OS_LINUX)
@@ -27,8 +22,13 @@ macro(libobjc_build)
        endif()
     endif()
     if (CMAKE_COMPILER_IS_CLANG)
-        set (extra_cflags "${extra_cflags} -Wno-deprecated-objc-isa-usage -Wno-objc-root-class")
+        set (extra_cflags "${extra_cflags} -Wno-deprecated-objc-isa-usage")
+        set (extra_cflags "${extra_cflags} -Wno-objc-root-class")
     endif()
+    set (extra_cflags "${extra_cflags} -Wno-attributes")
+    set (extra_cflags "${CMAKE_C_FLAGS} ${extra_cflags}")
+    separate_arguments(extra_cflags UNIX_COMMAND "${extra_cflags}")
+    separate_arguments(extra_ldflags UNIX_COMMAND "${extra_ldflags}")
     if (NOT (${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR}))
         add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/libobjc
             COMMAND mkdir ${PROJECT_BINARY_DIR}/third_party/libobjc
@@ -39,26 +39,20 @@ macro(libobjc_build)
     add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/libobjc/libobjc.a
         WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/libobjc
         COMMAND $(MAKE) clean
-        COMMAND $(MAKE) CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} EXTRA_CFLAGS=""${extra_cflags}"" EXTRA_LDFLAGS=""${extra_ldflags}""
+        COMMAND $(MAKE) CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} EXTRA_CFLAGS="${extra_cflags}" EXTRA_LDFLAGS="${extra_ldflags}"
         DEPENDS ${PROJECT_BINARY_DIR}/third_party/libobjc
                 ${PROJECT_BINARY_DIR}/CMakeCache.txt
     )
-    add_custom_target(libobjc ALL
+    add_custom_target(objc ALL
         DEPENDS ${PROJECT_BINARY_DIR}/third_party/libobjc/libobjc.a
     )
-    add_dependencies(build_bundled_libs libobjc)
+
+    set(LIBOBJC_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party/libobjc)
+    set(LIBOBJC_LIBRARIES ${PROJECT_BINARY_DIR}/third_party/libobjc/libobjc.a)
+
+    message(STATUS "Use bundled libobjc includes: ${LIBOBJC_INCLUDE_DIR}")
+    message(STATUS "Use bundled libobjc library: ${LIBOBJC_LIBRARIES}")
+
     unset (extra_cflags)
     unset (extra_ldlags)
 endmacro()
-
-if (TARGET_OS_DARWIN)
-    set (LIBOBJC_LIB objc)
-else()
-    set (LIBOBJC_LIB "${PROJECT_BINARY_DIR}/third_party/libobjc/libobjc.a")
-    include_directories("${PROJECT_SOURCE_DIR}/third_party/libobjc")
-    if (CMAKE_C_COMPILER_IS_CLANG)
-        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi")
-        SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-objc-legacy-dispatch")
-    endif()
-    libobjc_build()
-endif()
diff --git a/cmake/BuildMisc.cmake b/cmake/BuildMisc.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..8f90c771b67959f7e1802529e5ae4383c45ccd05
--- /dev/null
+++ b/cmake/BuildMisc.cmake
@@ -0,0 +1,33 @@
+#
+# A macro to build the bundled libmisc
+macro(libmisc_build)
+    set(misc_src
+        ${PROJECT_SOURCE_DIR}/third_party/crc32.c
+        ${PROJECT_SOURCE_DIR}/third_party/proctitle.c
+        ${PROJECT_SOURCE_DIR}/third_party/qsort_arg.c
+    )
+
+    if (NOT HAVE_MEMMEM)
+        list(APPEND misc_src
+            ${PROJECT_SOURCE_DIR}/third_party/memmem.c
+        )
+    endif()
+
+    if (NOT HAVE_MEMRCHR)
+        list(APPEND misc_src
+            ${PROJECT_SOURCE_DIR}/third_party/memrchr.c
+        )
+    endif()
+
+    if (NOT TARGET_OS_DEBIAN_FREEBSD)
+        if (TARGET_OS_FREEBSD)
+            set_source_files_properties(
+            ${PROJECT_SOURCE_DIR}/third_party/proctitle.c
+            PROPERTIES COMPILE_FLAGS "-DHAVE_SETPROCTITLE")
+        endif()
+    endif()
+
+    add_library(misc STATIC ${misc_src})
+
+    unset(misc_src)
+endmacro(libmisc_build)
diff --git a/cmake/CMakeTestOBJCCompiler.cmake b/cmake/CMakeTestOBJCCompiler.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..ae9a403385c6b00dcd490fde21cda1be31e091d2
--- /dev/null
+++ b/cmake/CMakeTestOBJCCompiler.cmake
@@ -0,0 +1,48 @@
+#
+# Check if C compiler can compile ObjectiveC sources.
+# The code was borrowed from CMakeTestCXXCompiler.cmake
+#
+
+if(CMAKE_OBJC_COMPILER_FORCED OR CMAKE_C_COMPILER_FORCED)
+  # The compiler configuration was forced by the user.
+  # Assume the user has configured all compiler information.
+  set(CMAKE_OBJC_COMPILER_WORKS TRUE)
+  return()
+endif()
+
+if(NOT CMAKE_OBJC_COMPILER_WORKS)
+  message(STATUS "Check for working ObjectiveC compiler: ${CMAKE_C_COMPILER}")
+  file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m
+    "#if !defined(__OBJC__)\n"
+    "# error \"The CMAKE_C_COMPILER doesn't support ObjectiveC\"\n"
+    "#endif\n"
+    "int main(){return 0;}\n")
+  try_compile(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_BINARY_DIR} 
+    ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m
+    OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT)
+  # Move result from cache to normal variable.
+  set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS})
+  set(OBJC_TEST_WAS_RUN 1)
+endif()
+
+if(NOT CMAKE_OBJC_COMPILER_WORKS)
+  message(STATUS "Check for working ObjectiveC compiler: "
+    "${CMAKE_C_COMPILER}" " -- broken")
+  file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+    "Determining if the ObjectiveC compiler works failed with "
+    "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
+  message(FATAL_ERROR "The ObjectiveC compiler \"${CMAKE_C_COMPILER}\" "
+    "is not able to compile a simple ObjectiveC test program.\nIt fails "
+    "with the following output:\n ${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n"
+    "CMake will not be able to correctly generate this project.")
+else()
+  if(OBJC_TEST_WAS_RUN)
+    message(STATUS "Check for working ObjectiveC compiler: "
+        "${CMAKE_C_COMPILER}" " -- works")
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+      "Determining if the ObjectiveC compiler works passed with "
+      "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
+  endif()
+endif()
+
+unset(__CMAKE_OBJC_COMPILER_OUTPUT)
diff --git a/cmake/CMakeTestOBJCXXCompiler.cmake b/cmake/CMakeTestOBJCXXCompiler.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..2d77c46046fcd216e321bea98e0ba8cac6ac2911
--- /dev/null
+++ b/cmake/CMakeTestOBJCXXCompiler.cmake
@@ -0,0 +1,48 @@
+#
+# Check if CXX compiler can compile ObjectiveC sources.
+# The code was borrowed from CMakeTestCXXCompiler.cmake
+#
+
+if(CMAKE_OBJCXX_COMPILER_FORCED OR CMAKE_CXX_COMPILER_FORCED)
+  # The compiler configuration was forced by the user.
+  # Assume the user has configured all compiler information.
+  set(CMAKE_OBJCXX_COMPILER_WORKS TRUE)
+  return()
+endif()
+
+if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
+  message(STATUS "Check for working ObjectiveC++ compiler: ${CMAKE_CXX_COMPILER}")
+  file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm
+    "#if !defined(__OBJC__) || !defined(__cplusplus)\n"
+    "# error \"The CMAKE_CXX_COMPILER doesn't support ObjectiveC++\"\n"
+    "#endif\n"
+    "int main(){return 0;}\n")
+  try_compile(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} 
+    ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm
+    OUTPUT_VARIABLE __CMAKE_OBJCXX_COMPILER_OUTPUT)
+  # Move result from cache to normal variable.
+  set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS})
+  set(OBJCXX_TEST_WAS_RUN 1)
+endif()
+
+if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
+  message(STATUS "Check for working ObjectiveC++ compiler: "
+    "${CMAKE_CXX_COMPILER}" " -- broken")
+  file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+    "Determining if the ObjectiveC++ compiler works failed with "
+    "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
+  message(FATAL_ERROR "The ObjectiveC++ compiler \"${CMAKE_CXX_COMPILER}\" "
+    "is not able to compile a simple ObjectiveC++ test program.\nIt fails "
+    "with the following output:\n ${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n"
+    "CMake will not be able to correctly generate this project.")
+else()
+  if(OBJCXX_TEST_WAS_RUN)
+    message(STATUS "Check for working ObjectiveC++ compiler: "
+        "${CMAKE_CXX_COMPILER}" " -- works")
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+      "Determining if the ObjectiveC++ compiler works passed with "
+      "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
+  endif()
+endif()
+
+unset(__CMAKE_OBJCXX_COMPILER_OUTPUT)
diff --git a/cmake/FindLibEIO.cmake b/cmake/FindLibEIO.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..781dcf37702258329a4a27f69b2320109185cdcf
--- /dev/null
+++ b/cmake/FindLibEIO.cmake
@@ -0,0 +1,17 @@
+find_path(LIBEIO_INCLUDE_DIR NAMES eio.h)
+find_library(LIBEIO_LIBRARIES NAMES eio)
+
+if(LIBEIO_INCLUDE_DIR AND LIBEIO_LIBRARIES)
+    set(LIBEIO_FOUND ON)
+endif(LIBEIO_INCLUDE_DIR AND LIBEIO_LIBRARIES)
+
+if(LIBEIO_FOUND)
+    if (NOT LIBEIO_FIND_QUIETLY)
+        message(STATUS "Found libeio includes: ${LIBEIO_INCLUDE_DIR}/eio.h")
+        message(STATUS "Found libeio library: ${LIBEIO_LIBRARIES}")
+    endif (NOT LIBEIO_FIND_QUIETLY)
+else(LIBEIO_FOUND)
+    if (LIBEIO_FIND_REQUIRED)
+        message(FATAL_ERROR "Could not find libeio development files")
+    endif (LIBEIO_FIND_REQUIRED)
+endif (LIBEIO_FOUND)
diff --git a/cmake/FindLibEV.cmake b/cmake/FindLibEV.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..8445215808a7e740ca4ad87054976c202f8586b7
--- /dev/null
+++ b/cmake/FindLibEV.cmake
@@ -0,0 +1,17 @@
+find_path(LIBEV_INCLUDE_DIR NAMES ev.h)
+find_library(LIBEV_LIBRARIES NAMES ev)
+
+if(LIBEV_INCLUDE_DIR AND LIBEV_LIBRARIES)
+    set(LIBEV_FOUND ON)
+endif(LIBEV_INCLUDE_DIR AND LIBEV_LIBRARIES)
+
+if(LIBEV_FOUND)
+    if (NOT LIBEV_FIND_QUIETLY)
+        message(STATUS "Found libev includes: ${LIBEV_INCLUDE_DIR}/ev.h")
+        message(STATUS "Found libev library: ${LIBEV_LIBRARIES}")
+    endif (NOT LIBEV_FIND_QUIETLY)
+else(LIBEV_FOUND)
+    if (LIBEV_FIND_REQUIRED)
+        message(FATAL_ERROR "Could not find libev development files")
+    endif (LIBEV_FIND_REQUIRED)
+endif (LIBEV_FOUND)
diff --git a/cmake/FindLibOBJC.cmake b/cmake/FindLibOBJC.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..7140c8e8d9a547cf0155d31542e06d673c43a2fe
--- /dev/null
+++ b/cmake/FindLibOBJC.cmake
@@ -0,0 +1,18 @@
+# Current we are not support GNUstep libraries
+find_path(LIBOBJC_INCLUDE_DIR NAMES objc/Object.h)
+find_library(LIBOBJC_LIBRARIES NAMES objc)
+
+if(LIBOBJC_INCLUDE_DIR AND LIBOBJC_LIBRARIES)
+    set(LIBOBJC_FOUND ON)
+endif(LIBOBJC_INCLUDE_DIR AND LIBOBJC_LIBRARIES)
+
+if(LIBOBJC_FOUND)
+    if (NOT LIBOBJC_FIND_QUIETLY)
+        message(STATUS "Found libobjc includes: ${LIBOBJC_INCLUDE_DIR}/objc")
+        message(STATUS "Found libobjc library: ${LIBOBJC_LIBRARIES}")
+    endif (NOT LIBOBJC_FIND_QUIETLY)
+else(LIBOBJC_FOUND)
+    if (LIBOBJC_FIND_REQUIRED)
+        message(FATAL_ERROR "Could not find libobjc development files")
+    endif (LIBOBJC_FIND_REQUIRED)
+endif (LIBOBJC_FOUND)
diff --git a/cmake/check_objective_c_compiler.cmake b/cmake/check_objective_c_compiler.cmake
deleted file mode 100644
index 7f7eff086010e4c2ef4b4d5a20942ddf4a089f80..0000000000000000000000000000000000000000
--- a/cmake/check_objective_c_compiler.cmake
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Check if CXX compiler can compile ObjectiveC sources.
-#  The code was borrowed from CMakeTestCXXCompiler.cmake
-#
-IF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS)
-  MESSAGE(STATUS "Check for working ObjectiveC compiler: ${CMAKE_CXX_COMPILER}...")
-  FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXObjectiveCCompiler.m 
-    "int main(){return 0;}\n")
-  TRY_COMPILE(CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS ${CMAKE_BINARY_DIR} 
-    ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXObjectiveCCompiler.m
-    OUTPUT_VARIABLE OUTPUT)
-  SET(CXX_OBJECTIVEC_TEST_WAS_RUN 1)
-ENDIF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS)
-IF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS)
-  MESSAGE(STATUS "Check for working ObjectiveC compiler: ${CMAKE_CXX_COMPILER} -- broken")
-  FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
-    "Determining if the ObjectiveC compiler works failed with "
-    "the following output:\n${OUTPUT}\n\n")
-  MESSAGE(FATAL_ERROR "Compiler \"${CMAKE_CXX_COMPILER}\" "
-    "is not able to compile a simple ObjectiveC test program."
-    " Please check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "
-    "to see how it fails. "
-    "CMake will not be able to correctly generate this project.")
-ELSE(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS)
-  IF(CXX_OBJECTIVEC_TEST_WAS_RUN)
-    MESSAGE(STATUS "Check for working ObjectiveC compiler: ${CMAKE_CXX_COMPILER} -- works")
-    FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
-      "Determining if the (ObjectiveC) compiler works passed with "
-      "the following output:\n${OUTPUT}\n\n")
-  ENDIF(CXX_OBJECTIVEC_TEST_WAS_RUN)
-  SET(CMAKE_CXX_OBJETIVEC_COMPILER_WORKS 1 CACHE INTERNAL "")
-ENDIF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS)
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index e59e9f9ebb549d4b099c4a1f857b18c6af3b919d..6cada535870f4bc6b0196beca7e481c179088b7f 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -1,36 +1,39 @@
-include(cmake/check_objective_c_compiler.cmake)
+#
+# Check if ObjectiveC and ObjectiveC++ compilers work
+#
+include(CMakeTestOBJCCompiler)
+include(CMakeTestOBJCXXCompiler)
+
+#
+# Check if the same compile family is used for both C and CXX
+#
+if (NOT (CMAKE_C_COMPILER_ID STREQUAL CMAKE_CXX_COMPILER_ID))
+    message(WARNING "CMAKE_C_COMPILER_ID (${CMAKE_C_COMPILER_ID}) is different "
+                    "from CMAKE_CXX_COMPILER_ID (${CMAKE_CXX_COMPILER_ID})."
+                    "The final binary may be unusable.")
+endif()
 
 # We support building with Clang and gcc. First check 
 # what we're using for build.
-if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
-    set(CMAKE_COMPILER_IS_CLANG true)
-    set(CMAKE_COMPILER_IS_GNUCC false)
+#
+if (CMAKE_C_COMPILER_ID STREQUAL Clang)
+    set(CMAKE_COMPILER_IS_CLANG  ON)
+    set(CMAKE_COMPILER_IS_GNUCC  OFF)
+    set(CMAKE_COMPILER_IS_GNUCXX OFF)
 endif()
 
-# Check Gcc version:
+# Check GCC version:
 # GCC older than 4.1 is not supported.
 if (CMAKE_COMPILER_IS_GNUCC)
-	execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
-			OUTPUT_VARIABLE GCC_VERSION)
-	if (GCC_VERSION VERSION_GREATER 4.1 OR GCC_VERSION VERSION_EQUAL 4.1)
-		message(STATUS "GCC Version >= 4.1 -- ${GCC_VERSION}")
-	else()
-	    message (FATAL_ERROR "GCC version should be >= 4.1 -- ${GCC_VERSION}")
-	endif()
-endif()
-
-
-#
-# Tarantool uses 'coro' (coroutines) library to implement
-# cooperative multi-tasking. Since coro.h is included
-# universally, define the underlying implementation switch
-# in the top level CMakeLists.txt, to ensure a consistent
-# header file layout across the entire project.
-#
-if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "amd64")
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCORO_ASM")
-else()
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCORO_SJLJ")
+    execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+        OUTPUT_VARIABLE CC_VERSION)
+    if (CC_VERSION VERSION_GREATER 4.1 OR CC_VERSION VERSION_EQUAL 4.1)
+        message(STATUS
+            "${CMAKE_C_COMPILER} version >= 4.1 -- ${CC_VERSION}")
+    else()
+        message (FATAL_ERROR
+            "${CMAKE_C_COMPILER} version should be >= 4.1 -- ${CC_VERSION}")
+    endif()
 endif()
 
 #
@@ -42,8 +45,17 @@ else()
     set (CC_DEBUG_OPT "-g")
 endif()
 
-set (CMAKE_C_FLAGS_DEBUG "${CC_DEBUG_OPT} -O0")
-set (CMAKE_C_FLAGS_RELWITHDEBUGINFO "${CC_DEBUG_OPT} -O2")
+set (CMAKE_C_FLAGS_DEBUG
+    "${CMAKE_C_FLAGS_DEBUG} ${CC_DEBUG_OPT} -O0")
+set (CMAKE_C_FLAGS_RELWITHDEBUGINFO
+    "${CMAKE_C_FLAGS_RELWITHDEBUGINFO} ${CC_DEBUG_OPT} -O2")
+set (CMAKE_CXX_FLAGS_DEBUG
+    "${CMAKE_CXX_FLAGS_DEBUG} ${CC_DEBUG_OPT} -O0")
+set (CMAKE_CXX_FLAGS_RELWITHDEBUGINFO
+    "${CMAKE_CXX_FLAGS_RELWITHDEBUGINFO} ${CC_DEBUG_OPT} -O2")
+
+unset(CC_DEBUG_OPT)
+
 #
 # Set flags for all include files: those maintained by us and
 # coming from third parties.
@@ -55,71 +67,85 @@ set (CMAKE_C_FLAGS_RELWITHDEBUGINFO "${CC_DEBUG_OPT} -O2")
 # internally, we also need to make sure all code is compiled
 # with unwind info.
 #
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer")
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funwind-tables")
-if (CMAKE_COMPILER_IS_GNUCC)
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fgnu89-inline")
-endif()
+
+add_compile_flags("C;CXX"
+    "-fno-omit-frame-pointer"
+    "-fno-stack-protector"
+    "-fexceptions"
+    "-funwind-tables")
+
 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
 # Remove VALGRIND code and assertions in *any* type of release build.
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNDEBUG -DNVALGRIND")
+    add_definitions("-DNDEBUG" "-DNVALGRIND")
 endif()
 
 #
-# GCC started to warn for unused result starting from 4.2, and
-# this is when it introduced -Wno-unused-result
-# GCC can also be built on top of llvm runtime (on mac).
+# Enable @try/@catch/@finaly syntax in Objective C code.
 #
-check_c_compiler_flag("-Wno-unused-result" CC_HAS_WNO_UNUSED_RESULT)
-check_c_compiler_flag("-Wno-unused-value" CC_HAS_WNO_UNUSED_VALUE)
-check_c_compiler_flag("-fno-strict-aliasing" CC_HAS_FNO_STRICT_ALIASING)
-check_c_compiler_flag("-Wno-comment" CC_HAS_WNO_COMMENT)
+add_compile_flags("OBJC;OBJCXX"
+    "-fobjc-exceptions")
 
-check_c_compiler_flag("-Wno-parentheses" CC_HAS_WNO_PARENTHESES)
+#
+# Invoke C++ constructors/destructors in the Objective C class instances.
+#
+add_compile_flags("OBJCXX" "-fobjc-call-cxx-cdtors")
 
 #
-# Tarantool code is written in GNU C dialect.
-# Additionally, compile it with more strict flags than the rest
-# of the code.
+# Assume that all Objective-C message dispatches (e.g., [receiver message:arg])
+# ensure that the receiver is not nil. This allows for more efficient entry
+# points in the runtime to be used
 #
-set (core_cflags "${core_cflags} -Wno-sign-compare")
-set (core_cflags "${core_cflags} -Wno-strict-aliasing")
-set (core_cflags "${core_cflags} -std=gnu99")
-if(CMAKE_COMPILER_IS_GNUCC)
-    set (core_cflags "${core_cflags} -Wall -Wextra")
-elseif(CMAKE_COMPILER_IS_CLANG AND CC_HAS_WNO_UNUSED_RESULT)
-    set (core_cflags "${core_cflags} -Wno-unused-result")
+if (CMAKE_COMPILER_IS_GNUCC)
+    add_compile_flags("OBJC;OBJCXX"
+        "-fno-nil-receivers")
 endif()
 
-# Only add -Werror if it's a debug build, done by developers.
-# Community builds should not cause extra trouble.
-if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
-    set (core_cflags "${core_cflags} -Werror")
+if (CMAKE_COMPILER_IS_CLANG)
+    add_compile_flags("OBJC"
+        "-fobjc-nonfragile-abi"
+        "-fno-objc-legacy-dispatch")
 endif()
 
-# Mac ports get installed into /opt/local, hence:
-if (TARGET_OS_DARWIN)
-    include_directories("/opt/local/include")
-    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/local/lib")
+if (CMAKE_COMPILER_IS_CLANGXX)
+    add_compile_flags("OBJCXX"
+        "-fobjc-nonfragile-abi"
+        "-fno-objc-legacy-dispatch")
+elseif(CMAKE_COMPILER_IS_GNUCXX)
+    # Suppress deprecated warnings in objc/runtime-deprecated.h
+    add_compile_flags("OBJCXX"
+        " -Wno-deprecated-declarations")
 endif()
 
-# Require pthread globally if compiling with gcc
-if (CMAKE_COMPILER_IS_GNUCC)
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
-endif()
+macro(enable_tnt_compile_flags)
+    # Tarantool code is written in GNU C dialect.
+    # Additionally, compile it with more strict flags than the rest
+    # of the code.
+
+    add_compile_flags("C;OBJC" "-std=gnu99")
+    add_compile_flags("CXX;OBJCXX" "-std=gnu++11 -fno-rtti")
+
+    add_compile_flags("C;CXX"
+        "-Wall"
+        "-Wextra"
+        "-Wno-sign-compare"
+        "-Wno-strict-aliasing"
+    )
+
+    # Only add -Werror if it's a debug build, done by developers using GCC.
+    # Community builds should not cause extra trouble.
+    if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND CMAKE_COMPILER_IS_GNUCC)
+        add_compile_flags("C;CXX" "-Werror")
+    endif()
+endmacro(enable_tnt_compile_flags)
 
-# CMake believes that Objective C is a flavor of C++, not C,
-# and uses g++ compiler for .m files. Since talking CMake out
-# of this idea is difficult, and since gcc or g++ are only
-# front-ends to the language-specific compiler specified in
-# -x option, simply use CXX flags to build Objective C files.
-set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
 #
-# To enable @try/@catch/@finaly syntax in Objective C code,
-# gcc requires this flag.
+# GCC started to warn for unused result starting from 4.2, and
+# this is when it introduced -Wno-unused-result
+# GCC can also be built on top of llvm runtime (on mac).
 #
-if (CMAKE_COMPILER_IS_GNUCC)
-    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-exceptions")
-endif()
+
+check_c_compiler_flag("-Wno-unused-result" CC_HAS_WNO_UNUSED_RESULT)
+check_c_compiler_flag("-Wno-unused-value" CC_HAS_WNO_UNUSED_VALUE)
+check_c_compiler_flag("-fno-strict-aliasing" CC_HAS_FNO_STRICT_ALIASING)
+check_c_compiler_flag("-Wno-comment" CC_HAS_WNO_COMMENT)
+check_c_compiler_flag("-Wno-parentheses" CC_HAS_WNO_PARENTHESES)
diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake
index b3bfd171aaeb9f7a7d87994d61787666a6b0585c..5a44aa9fed92e53134e55e02a30162119773c0b7 100644
--- a/cmake/luajit.cmake
+++ b/cmake/luajit.cmake
@@ -63,10 +63,10 @@ endmacro()
 # usable with the server (determined by a compiled test).
 #
 macro (luajit_try_system)
-    find_path (LUAJIT_INCLUDE lua.h PATH_SUFFIXES luajit-2.0 luajit)
+    find_path (LUAJIT_INCLUDE lj_obj.h PATH_SUFFIXES luajit-2.0 luajit)
     find_library (LUAJIT_LIB NAMES luajit luajit-5.1 PATH_SUFFIXES x86_64-linux-gnu)
-    message (STATUS "include: ${LUAJIT_INCLUDE}, lib: ${LUAJIT_LIB}")
     if (LUAJIT_INCLUDE AND LUAJIT_LIB)
+        message (STATUS "include: ${LUAJIT_INCLUDE}, lib: ${LUAJIT_LIB}")
         message (STATUS "Found a system-wide LuaJIT.")
         luajit_test()
         if ("${LUAJIT_RUNS}" STREQUAL "1")
@@ -76,8 +76,8 @@ macro (luajit_try_system)
 	        luajit_use_bundled()
         endif()
     else()
-        message (STATUS "Not found a system LuaJIT, using the bundled one.")
-        luajit_use_bundled()
+        message (FATAL_ERROR "Not found a system LuaJIT")
+        #luajit_use_bundled()
     endif()
 endmacro()
 
@@ -125,12 +125,12 @@ endif()
 unset (LUAJIT_RUNS)
 include_directories("${LUAJIT_INCLUDE}")
 
-message (STATUS "LuaJIT include: ${LUAJIT_INCLUDE}")
-message (STATUS "LuaJIT lib: ${LUAJIT_LIB}")
+message (STATUS "Use LuaJIT includes: ${LUAJIT_INCLUDE}")
+message (STATUS "Use LuaJIT library: ${LUAJIT_LIB}")
 
 macro(luajit_build)
     set (luajit_buildoptions BUILDMODE=static)
-    set (luajit_copt ${CCOPT})
+    set (luajit_copt ${CMAKE_C_FLAGS})
     if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
         set (luajit_buildoptions ${luajit_buildoptions} CCDEBUG=${CC_DEBUG_OPT})
         set (luajit_copt ${luajit_copt} -O1)
@@ -143,8 +143,10 @@ macro(luajit_build)
     if (NOT luajit_cc)
         message (FATAL_ERROR "LuaJIT will not compile with default C compiler (cc)")
     endif()
+    separate_arguments(luajit_copt UNIX_COMMAND "${luajit_copt}")
+    separate_arguments(luajit_ldflags UNIX_COMMAND "${CMAKE_SHARED_LINKER_FLAGS}")
     set (luajit_buildoptions ${luajit_buildoptions} CC="${luajit_cc}" TARGET_CC="${luajit_cc}" CCOPT="${luajit_copt}")
-    set (luajit_buildoptions ${luajit_buildoptions} Q='')
+    set (luajit_buildoptions ${luajit_buildoptions} Q='' LDFLAGS="${luajit_ldflags}")
     if (${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
         add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/third_party/luajit/src/libluajit.a
             WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/third_party/luajit
diff --git a/cmake/os.cmake b/cmake/os.cmake
index e0490244a6cab7ac52f2aa5089554cd22be47c3b..93b77a6d72db46dbd4ea4383551fa862b383fccf 100644
--- a/cmake/os.cmake
+++ b/cmake/os.cmake
@@ -5,24 +5,27 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     set(TARGET_OS_LINUX 1)
 #
 # Enable GNU glibc extentions.
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
+    add_definitions("-D_GNU_SOURCE")
 #
 # On 32-bit systems, support files larger than 2GB
 # (see man page for feature_test_macros).
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
+    add_definitions("-D_FILE_OFFSET_BITS=64")
     message(STATUS "Building for Linux")
 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
     set(TARGET_OS_FREEBSD 1)
     set(TARGET_OS_DEBIAN_FREEBSD 1)
 # Debian/kFreeBSD uses GNU glibc.
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
+    add_definitions("-D_GNU_SOURCE")
+    add_definitions("-D_FILE_OFFSET_BITS=64")
     message(STATUS "Building for Debian/kFreeBSD")
 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
     set(TARGET_OS_FREEBSD 1)
     message(STATUS "Building for FreeBSD")
 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
     set(TARGET_OS_DARWIN 1)
+    # Mac ports get installed into /opt/local, hence:
+    include_directories("/opt/local/include")
+    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/local/lib")
     message(STATUS "Building for Mac OS X")
 else()
     message (FATAL_ERROR "Unsupported platform -- ${CMAKE_SYSTEM_NAME}")
diff --git a/cmake/profile.cmake b/cmake/profile.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..3d5d570d0254313e32d8e730988acc9e48b517bc
--- /dev/null
+++ b/cmake/profile.cmake
@@ -0,0 +1,38 @@
+check_library_exists (gcov __gcov_flush  ""  HAVE_GCOV)
+
+if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+    set(ENABLE_GCOV_DEFAULT ON)
+else()
+    set(ENABLE_GCOV_DEFAULT OFF)
+endif()
+option(ENABLE_GCOV "Enable integration with gcov, a code coverage program" ${ENABLE_GCOV_DEFAULT})
+
+if (ENABLE_GCOV)
+    if (NOT HAVE_GCOV)
+    message (FATAL_ERROR
+         "ENABLE_GCOV option requested but gcov library is not found")
+    endif()
+
+    add_compile_flags("C;CXX"
+        "-fprofile-arcs"
+        "-ftest-coverage"
+    )
+
+    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs")
+    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ftest-coverage")
+    set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs")
+    set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage")
+
+   # add_library(gcov SHARED IMPORTED)
+endif()
+
+if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+    set(ENABLE_GPROF_DEFAULT ON)
+else()
+    set(ENABLE_GPROF_DEFAULT OFF)
+endif()
+option(ENABLE_GPROF "Enable integration with gprof, a performance analyzing tool" ${GPROF_DEFAULT})
+
+if (ENABLE_GPROF)
+    add_compile_flags("C;CXX" "-pg")
+endif()
diff --git a/cmake/utils.cmake b/cmake/utils.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..1400bf116975eae74035ec3d5f681f0faacd267f
--- /dev/null
+++ b/cmake/utils.cmake
@@ -0,0 +1,38 @@
+macro(add_compile_flags langs)
+    foreach(_lang ${langs})
+        string (REPLACE ";" " " _flags "${ARGN}")
+        set ("CMAKE_${_lang}_FLAGS" "${CMAKE_${_lang}_FLAGS} ${_flags}")
+        unset (${_lang})
+        unset (${_flags})
+    endforeach()
+endmacro(add_compile_flags)
+
+macro(set_source_files_compile_flags)
+    foreach(file ${ARGN})
+        get_filename_component(_file_ext ${file} EXT)
+        set(_lang "")
+        if ("${_file_ext}" STREQUAL ".m")
+            set(_lang OBJC)
+            # CMake believes that Objective C is a flavor of C++, not C,
+            # and uses g++ compiler for .m files.
+            # LANGUAGE property forces CMake to use CC for ${file}
+            set_source_files_properties(${file} PROPERTIES LANGUAGE C)
+        elseif("${_file_ext}" STREQUAL ".mm")
+            set(_lang OBJCXX)
+        endif()
+
+        if (_lang)
+            get_source_file_property(_flags ${file} COMPILE_FLAGS)
+            if ("${_flags}" STREQUAL "NOTFOUND")
+                set(_flags "${CMAKE_${_lang}_FLAGS}")
+            else()
+                set(_flags "${_flags} ${CMAKE_${_lang}_FLAGS}")
+            endif()
+            # message(STATUS "Set (${file} ${_flags}")
+            set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS
+                "${_flags}")
+        endif()
+    endforeach()
+    unset(_file_ext)
+    unset(_lang)
+endmacro(set_source_files_compile_flags)
diff --git a/include/config.h.cmake b/include/config.h.cmake
index 73fed9f71134a5787acd8a4927446336835cf631..b90df4cc4a71194b7f9eecfafdd36dc3d82e7801 100644
--- a/include/config.h.cmake
+++ b/include/config.h.cmake
@@ -73,6 +73,12 @@
  * Defined if this is a big-endian system.
  */
 #cmakedefine HAVE_BYTE_ORDER_BIG_ENDIAN 1
+
+#cmakedefine ENABLE_BUNDLED_LIBOBJC 1
+#cmakedefine ENABLE_BUNDLED_LIBEV 1
+#cmakedefine ENABLE_BUNDLED_LIBEIO 1
+#cmakedefine ENABLE_BUNDLED_LIBCORO 1
+
 /*
  * predefined /etc directory prefix.
  */
@@ -81,8 +87,11 @@
 #define BUILD_TYPE "@CMAKE_BUILD_TYPE@"
 #define BUILD_INFO "@TARANTOOL_BUILD@"
 #define BUILD_OPTIONS "cmake . @TARANTOOL_OPTIONS@"
-#define COMPILER_INFO "@TARANTOOL_COMPILER@"
-#define COMPILER_CFLAGS "@CMAKE_C_FLAGS@ @core_cflags@"
+#define COMPILER_INFO "@CMAKE_C_COMPILER@ @CMAKE_CXX_COMPILER@"
+#define COMPILER_C_FLAGS "@CMAKE_C_FLAGS@"
+#define COMPILER_CXX_FLAGS "@CMAKE_CXX_FLAGS@"
+#define COMPILER_OBJC_FLAGS "@CMAKE_C_FLAGS@ @CMAKE_OBJC_FLAGS@"
+#define COMPILER_OBJCXX_FLAGS "@CMAKE_CXX_FLAGS@ @CMAKE_OBJCXX_FLAGS@"
 /*
  * vim: syntax=c
  */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8bf56024b1f2415d71e4a1e316f5dc4f65cb6c5b..d4dbfa486100af95f324917bda3e0c979bbab80d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,57 +1,12 @@
 #
-# libev library
+# Set compile flags for entire src/ directory
 #
-add_library(ev tarantool_ev.c)
+enable_tnt_compile_flags()
 
-if (CC_HAS_WNO_UNUSED_RESULT)
-    set (ev_flags "-Wno-unused-result")
+# Require pthread globally if compiling with GCC
+if (CMAKE_COMPILER_IS_GNUCC)
+    add_compile_flags("C;CXX" "-pthread")
 endif()
-if (CC_HAS_WNO_UNUSED_VALUE)
-    set (ev_flags "${ev_flags} -Wno-unused-value")
-endif()
-if(CC_HAS_WNO_COMMENT)
-    set (ev_flags "${ev_flags} -Wno-comment")
-endif()
-if(CC_HAS_FNO_STRICT_ALIASING)
-    set (ev_flags "${ev_flags} -fno-strict-aliasing")
-endif()
-if (CC_HAS_WNO_PARENTHESES)
-    set (ev_flags "${ev_flags} -Wno-parentheses")
-endif()
-set_source_files_properties(tarantool_ev.c
-    PROPERTIES COMPILE_FLAGS "${ev_flags}")
-unset (ev_flags)
-
-if (TARGET_OS_LINUX)
-#
-# Enable Linux-specific event notification API (man inotify)
-  set_target_properties(ev PROPERTIES COMPILE_FLAGS "-DEV_USE_INOTIFY")
-elseif (TARGET_OS_FREEBSD)
-#
-# On FreeBSD build libev loop on top of
-  set_target_properties(ev PROPERTIES COMPILE_FLAGS "-DEV_USE_KQUEUE")
-endif()
-
-#
-# libev uses ceil and floor from the standard math library
-#
-
-#
-# libev depends on librt under kFreeBSD
-if (TARGET_OS_DEBIAN_FREEBSD)
-  set (ev_libs m rt)
-else()
-  set (ev_libs m)
-endif()
-
-target_link_libraries(ev ${ev_libs})
-
-#
-# libeio library
-#
-set_source_files_properties(tarantool_eio.c
-    PROPERTIES COMPILE_FLAGS "-Wno-unused-value -Wno-dangling-else")
-add_library(eio tarantool_eio.c)
 
 #
 # Build admin.m from admin.rl, but only if admin.rl was changed.
@@ -148,29 +103,33 @@ if (ENABLE_TRACE)
     set (common_sources ${common_sources} trace.m)
 endif()
 
+set_source_files_compile_flags(${common_sources})
 add_library(core STATIC ${common_sources})
 add_dependencies(core generate_headers)
-set_target_properties(core PROPERTIES COMPILE_FLAGS "${core_cflags}")
 
-set (common_libraries cfg core ev eio coro gopt misc)
+set (common_libraries cfg core)
+
+list(APPEND common_libraries
+    ${LIBEV_LIBRARIES}
+    ${LIBEIO_LIBRARIES}
+    ${LIBCORO_LIBRARIES}
+    ${LIBGOPT_LIBRARIES}
+    ${LUAJIT_LIB}
+    ${LIBOBJC_LIBRARIES}
+    misc
+)
 
 set (THREAD_LIB pthread)
 if (ENABLE_STATIC)
     set (THREAD_LIB -Wl,--whole-archive pthread -Wl,--no-whole-archive)
 endif()
 
-set (common_libraries ${common_libraries} ${LUAJIT_LIB} ${LIBOBJC_LIB} ${THREAD_LIB})
+set (common_libraries ${common_libraries} ${THREAD_LIB})
 
 if (TARGET_OS_LINUX OR TARGET_OS_DEBIAN_FREEBSD)
     set (common_libraries ${common_libraries} dl)
 endif()
 
-if (ENABLE_GCOV)
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCOV_C_FLAGS}")
-    set (LDFLAGS "${LDFLAGS} ${GCOV_LDFLAGS}")
-    set (common_libraries ${common_libraries} gcov)
-endif()
-
 if (ENABLE_BACKTRACE AND HAVE_BFD)
     set (common_libraries ${common_libraries} bfd)
     if (NOT TARGET_OS_DARWIN)
@@ -186,9 +145,15 @@ set (common_libraries ${common_libraries} PARENT_SCOPE)
 
 function(tarantool_module mod)
     set (module_sources ${ARGN})
+    set(cfg_c_flags "-Wno-unused -Wno-unused-parameter")
+    if (CMAKE_COMPILER_IS_CLANG)
+        set(cfg_c_flags "${cfg_c_flags} -Wno-semicolon-before-method-body")
+    endif()
     set_source_files_properties(
         ${CMAKE_SOURCE_DIR}/cfg/tarantool_${mod}_cfg.c
-        PROPERTIES COMPILE_FLAGS "-Wno-unused" GENERATED True)
+        PROPERTIES COMPILE_FLAGS ${cfg_c_flags}
+        GENERATED True)
+    unset(cfg_c_flags)
     add_executable(tarantool_${mod}
         ${module_sources}
         ${CMAKE_SOURCE_DIR}/cfg/tarantool_${mod}_cfg.c)
@@ -197,14 +162,15 @@ function(tarantool_module mod)
         PROPERTIES OBJECT_DEPENDS
         ${CMAKE_SOURCE_DIR}/cfg/tarantool_${mod}_cfg.h)
 
+    set_source_files_compile_flags(
+        ${recompiled_sources} ${module_sources})
+
     add_library(lt${mod} STATIC ${recompiled_sources})
     set_target_properties(lt${mod} PROPERTIES COMPILE_FLAGS
-        "${core_cflags} ${GCOV_C_FLAGS} -DTARANTOOL_CONFIG='<cfg/tarantool_${mod}_cfg.h>'")
+        "-DTARANTOOL_CONFIG='<cfg/tarantool_${mod}_cfg.h>'")
     add_dependencies(lt${mod} generate_headers generate_admin_m generate_memcached_grammar_m build_bundled_libs)
 
-    target_link_libraries(tarantool_${mod} lt${mod} ${GCOV_LDFLAGS} ${common_libraries})
-    set_target_properties(tarantool_${mod} PROPERTIES COMPILE_FLAGS
-        "${core_cflags} ${GCOV_C_FLAGS}")
+    target_link_libraries(tarantool_${mod} lt${mod} ${common_libraries})
 
     if (ENABLE_STATIC)
         set_target_properties(tarantool_${mod} PROPERTIES
diff --git a/src/box/index.m b/src/box/index.m
index b7c98f69c4b1ce062a4c2543844e45067c66d824..c105cb4a30c7d5a0d7b6c79679f61fd7f16e6458 100644
--- a/src/box/index.m
+++ b/src/box/index.m
@@ -115,7 +115,7 @@ replace_check_dup(struct tuple *old_tuple,
 	return NULL;
 }
 
-- (id) init: (struct key_def *) key_def_arg :(struct space *) space_arg;
+- (id) init: (struct key_def *) key_def_arg :(struct space *) space_arg
 {
 	self = [super init];
 	if (self == NULL)
diff --git a/src/box/tree_index.m b/src/box/tree_index.m
index 69b8ded31230fafaea3295f0571b9da7a0a2845a..3dcb7c8c2d9ae1314676aabfe5d4eb625b3b63a1 100644
--- a/src/box/tree_index.m
+++ b/src/box/tree_index.m
@@ -891,6 +891,7 @@ tree_iterator_gt(struct iterator *iterator)
 		return [FixedTreeIndex alloc];
 	default:
 		assert(false);
+		return 0;
 	}
 }
 
diff --git a/src/evio.m b/src/evio.m
index c5539d1c4be8bd58b5a5e3bae2696575ab7ce17a..83a2080e97e0824b04750175663adcc06475b00b 100644
--- a/src/evio.m
+++ b/src/evio.m
@@ -32,6 +32,10 @@
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
 
+#if EV_MULTIPLICITY
+#error libev with enabled EV_MULTIPLICITY is not supported yet
+#endif
+
 #define BIND_RETRY_DELAY 0.1
 
 void
diff --git a/src/lua/info.m b/src/lua/info.m
index 48f09a7622b67c15e651f20958d4835859446c34..e36d4c00c09cee851bd15c19629e0195cc85451e 100644
--- a/src/lua/info.m
+++ b/src/lua/info.m
@@ -163,7 +163,7 @@ lbox_info_init_static_values(struct lua_State *L)
 
 	/* box.info.build.flags */
 	lua_pushstring(L, "flags");
-	lua_pushstring(L, COMPILER_CFLAGS);
+	lua_pushstring(L, COMPILER_C_FLAGS);
 	lua_settable(L, -3);
 
 	lua_settable(L, -3);    /* box.info.build */
diff --git a/src/sio.m b/src/sio.m
index 8e5d4eec6c8b1b48cd0353c8af53d3db02cdab8a..7ac6bfaf5fee70774878a75bc697c6b8118b0086 100644
--- a/src/sio.m
+++ b/src/sio.m
@@ -31,6 +31,7 @@
 #include <sys/uio.h>
 #include <errno.h>
 #include <stdio.h>
+#include <limits.h>
 #include <netinet/tcp.h> /* TCP_NODELAY */
 #include <arpa/inet.h> /* inet_ntoa */
 
diff --git a/src/tarantool.m b/src/tarantool.m
index 5045f24eaf0c16ce0a9ca3746db3397605280872..ea54b0dac6d27f1b0293024b4f6e1f5ef6999a57 100644
--- a/src/tarantool.m
+++ b/src/tarantool.m
@@ -567,14 +567,14 @@ background()
 	close(STDERR_FILENO);
 	return;
 error:
-        exit(EXIT_FAILURE);
+	exit(EXIT_FAILURE);
 }
 
 void
 tarantool_free(void)
 {
 	/*
-	 * Got to be done prior to anything else, since GC 
+	 * Got to be done prior to anything else, since GC
 	 * handlers can refer to other subsystems (e.g. fibers).
 	 */
 	if (tarantool_L)
@@ -685,7 +685,7 @@ main(int argc, char **argv)
 		printf("Target: %s\n", BUILD_INFO);
 		printf("Build options: %s\n", BUILD_OPTIONS);
 		printf("Compiler: %s\n", COMPILER_INFO);
-		printf("CFLAGS:%s\n", COMPILER_CFLAGS);
+		printf("C_FLAGS:%s\n", COMPILER_C_FLAGS);
 		return 0;
 	}
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0d2a43e561cf21d7c79aadbc9b151c4f5d73dede..9af2734410bf80a5f169fde873c78ea296bb95c2 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,8 +1,13 @@
+enable_tnt_compile_flags()
+
+add_compile_flags("C;CXX"
+    "-Wno-unused-parameter")
+
 add_custom_target(test
-    COMMAND ${PROJECT_SOURCE_DIR}/test/run.sh --builddir=${PROJECT_BINARY_DIR} --vardir=${PROJECT_BINARY_DIR}/test/var)
+    COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py --builddir=${PROJECT_BINARY_DIR} --vardir=${PROJECT_BINARY_DIR}/test/var)
 
 add_custom_target(test-force
-    COMMAND ${PROJECT_SOURCE_DIR}/test/run.sh --builddir=${PROJECT_BINARY_DIR} --force --vardir=${PROJECT_BINARY_DIR}/test/var)
+    COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py --builddir=${PROJECT_BINARY_DIR} --force --vardir=${PROJECT_BINARY_DIR}/test/var)
 
 add_subdirectory(unit)
 add_subdirectory(box)
diff --git a/test/box/args.result b/test/box/args.result
index 120ed0c33883272a018ed7a655dd3940bcfb2352..856d2780ec9729518591c226dcdd62f7f9517746 100644
--- a/test/box/args.result
+++ b/test/box/args.result
@@ -78,14 +78,14 @@ Tarantool/Box 1.minor.patch-<rev>-<commit>
 Target: platform <build>
 Build options: flags
 Compiler: cc
-CFLAGS: flags
+C_FLAGS: flags
 
 tarantool_box -V
 Tarantool/Box 1.minor.patch-<rev>-<commit>
 Target: platform <build>
 Build options: flags
 Compiler: cc
-CFLAGS: flags
+C_FLAGS: flags
 
 #
 # A test case for Bug#726778 "Gopt broke wal_dir and snap_dir: they are no
diff --git a/test/box/args.test b/test/box/args.test
index 5a07380baef23a4b9992c82878534b1a962db26f..56847962f9d67a6094864bb4cbcc4512f3121ee4 100644
--- a/test/box/args.test
+++ b/test/box/args.test
@@ -32,7 +32,10 @@ sys.stdout.pop_filter()
 sys.stdout.push_filter("(\d)\.\d\.\d(-\d+-\w+)?", "\\1.minor.patch-<rev>-<commit>")
 sys.stdout.push_filter("Target: .*", "Target: platform <build>")
 sys.stdout.push_filter("Build options: .*", "Build options: flags")
-sys.stdout.push_filter("CFLAGS: .*", "CFLAGS: flags")
+sys.stdout.push_filter("C_FLAGS:.*", "C_FLAGS: flags")
+sys.stdout.push_filter("CXX_FLAGS:.*", "CXX_FLAGS: flags")
+sys.stdout.push_filter("OBJC_FLAGS:.*", "OBJC_FLAGS: flags")
+sys.stdout.push_filter("OBJCXX_FLAGS:.*", "OBJCXX_FLAGS: flags")
 sys.stdout.push_filter("Compiler: .*", "Compiler: cc")
 
 server.test_option("--version")
diff --git a/test/connector_c/CMakeLists.txt b/test/connector_c/CMakeLists.txt
index 019345e0d9c857b4f0bab88e37bc97b78c213cdd..548a8df56edfd6197f3448795e4eb9befaf3c15c 100644
--- a/test/connector_c/CMakeLists.txt
+++ b/test/connector_c/CMakeLists.txt
@@ -1,5 +1,9 @@
+file(GLOB all_sources *.c *.m *.mm)
+set_source_files_compile_flags("TESTS" ${all_sources})
+
 include_directories("${PROJECT_SOURCE_DIR}/test/unit")
 include_directories("${PROJECT_SOURCE_DIR}/connector/c/include")
+
 tarantool_client("tt" tt.c)
 tarantool_client("update" update.c)
 tarantool_client("xlog" xlog.c)
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 935fadba2a375eeefd5db508fb12a0a04b7a85fb..08db175ca2e9dc6a77421c081cf15077f6cdfc8c 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -1,3 +1,6 @@
+file(GLOB all_sources *.c *.m *.mm)
+set_source_files_compile_flags(${all_sources})
+
 add_executable(rlist rlist.c test.c)
 add_executable(queue queue.c)
 add_executable(mhash mhash.c)
@@ -9,9 +12,8 @@ add_executable(objc_finally objc_finally.m)
 add_executable(objc_catchcxx objc_catchcxx.m)
 add_dependencies(objc_finally build_bundled_libs)
 add_dependencies(objc_catchcxx build_bundled_libs)
-set_target_properties(mhash PROPERTIES COMPILE_FLAGS "-std=c99")
-target_link_libraries(objc_finally ${LIBOBJC_LIB} -lm -pthread)
-target_link_libraries(objc_catchcxx ${LIBOBJC_LIB} ${LUAJIT_LIB} -lm -pthread)
+target_link_libraries(objc_finally ${LIBOBJC_LIBRARIES} -lm -pthread)
+target_link_libraries(objc_catchcxx ${LIBOBJC_LIBRARIES} ${LUAJIT_LIB} -lm -pthread)
 if (TARGET_OS_LINUX OR TARGET_OS_DEBIAN_FREEBSD)
     target_link_libraries(objc_catchcxx dl)
 endif()
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 48fd36ce73aa39beeb8926ad378e9230904d2c4d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -1,19 +0,0 @@
-if (NOT HAVE_MEMMEM)
-    set (misc_opt_sources ${misc_opt_sources} memmem.c)
-endif()
-
-if (NOT HAVE_MEMRCHR)
-    set (misc_opt_sources ${misc_opt_sources} memrchr.c)
-endif()
-
-add_library (misc STATIC crc32.c proctitle.c qsort_arg.c ${misc_opt_sources})
-
-if (NOT TARGET_OS_DEBIAN_FREEBSD) 
-    if (TARGET_OS_FREEBSD)
-      set_source_files_properties(proctitle.c PROPERTIES
-           COMPILE_FLAGS "-DHAVE_SETPROCTITLE")
-    endif()
-endif()
-
-add_subdirectory(coro)
-add_subdirectory(gopt)
diff --git a/third_party/coro/CMakeLists.txt b/third_party/coro/CMakeLists.txt
deleted file mode 100644
index cfa89654d2d7be6b99a9b115d031811aa1700b33..0000000000000000000000000000000000000000
--- a/third_party/coro/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_library(coro STATIC coro.c)
diff --git a/third_party/gopt/CMakeLists.txt b/third_party/gopt/CMakeLists.txt
deleted file mode 100644
index 0b2c7c75bba7773ef52408f8383eab31ecf8452d..0000000000000000000000000000000000000000
--- a/third_party/gopt/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library(gopt STATIC gopt.c)
-set_target_properties(gopt PROPERTIES COMPILE_FLAGS "${core_cflags}")
diff --git a/src/tarantool_eio.c b/third_party/tarantool_eio.c
similarity index 100%
rename from src/tarantool_eio.c
rename to third_party/tarantool_eio.c
diff --git a/include/tarantool_eio.h b/third_party/tarantool_eio.h
similarity index 92%
rename from include/tarantool_eio.h
rename to third_party/tarantool_eio.h
index 241be1b18427f627d6b875f5e400dd427cae4a8a..b8cca642ec53ee708c0e91d7e6cfa0286350e270 100644
--- a/include/tarantool_eio.h
+++ b/third_party/tarantool_eio.h
@@ -29,6 +29,8 @@
  * SUCH DAMAGE.
  */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <fcntl.h> /* Definition of AT_* constants */
 #include <sys/types.h>
@@ -37,5 +39,10 @@
 #include <utime.h>
 #include <unistd.h>
 
+#if defined(ENABLE_BUNDLED_LIBEIO)
 #include "third_party/libeio/eio.h"
+#else /* !defined(ENABLE_BUNDLED_LIBEIO) */
+#include <eio.h>
+#endif
+
 #endif /* TARANTOOL_EIO_H_INCLUDED */
diff --git a/src/tarantool_ev.c b/third_party/tarantool_ev.c
similarity index 100%
rename from src/tarantool_ev.c
rename to third_party/tarantool_ev.c
diff --git a/include/tarantool_ev.h b/third_party/tarantool_ev.h
similarity index 93%
rename from include/tarantool_ev.h
rename to third_party/tarantool_ev.h
index 59db78e2045853828bf4722f80c67e0bc0f5665c..949f535e66375b43feae9a15a2f2285c1bc86d1e 100644
--- a/include/tarantool_ev.h
+++ b/third_party/tarantool_ev.h
@@ -28,24 +28,29 @@
  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#define EV_STANDALONE 1
-#define EV_MULTIPLICITY 0
 
-#define EV_USE_REALTIME 1
+#include "config.h"
+
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#if defined(ENABLE_BUNDLED_LIBEV)
+#define EV_MULTIPLICITY 0
+#define EV_STANDALONE 1
 #define EV_USE_SELECT 1
 #define EV_USE_POLL 1
 #define EV_USE_NANOSLEEP 1
-
+#define EV_USE_REALTIME 1
 #define EV_PERIODIC_ENABLE 1
 #define EV_IDLE_ENABLE 1
 #define EV_STAT_ENABLE 1
 #define EV_FORK_ENABLE 1
 #define EV_CONFIG_H 0
-
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
 #include "third_party/libev/ev.h"
+#else /* !defined(ENABLE_BUNDLED_LIBEV) */
+#include <ev.h>
+#endif
+
 #endif /* TARANTOOL_EV_H_INCLUDED */