diff --git a/CMakeLists.txt b/CMakeLists.txt index 419677c0a..244bbc4fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,7 @@ if(CMAKE_GENERATOR STREQUAL "Ninja") add_c_compiler_flag_if_supported(OUR_FLAGS -fcolor-diagnostics) endif() -if(NOT MSVC) +if(NOT MSVC AND NOT HAIKU) if(CMAKE_VERSION VERSION_LESS 3.1 OR TARGET_OS STREQUAL "mac") check_cxx_compiler_flag(-std=gnu++11 FLAG_SUPPORTED_std_gnu__11) if(FLAG_SUPPORTED_std_gnu__11) @@ -210,9 +210,15 @@ if(NOT MSVC) add_c_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety) # TODO: Enable for C++ code except gtest #add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN "-Wuseless-cast") +else() + if(TARGET_OS STREQUAL "haiku") + set(PLATFORM_CLIENT) + find_package(OpenGL) + set(PLATFORM_LIBS GL network) + endif() endif() -if(NOT MSVC) +if(NOT MSVC AND NOT HAIKU) check_c_compiler_flag("-O2;-Wp,-Werror;-D_FORTIFY_SOURCE=2" DEFINE_FORTIFY_SOURCE) # Some distributions define _FORTIFY_SOURCE by themselves. endif() diff --git a/src/base/detect.h b/src/base/detect.h index 914c4760b..19a2386d4 100644 --- a/src/base/detect.h +++ b/src/base/detect.h @@ -82,6 +82,13 @@ #define PLATFORM_STRING "beos" #endif +#if defined(__HAIKU__) +#define CONF_FAMILY_UNIX 1 +#define CONF_FAMILY_STRING "unix" +#define CONF_PLATFORM_HAIKU 1 +#define CONF_PLATFORM_STRING "haiku" +#endif + /* use gcc endianness definitions when available */ #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun) #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) diff --git a/src/base/system.c b/src/base/system.c index 1497c6446..6794f1810 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -2078,6 +2078,11 @@ int fs_storage_path(const char *appname, char *path, int max) if(!home) return -1; +#if defined(CONF_PLATFORM_HAIKU) + str_format(path, max, "%s/config/settings/%s", home, appname); + return 0; +#endif + #if defined(CONF_PLATFORM_MACOS) snprintf(path, max, "%s/Library/Application Support/%s", home, appname); #else @@ -2117,6 +2122,11 @@ int fs_makedir(const char *path) return 0; return -1; #else +#ifdef CONF_PLATFORM_HAIKU + struct stat st; + if(stat(path, &st) == 0) + return 0; +#endif if(mkdir(path, 0755) == 0) return 0; if(errno == EEXIST) diff --git a/src/base/system.h b/src/base/system.h index 6b1363832..dd354e181 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -631,7 +631,11 @@ void sphore_destroy(SEMAPHORE *sem); /* if compiled with -pedantic-errors it will complain about long not being a C90 thing. */ +#ifdef CONF_PLATFORM_HAIKU +#include +#else __extension__ typedef long long int64; +#endif __extension__ typedef unsigned long long uint64; #else typedef long long int64; diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 0042bd0cb..0e33d2a87 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -4777,7 +4777,7 @@ void CGraphicsBackend_SDL_OpenGL::SetWindowParams(int FullscreenMode, bool IsBor { if(FullscreenMode == 1) { -#if defined(CONF_PLATFORM_MACOS) // Todo SDL: remove this when fixed (game freezes when losing focus in fullscreen) +#if defined(CONF_PLATFORM_MACOS) || defined(CONF_PLATFORM_HAIKU) // Todo SDL: remove this when fixed (game freezes when losing focus in fullscreen) SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP); #else SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN); diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index 332a8d643..9b6f9a292 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef CONF_PLATFORM_HAIKU +#include +#endif + class CStorage : public IStorage { public: @@ -193,6 +197,9 @@ public: // 3) check for usable path in argv[0] { +#ifdef CONF_PLATFORM_HAIKU + pArgv0 = realpath(pArgv0, NULL); +#endif unsigned int Pos = ~0U; for(unsigned i = 0; pArgv0[i]; i++) if(pArgv0[i] == '/' || pArgv0[i] == '\\') @@ -211,6 +218,9 @@ public: } } } +#ifdef CONF_PLATFORM_HAIKU + free((void *)pArgv0); +#endif #if defined(CONF_FAMILY_UNIX) // 4) check for all default locations