# remote block storage
option(WITH_RBD "Remote block storage is here" ON)
+# embedded ceph daemon static library
+# NOTE: Ceph is mostly LGPL (see COPYING), which means that
+# static linking brings with it restrictions. Please be sure
+# to look at the LGPL license carefully before linking this library to
+# your code. See http://www.gnu.org/licenses/gpl-faq.html#LGPLStaticVsDynamic.
+option(WITH_EMBEDDED "build the embedded ceph daemon library" ON)
+
option(WITH_LEVELDB "LevelDB is here" ON)
if(WITH_LEVELDB)
if(LEVELDB_PREFIX)
-DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir} \
-DCMAKE_INSTALL_MANDIR=%{_mandir} \
-DCMAKE_INSTALL_DOCDIR=%{_docdir}/ceph \
+ -DWITH_EMBEDDED=OFF \
-DWITH_MANPAGE=ON \
-DWITH_PYTHON3=ON \
-DWITH_SYSTEMD=ON \
--- /dev/null
+# This function is a helper that will merge static libraries.
+# For example,
+#
+# merge_static_libraries(mylib staticlibX staticlibY)
+#
+# mylib.a will generate a new static library mylib that is
+# a combination of staticlibX and staticlibY
+#
+function(merge_static_libraries target)
+
+ set(dummy_source ${CMAKE_CURRENT_BINARY_DIR}/${target}_dummy.c)
+ add_library(${target} STATIC ${dummy_source})
+
+ # remove duplicates
+ set(libs ${ARGN})
+ list(REMOVE_DUPLICATES libs)
+
+ # validate that all libs are static
+ foreach(lib ${libs})
+ if (NOT TARGET ${lib})
+ message(FATAL_ERROR "${lib} not a valid target")
+ endif()
+
+ get_target_property(libtype ${lib} TYPE)
+ if(NOT libtype STREQUAL "STATIC_LIBRARY")
+ message(FATAL_ERROR "${lib} not a static library")
+ endif()
+
+ # add a dependency on the lib
+ add_dependencies(${target} ${lib})
+ endforeach()
+
+ # Force the merged Make the generated dummy source file depended on all static input
+ # libs. If input lib changes,the source file is touched
+ # which causes the desired effect (relink).
+ add_custom_command(
+ OUTPUT ${dummy_source}
+ COMMAND ${CMAKE_COMMAND} -E touch ${dummy_source}
+ DEPENDS ${libs})
+
+ # only LINUX is currently supported. OSX's libtool and windows lib.exe
+ # have native support for merging static libraries, and support for them
+ # can be easily added if required.
+ if(LINUX)
+ # generate a script to merge the static libraries in to the target
+ # library. see https://sourceware.org/binutils/docs/binutils/ar-scripts.html
+ set(mri_script "open $<TARGET_FILE:${target}>=")
+ foreach(lib ${libs})
+ # we use the generator expression TARGET_FILE to get the location
+ # of the library. this will not be expanded until the script file
+ # is written below
+ set(mri_script "${mri_script} addlib $<TARGET_FILE:${lib}>=")
+ endforeach()
+ set(mri_script "${mri_script} save=end")
+
+ add_custom_command(
+ TARGET ${target} POST_BUILD
+ COMMAND echo ${mri_script} | tr = \\\\n | ${CMAKE_AR} -M)
+ endif(LINUX)
+
+ message("-- MergeStaticLibraries: ${target}: merged ${libs}")
+
+ # we want to set the target_link_libraries correctly for the new merged
+ # static library. First we get the list of link libraries for each
+ # of the libs we are merging
+ set(link_libs)
+ foreach(lib ${libs})
+ get_property(trans TARGET ${lib} PROPERTY LINK_LIBRARIES)
+ list(APPEND link_libs ${trans})
+ endforeach()
+
+ if (link_libs)
+ # now remove the duplicates and any of the libraries we already merged
+ list(REMOVE_DUPLICATES link_libs)
+ foreach(lib ${libs})
+ list(REMOVE_ITEM link_libs ${lib})
+ endforeach()
+
+ # set the target link libraries
+ target_link_libraries(${target} ${link_libs})
+
+ message("-- MergeStaticLibraries: ${target}: remaining ${link_libs}")
+ endif()
+
+endfunction()
export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
-extraopts += -DUSE_CRYPTOPP=OFF -DWITH_OCF=ON -DWITH_LTTNG=ON -DWITH_PYTHON3=ON
+extraopts += -DUSE_CRYPTOPP=OFF -DWITH_OCF=ON -DWITH_LTTNG=ON -DWITH_PYTHON3=ON -DWITH_EMBEDDED=OFF
extraopts += -DWITH_CEPHFS_JAVA=ON
# assumes that ceph is exmpt from multiarch support, so we override the libdir.
extraopts += -DCMAKE_INSTALL_LIBDIR=/usr/lib
endif()
add_subdirectory(script)
+
+if(WITH_EMBEDDED)
+ add_subdirectory(libcephd)
+endif()
--- /dev/null
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LIBCEPHD_VER_MAJOR 0
+#define LIBCEPHD_VER_MINOR 1
+#define LIBCEPHD_VER_PATCH 0
+
+#define LIBCEPHFD_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
+#define LIBCEPHFD_VERSION_CODE LIBCEPHD_VERSION(LIBCEPHD_VER_MAJOR, LIBCEPHD_VER_MINOR, LIBCEPHD_VER_PATCH)
+
+#define CEPH_LIBCEPHD_API __attribute__ ((visibility ("default")))
+
+/**
+ * Get the API version of libcephd. We use semantic versioning
+ * for the API:
+ *
+ * - incrementing major is for backwards-incompatible changes
+ * - incrementing minor is for backwards-compatible changes
+ * - incrementing extra is for bug fixes
+ *
+ * @param pmajor where to store the major version number
+ * @param pminor where to store the minor version number
+ * @param ppatch where to store the patch version number
+ */
+CEPH_LIBCEPHD_API void cephd_version(int *pmajor, int *pminor, int *ppatch);
+
+/**
+ * Gets the runtime version of ceph.
+ *
+ * @param pmajor where to store the major version number
+ * @param pminor where to store the minor version number
+ * @param ppatch where to store the patch version number
+ */
+CEPH_LIBCEPHD_API const char *ceph_version(int *pmajor, int *pminor, int *ppatch);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+include(MergeStaticLibraries)
+
+add_library(cephd_base STATIC
+ libcephd.cc)
+
+set(merge_libs
+ cephd_base
+ mon
+ osd
+ common
+ common_utf8
+ os
+ kv
+ global
+ rocksdb
+ json_spirit)
+
+if(HAVE_ARMV8_CRC)
+ list(APPEND merge_libs common_crc_aarch64)
+endif(HAVE_ARMV8_CRC)
+
+merge_static_libraries(cephd ${merge_libs})
+
+# TODO: install these libraries and add them to rpm and deb packages
+#install(TARGETS cephd DESTINATION ${CMAKE_INSTALL_LIBDIR})
+#install(FILES ../include/cephd/libcephd.h DESTINATION include/cephd)
--- /dev/null
+#include "common/version.h"
+#include "include/cephd/libcephd.h"
+
+extern "C" void cephd_version(int *pmajor, int *pminor, int *ppatch)
+{
+ if (pmajor)
+ *pmajor = LIBCEPHD_VER_MAJOR;
+ if (pminor)
+ *pminor = LIBCEPHD_VER_MINOR;
+ if (ppatch)
+ *ppatch = LIBCEPHD_VER_PATCH;
+}
+
+extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
+{
+ int major, minor, patch;
+ const char *v = ceph_version_to_str();
+
+ int n = sscanf(v, "%d.%d.%d", &major, &minor, &patch);
+ if (pmajor)
+ *pmajor = (n >= 1) ? major : 0;
+ if (pminor)
+ *pminor = (n >= 2) ? minor : 0;
+ if (ppatch)
+ *ppatch = (n >= 3) ? patch : 0;
+ return v;
+}
add_subdirectory(filestore)
add_subdirectory(fs)
add_subdirectory(journal)
+if(WITH_EMBEDDED)
+ add_subdirectory(libcephd)
+endif(WITH_EMBEDDED)
add_subdirectory(libcephfs)
add_subdirectory(librados)
add_subdirectory(librados_test_stub)
--- /dev/null
+# cephdtest
+set(cephdtest_srcs
+ test.cc)
+add_library(cephdtest STATIC ${cephdtest_srcs})
+set_target_properties(cephdtest PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS})
+
+# ceph_test_cephd_api_misc
+add_executable(ceph_test_cephd_api_misc
+ misc.cc
+ )
+set_target_properties(ceph_test_cephd_api_misc PROPERTIES COMPILE_FLAGS
+ ${UNITTEST_CXX_FLAGS})
+target_link_libraries(ceph_test_cephd_api_misc
+ cephd global ${UNITTEST_LIBS} cephdtest z snappy)
+
+install(TARGETS
+ ceph_test_cephd_api_misc
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
--- /dev/null
+#include "gtest/gtest.h"
+#include "include/cephd/libcephd.h"
+
+TEST(LibCephdMiscVersion, Version) {
+ int major, minor, extra;
+ cephd_version(&major, &minor, &extra);
+}
--- /dev/null
+void doNothing() {
+}