From 4906eec24a186f2441aaa5e6865659ae0b61be1a Mon Sep 17 00:00:00 2001 From: Greg Hewgill Date: Thu, 22 Feb 2024 20:10:34 +1300 Subject: [PATCH] Add some support for NetBSD --- CMakeLists.txt | 4 ++-- exec/cnex/CMakeLists.txt | 5 ++++- external/libbid.cmake | 18 +++++++++++++++++- external/minizip.cmake | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf312ce91..1202f2d0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -387,7 +387,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") lib/time_posix.cpp lib/time_darwin.cpp ) -elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD") set(platform_executor src/rtl_posix.cpp lib/file_posix.cpp @@ -488,7 +488,7 @@ endif (WIN32) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") target_link_libraries(executor dl) endif () -if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD") target_link_libraries(executor pthread) endif () diff --git a/exec/cnex/CMakeLists.txt b/exec/cnex/CMakeLists.txt index ad25beec0..81651847c 100644 --- a/exec/cnex/CMakeLists.txt +++ b/exec/cnex/CMakeLists.txt @@ -21,7 +21,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") lib/random_posix.c lib/runtime_posix.c ) -elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD") # Not all flavors of Linx will have the function clock_gettime(), and some have it in a different include. # See exec/cnex/lib/time_linux.c for more information. include(CheckSymbolExists) @@ -155,4 +155,7 @@ else (WIN32) target_link_libraries(test_string_support m) target_link_libraries(test_number_to_string_c m) target_link_libraries(test_path_support m) + if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD") + target_link_libraries(executor pthread) + endif () endif (WIN32) diff --git a/external/libbid.cmake b/external/libbid.cmake index 183fd9372..abbb75244 100644 --- a/external/libbid.cmake +++ b/external/libbid.cmake @@ -13,7 +13,23 @@ if (NOT EXISTS external/IntelRDFPMathLib20U2) RESULT_VARIABLE retcode ) if (NOT "${retcode}" STREQUAL "0") - message(FATAL_ERROR "Fatal error extracting archive") + message(FATAL_ERROR "Fatal error patching file") + endif () + endif () + if (${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD") + execute_process( + COMMAND perl -p -i -e "s/unsigned short int fexcept_t/unsigned int fexcept_t/" external/IntelRDFPMathLib20U2/LIBRARY/src/bid_functions.h + RESULT_VARIABLE retcode + ) + if (NOT "${retcode}" STREQUAL "0") + message(FATAL_ERROR "Fatal error patching file") + endif () + execute_process( + COMMAND sh -c "(echo '#include ' && cat external/IntelRDFPMathLib20U2/LIBRARY/float128/dpml_exception.h) >external/IntelRDFPMathLib20U2/LIBRARY/float128/dpml_exception.h.new && mv external/IntelRDFPMathLib20U2/LIBRARY/float128/dpml_exception.h.new external/IntelRDFPMathLib20U2/LIBRARY/float128/dpml_exception.h" + RESULT_VARIABLE retcode + ) + if (NOT "${retcode}" STREQUAL "0") + message(FATAL_ERROR "Fatal error patching file") endif () endif () endif () diff --git a/external/minizip.cmake b/external/minizip.cmake index ee4f588b5..487eb5224 100644 --- a/external/minizip.cmake +++ b/external/minizip.cmake @@ -19,7 +19,7 @@ add_library(minizip minizip11/zip.c ${minizip_platform} ) -if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") +if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD") set_source_files_properties(minizip11/ioapi.c PROPERTIES COMPILE_DEFINITIONS "fopen64=fopen;fseeko64=fseeko;ftello64=ftello") endif () target_include_directories(minizip