From 2c8ee266371097e61dd93463fd42befb1d095b2b Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 2 Oct 2018 11:55:44 +1000
Subject: Fixes for Haiku


diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff6b5ae..544e8cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -139,9 +139,15 @@ if(WIN32)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mthreads")
 else(WIN32)
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
+if(NOT HAIKU)
+	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
+endif(HAIKU)
 endif(WIN32)
 
+#if(HAIKU)
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lnetwork")
+#endif(HAIKU)
+
 if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE "Debug")
 endif(NOT CMAKE_BUILD_TYPE)
diff --git a/engine/gupta/src/cecp/stdin_io.c b/engine/gupta/src/cecp/stdin_io.c
index bad7c08..d765264 100644
--- a/engine/gupta/src/cecp/stdin_io.c
+++ b/engine/gupta/src/cecp/stdin_io.c
@@ -50,6 +50,10 @@
 #include <stdio.h>
 #include <string.h>
 
+#ifdef __HAIKU__
+#include <sys/select.h>
+#endif
+
 #ifdef _WIN32
 static HANDLE hStdInput;
 static int is_pipe = 0;
diff --git a/src/Core/GambitApplication.cc b/src/Core/GambitApplication.cc
index 0784032..b36a64b 100644
--- a/src/Core/GambitApplication.cc
+++ b/src/Core/GambitApplication.cc
@@ -168,7 +168,11 @@ done:
 
     QString appDataPath;
 
+#ifdef __HAIKU__
+	const char *i = "/boot/home/config/settings";
+#else
     const char *i = getenv("XDG_CONFIG_HOME");
+#endif
     if (i)
         appDataPath = i;
     else
diff --git a/src/main.cc b/src/main.cc
index 2073992..f6f156f 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -102,6 +102,10 @@ int main(int argc, char **argv)
 
         GambitApplication app(argc, argv);
 
+#ifdef __HAIKU__
+		QDir::setCurrent(app.applicationDirPath());
+#endif
+
         if (!QDir().exists(app.configDirPath()))
         {
             if (!QDir().mkdir(app.configDirPath()))
diff --git a/src/sdk/procspawn/procspawn_unix.c b/src/sdk/procspawn/procspawn_unix.c
index f2cc811..2a6d2a0 100644
--- a/src/sdk/procspawn/procspawn_unix.c
+++ b/src/sdk/procspawn/procspawn_unix.c
@@ -432,7 +432,7 @@ static void child(int send_pid, pspwn_redir_t *parent_redir,
             goto send_status_code;
         }
     }
-
+#ifndef __HAIKU__
     if (priority != 0)
     {
         if (setpriority(PRIO_PROCESS, 0, priority) < 0)
@@ -442,7 +442,7 @@ static void child(int send_pid, pspwn_redir_t *parent_redir,
             goto send_status_code;
         }
     }
-
+#endif
     /* Send the PID of the 'init'-adopted child to the grandparent. */
     if (send_pid)
     {
-- 
2.19.0


From 7c16c8d3828ee676b6d7c8c2bc586a515163f84e Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 2 Oct 2018 13:08:00 +1000
Subject: Disable OpenGL


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 544e8cc..04f65be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -299,7 +299,7 @@ find_package(Qt5Widgets REQUIRED)
 find_package(Qt5Network REQUIRED)
 find_package(Qt5OpenGL) # OPTIONAL
 
-if(Qt5OpenGL_FOUND)
+if(Qt5OpenGL_FOUND AND NOT HAIKU)
     set(QT5_OPENGL_TARGET_LINK_LIBRARY "Qt5::OpenGL")
     add_definitions(-D CONFIG_QT_OPENGL)
 endif(Qt5OpenGL_FOUND)
-- 
2.19.0

