# HG changeset patch # User jodogne # Date 1427794829 -7200 # Node ID afaa55d42ddd4ba70c0e1810cbc803cf1882f3bf # Parent a80e811ec619a4a2a96c24f0e1a734055ce08c0c FreeBSD support diff -r a80e811ec619 -r afaa55d42ddd CMakeLists.txt --- a/CMakeLists.txt Mon Mar 30 16:18:46 2015 +0200 +++ b/CMakeLists.txt Tue Mar 31 11:40:29 2015 +0200 @@ -345,7 +345,7 @@ OrthancServer/main.cpp ) -target_link_libraries(Orthanc ServerLibrary CoreLibrary ${STATIC_LUA} ${STATIC_GOOGLE_LOG}) +target_link_libraries(Orthanc ServerLibrary CoreLibrary ${STATIC_LUA} ${STATIC_GOOGLE_LOG} ${DCMTK_LIBRARIES}) if (${OPENSSL_SOURCES_LENGTH} GREATER 0) target_link_libraries(Orthanc OpenSSL) @@ -374,7 +374,7 @@ ${GTEST_SOURCES} ${ORTHANC_UNIT_TESTS_SOURCES} ) -target_link_libraries(UnitTests ServerLibrary CoreLibrary ${STATIC_LUA} ${STATIC_GOOGLE_LOG}) +target_link_libraries(UnitTests ServerLibrary CoreLibrary ${STATIC_LUA} ${STATIC_GOOGLE_LOG} ${DCMTK_LIBRARIES}) if (${OPENSSL_SOURCES_LENGTH} GREATER 0) target_link_libraries(UnitTests OpenSSL) @@ -431,7 +431,8 @@ ) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") + ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") set_target_properties(OrthancClient PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw/VersionScript.map" ) diff -r a80e811ec619 -r afaa55d42ddd Core/MultiThreading/Mutex.cpp --- a/Core/MultiThreading/Mutex.cpp Mon Mar 30 16:18:46 2015 +0200 +++ b/Core/MultiThreading/Mutex.cpp Tue Mar 31 11:40:29 2015 +0200 @@ -37,7 +37,7 @@ #if defined(_WIN32) #include -#elif defined(__linux) || defined(__FreeBSD_kernel__) || defined(__APPLE__) +#elif defined(__linux) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__FreeBSD__) #include #else #error Support your platform here @@ -75,7 +75,7 @@ } -#elif defined(__linux) || defined(__FreeBSD_kernel__) || defined(__APPLE__) +#elif defined(__linux) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__FreeBSD__) struct Mutex::PImpl { diff -r a80e811ec619 -r afaa55d42ddd Core/Toolbox.cpp --- a/Core/Toolbox.cpp Mon Mar 30 16:18:46 2015 +0200 +++ b/Core/Toolbox.cpp Tue Mar 31 11:40:29 2015 +0200 @@ -59,7 +59,7 @@ #include /* PATH_MAX */ #endif -#if defined(__linux) || defined(__FreeBSD_kernel__) +#if defined(__linux) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) #include /* PATH_MAX */ #include #include @@ -116,7 +116,7 @@ { #if defined(_WIN32) ::Sleep(static_cast(microSeconds / static_cast(1000))); -#elif defined(__linux) || defined(__APPLE__) || defined(__FreeBSD_kernel__) +#elif defined(__linux) || defined(__APPLE__) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) usleep(microSeconds); #else #error Support your platform here @@ -503,7 +503,7 @@ return std::string(&buffer[0]); } -#elif defined(__linux) || defined(__FreeBSD_kernel__) +#elif defined(__linux) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) static std::string GetPathToExecutableInternal() { std::vector buffer(PATH_MAX + 1); diff -r a80e811ec619 -r afaa55d42ddd LinuxCompilation.txt --- a/LinuxCompilation.txt Mon Mar 30 16:18:46 2015 +0200 +++ b/LinuxCompilation.txt Tue Mar 31 11:40:29 2015 +0200 @@ -219,6 +219,17 @@ +SUPPORTED - FreeBSD 10.1 +------------------------ + +# pkg install jsoncpp pugixml lua51 curl googletest dcmtk cmake \ + e2fsprogs-libuuid glog boost-libs sqlite3 python libiconv + +# cmake -DALLOW_DOWNLOADS=ON \ + -DUSE_SYSTEM_MONGOOSE=OFF \ + -DDCMTK_LIBRARIES="dcmdsig;charls;dcmjpls" \ + ~/Orthanc + Other Linux distributions? diff -r a80e811ec619 -r afaa55d42ddd NEWS --- a/NEWS Mon Mar 30 16:18:46 2015 +0200 +++ b/NEWS Tue Mar 31 11:40:29 2015 +0200 @@ -1,6 +1,7 @@ Pending changes in the mainline =============================== +* Support of FreeBSD * Prevent freeze on C-FIND if no DICOM tag is to be returned * Fix issue 30 (QR response missing "Query/Retrieve Level" (008,0052)) diff -r a80e811ec619 -r afaa55d42ddd Plugins/Engine/PluginsManager.cpp --- a/Plugins/Engine/PluginsManager.cpp Mon Mar 30 16:18:46 2015 +0200 +++ b/Plugins/Engine/PluginsManager.cpp Tue Mar 31 11:40:29 2015 +0200 @@ -42,7 +42,7 @@ #ifdef WIN32 #define PLUGIN_EXTENSION ".dll" -#elif defined(__linux) || defined(__FreeBSD_kernel__) +#elif defined(__linux) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) #define PLUGIN_EXTENSION ".so" #elif defined(__APPLE__) && defined(__MACH__) #define PLUGIN_EXTENSION ".dylib" diff -r a80e811ec619 -r afaa55d42ddd Plugins/Engine/SharedLibrary.cpp --- a/Plugins/Engine/SharedLibrary.cpp Mon Mar 30 16:18:46 2015 +0200 +++ b/Plugins/Engine/SharedLibrary.cpp Tue Mar 31 11:40:29 2015 +0200 @@ -36,7 +36,7 @@ #if defined(_WIN32) #include -#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) #include #else #error Support your platform here @@ -58,7 +58,7 @@ throw OrthancException(ErrorCode_SharedLibrary); } -#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) handle_ = ::dlopen(path.c_str(), RTLD_NOW); if (handle_ == NULL) { @@ -84,7 +84,7 @@ { #if defined(_WIN32) ::FreeLibrary((HMODULE)handle_); -#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) ::dlclose(handle_); #else #error Support your platform here @@ -102,7 +102,7 @@ #if defined(_WIN32) return ::GetProcAddress((HMODULE)handle_, name.c_str()); -#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) +#elif defined(__linux) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) return ::dlsym(handle_, name.c_str()); #else #error Support your platform here diff -r a80e811ec619 -r afaa55d42ddd Resources/CMake/BoostConfiguration.cmake --- a/Resources/CMake/BoostConfiguration.cmake Mon Mar 30 16:18:46 2015 +0200 +++ b/Resources/CMake/BoostConfiguration.cmake Tue Mar 31 11:40:29 2015 +0200 @@ -56,6 +56,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") list(APPEND BOOST_SOURCES ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/once.cpp diff -r a80e811ec619 -r afaa55d42ddd Resources/CMake/Compiler.cmake --- a/Resources/CMake/Compiler.cmake Mon Mar 30 16:18:46 2015 +0200 +++ b/Resources/CMake/Compiler.cmake Tue Mar 31 11:40:29 2015 +0200 @@ -41,25 +41,24 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR - ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") - if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward -fpermissive") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}") - endif() - - add_definitions( - -D_LARGEFILE64_SOURCE=1 - -D_FILE_OFFSET_BITS=64 - ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") + ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") # Remove the "-rdynamic" option # http://www.mail-archive.com/cmake@cmake.org/msg08837.html set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") - link_libraries(uuid pthread rt dl) + link_libraries(uuid pthread rt) + + if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") + add_definitions( + -D_LARGEFILE64_SOURCE=1 + -D_FILE_OFFSET_BITS=64 + ) + link_libraries(dl) + endif() elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") add_definitions( @@ -82,6 +81,22 @@ endif() +if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward -fpermissive") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}") +endif() + + +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + # In FreeBSD, the "/usr/local/" folder contains the ports and need to be imported + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") + SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -I/usr/local/include/jsoncpp") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib") +endif() + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") CHECK_INCLUDE_FILES(rpc.h HAVE_UUID_H) else() @@ -92,6 +107,7 @@ message(FATAL_ERROR "Please install the uuid-dev package") endif() + if (${STATIC_BUILD}) add_definitions(-DORTHANC_STATIC=1) else() diff -r a80e811ec619 -r afaa55d42ddd Resources/CMake/DcmtkConfiguration.cmake --- a/Resources/CMake/DcmtkConfiguration.cmake Mon Mar 30 16:18:46 2015 +0200 +++ b/Resources/CMake/DcmtkConfiguration.cmake Tue Mar 31 11:40:29 2015 +0200 @@ -93,6 +93,7 @@ AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/oflog/libsrc DCMTK_SOURCES) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") list(REMOVE_ITEM DCMTK_SOURCES ${DCMTK_SOURCES_DIR}/oflog/libsrc/windebap.cc @@ -163,7 +164,6 @@ list(APPEND DCMTK_LIBRARIES "${tmp}") include_directories(${DCMTK_INCLUDE_DIR}) - link_libraries(${DCMTK_LIBRARIES}) add_definitions( -DHAVE_CONFIG_H=1 diff -r a80e811ec619 -r afaa55d42ddd Resources/CMake/GoogleLogConfiguration.cmake --- a/Resources/CMake/GoogleLogConfiguration.cmake Mon Mar 30 16:18:46 2015 +0200 +++ b/Resources/CMake/GoogleLogConfiguration.cmake Tue Mar 31 11:40:29 2015 +0200 @@ -30,6 +30,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") set(ac_cv_have_unistd_h 1) set(ac_cv_have_stdint_h 1) @@ -96,6 +97,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") # Install the specific configuration for LSB SDK diff -r a80e811ec619 -r afaa55d42ddd Resources/CMake/LibCurlConfiguration.cmake --- a/Resources/CMake/LibCurlConfiguration.cmake Mon Mar 30 16:18:46 2015 +0200 +++ b/Resources/CMake/LibCurlConfiguration.cmake Tue Mar 31 11:40:29 2015 +0200 @@ -42,6 +42,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR + ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") SET(TMP_OS "x86_64") diff -r a80e811ec619 -r afaa55d42ddd Resources/CMake/MongooseConfiguration.cmake --- a/Resources/CMake/MongooseConfiguration.cmake Mon Mar 30 16:18:46 2015 +0200 +++ b/Resources/CMake/MongooseConfiguration.cmake Tue Mar 31 11:40:29 2015 +0200 @@ -24,7 +24,7 @@ # Patch mongoose execute_process( - COMMAND patch mongoose.c ${MONGOOSE_PATCH} + COMMAND patch -N mongoose.c ${MONGOOSE_PATCH} WORKING_DIRECTORY ${MONGOOSE_SOURCES_DIR} ) diff -r a80e811ec619 -r afaa55d42ddd THANKS --- a/THANKS Mon Mar 30 16:18:46 2015 +0200 +++ b/THANKS Tue Mar 31 11:40:29 2015 +0200 @@ -28,6 +28,7 @@ * Vincent Kersten , for DICOMDIR in the GUI. * Emsy Chan , for various contributions and sample DICOM files. +* Mikhail , for FreeBSD support. Thanks also to all the contributors active in our Google Group: diff -r a80e811ec619 -r afaa55d42ddd UnitTestsSources/PluginsTests.cpp --- a/UnitTestsSources/PluginsTests.cpp Mon Mar 30 16:18:46 2015 +0200 +++ b/UnitTestsSources/PluginsTests.cpp Tue Mar 31 11:40:29 2015 +0200 @@ -55,6 +55,16 @@ ASSERT_TRUE(l.HasFunction("dlclose")); ASSERT_FALSE(l.HasFunction("world")); +#elif defined(__FreeBSD__) + // dlopen() in FreeBSD is supplied by libc, libc.so is + // a ldscript, so we can't actually use it. Use thread + // library instead - if it works - dlopen() is good. + SharedLibrary l("libpthread.so"); + ASSERT_THROW(l.GetFunction("world"), OrthancException); + ASSERT_TRUE(l.GetFunction("pthread_create") != NULL); + ASSERT_TRUE(l.HasFunction("pthread_cancel")); + ASSERT_FALSE(l.HasFunction("world")); + #elif defined(__APPLE__) && defined(__MACH__) SharedLibrary l("libdl.dylib"); ASSERT_THROW(l.GetFunction("world"), OrthancException); diff -r a80e811ec619 -r afaa55d42ddd UnitTestsSources/UnitTestsMain.cpp --- a/UnitTestsSources/UnitTestsMain.cpp Mon Mar 30 16:18:46 2015 +0200 +++ b/UnitTestsSources/UnitTestsMain.cpp Tue Mar 31 11:40:29 2015 +0200 @@ -45,6 +45,7 @@ #include "../Core/Uuid.h" #include "../OrthancServer/OrthancInitialization.h" + using namespace Orthanc; @@ -668,19 +669,29 @@ #if defined(__linux) #include +#elif defined(__FreeBSD__) +#include #endif + TEST(Toolbox, Endianness) { // Parts of this test come from Adam Conrad // http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728822#5 -#if defined(_WIN32) + + /** + * Windows and OS X are assumed to always little-endian. + **/ + +#if defined(_WIN32) || defined(__APPLE__) ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); -#elif defined(__APPLE__) - ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); + /** + * Linux. + **/ + #elif defined(__linux) || defined(__FreeBSD_kernel__) #if !defined(__BYTE_ORDER) @@ -693,6 +704,18 @@ ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); # endif + + /** + * FreeBSD. + **/ + +#elif defined(__FreeBSD__) +# if _BYTE_ORDER == _BIG_ENDIAN + ASSERT_EQ(Endianness_Big, Toolbox::DetectEndianness()); +# else // _LITTLE_ENDIAN + ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); +# endif + #else #error Support your platform here #endif