From 7a0d7728d2385d9a676049fa50b491275149c293 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 | 2 +- exec/cnex/CMakeLists.txt | 2 +- external/libbid.cmake | 18 +++++++++++++++++- external/minizip.cmake | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf312ce91..339bad5bb 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 diff --git a/exec/cnex/CMakeLists.txt b/exec/cnex/CMakeLists.txt index ad25beec0..238f1942b 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) 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