build: haiku os support #36639

Initial support for compiling on haiku os. Some deps can be pulled from
haiku repos, some need to be compiled with nvim's dep build system:

    cmake -DUSE_BUNDLED_LIBUV=OFF -DUSE_BUNDLED_UNIBILIUM=OFF -DUSE_BUNDLED_LUAJIT=OFF -B .deps ./cmake.deps
    make -C .deps

(cherry picked from commit 10c11c4644)
This commit is contained in:
User0
2025-11-23 18:45:00 +01:00
committed by github-actions[bot]
parent 9978b1b29e
commit d0ed06dcea
3 changed files with 15 additions and 5 deletions

View File

@@ -91,7 +91,7 @@ int main(void)
}
" HAVE_BITSCANFORWARD64)
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR CMAKE_SYSTEM_NAME STREQUAL "Haiku")
check_c_source_compiles("
#include <termios.h>
int

View File

@@ -93,7 +93,7 @@ if(NOT MSVC)
endif()
# -fstack-protector breaks Mingw-w64 builds
if(NOT MINGW)
if(NOT MINGW AND NOT CMAKE_SYSTEM_NAME STREQUAL "Haiku")
check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG_FLAG)
if(HAS_FSTACK_PROTECTOR_STRONG_FLAG)
target_compile_options(main_lib INTERFACE -fstack-protector-strong)
@@ -145,7 +145,10 @@ endif()
# Platform specific options
if(UNIX)
target_link_libraries(main_lib INTERFACE m)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
if (CMAKE_SYSTEM_NAME STREQUAL "Haiku")
target_link_libraries(main_lib INTERFACE bsd)
target_link_libraries(nvim_bin PRIVATE -lnetwork)
elseif (NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
target_link_libraries(main_lib INTERFACE util)
endif()
endif()

View File

@@ -46,12 +46,17 @@
# include "os/pty_proc_unix.c.generated.h"
#endif
#if defined(__sun) && !defined(HAVE_FORKPTY)
#if !defined(HAVE_FORKPTY) && !defined(__APPLE__)
// this header defines STR, just as nvim.h, but it is defined as ('S'<<8),
// to avoid #undef STR, #undef STR, #define STR ('S'<<8) just delay the
// inclusion of the header even though it gets include out of order.
# include <sys/stropts.h>
# if !defined(__HAIKU__)
# include <sys/stropts.h>
# else
# define I_PUSH 0 // XXX: find the actual value
# endif
static int openpty(int *amaster, int *aslave, char *name, struct termios *termp,
struct winsize *winp)
@@ -343,9 +348,11 @@ static void init_termios(struct termios *termios) FUNC_ATTR_NONNULL_ALL
termios->c_cc[VSTART] = 0x1f & 'Q';
termios->c_cc[VSTOP] = 0x1f & 'S';
termios->c_cc[VSUSP] = 0x1f & 'Z';
#if !defined(__HAIKU__)
termios->c_cc[VREPRINT] = 0x1f & 'R';
termios->c_cc[VWERASE] = 0x1f & 'W';
termios->c_cc[VLNEXT] = 0x1f & 'V';
#endif
termios->c_cc[VMIN] = 1;
termios->c_cc[VTIME] = 0;
}