From c66d4ac662840af459b64a77aaa998867d1cf5c7 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 30 Oct 2019 21:24:04 +1000
Subject: Haiku fixes


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 092dcb5..fff3c08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -281,6 +281,13 @@ else()
 	endif( APPLE )
 endif()
 
+
+	if(HAIKU)
+		# Haiku networking resides in libnetwork
+		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lnetwork")
+		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lnetwork")
+	endif(HAIKU)
+
 set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${REL_LINKER_FLAGS}" )
 set( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} ${REL_LINKER_FLAGS}" )
 set( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} ${REL_LINKER_FLAGS}" )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 21bf74b..b784624 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -405,7 +405,7 @@ endif()
 CHECK_CXX_SOURCE_COMPILES("thread_local int i; int main() { i = 0; }"
 	HAVE_THREAD_LOCAL)
 
-if( NOT HAVE_THREAD_LOCAL )
+if( NOT HAVE_THREAD_LOCAL AND NOT HAIKU)
 	message( SEND_ERROR "C++ compiler doesn't support thread_local storage duration specifier" )
 endif()
 
diff --git a/src/gl_load/gl_load.c b/src/gl_load/gl_load.c
index 4bfbb78..405444e 100644
--- a/src/gl_load/gl_load.c
+++ b/src/gl_load/gl_load.c
@@ -84,7 +84,7 @@ static PROC WinGetProcAddress(const char *name)
 	#if defined(__APPLE__)
 		#define IntGetProcAddress(name) AppleGLGetProcAddress(name)
 	#else
-		#if defined(__sgi) || defined(__sun) || defined(__unix__)
+		#if defined(__sgi) || defined(__sun) || defined(__unix__) || defined(__HAIKU__)
 			void* SDL_GL_GetProcAddress(const char* proc);
 			#define IntGetProcAddress(name) SDL_GL_GetProcAddress((const char*)name)
 			//#define IntGetProcAddress(name) PosixGetProcAddress((const GLubyte*)name)
diff --git a/src/posix/i_system.h b/src/posix/i_system.h
index 1fc528e..6baae1b 100644
--- a/src/posix/i_system.h
+++ b/src/posix/i_system.h
@@ -147,6 +147,7 @@ inline const char *I_FindName(findstate_t *fileinfo)
 #define FA_DIREC	8
 #define FA_ARCH		16
 
+#ifndef __HAIKU__
 static inline char *strlwr(char *str)
 {
 	char *ptr = str;
@@ -157,6 +158,7 @@ static inline char *strlwr(char *str)
 	}
 	return str;
 }
+#endif
 
 inline int I_GetNumaNodeCount() { return 1; }
 inline int I_GetNumaNodeThreadCount(int numaNode) { return std::max<int>(std::thread::hardware_concurrency(), 1); }
diff --git a/tools/re2c/src/util/c99_stdint.h b/tools/re2c/src/util/c99_stdint.h
index 5718604..e2c76df 100644
--- a/tools/re2c/src/util/c99_stdint.h
+++ b/tools/re2c/src/util/c99_stdint.h
@@ -7,6 +7,10 @@
 #include "config.h"
 #endif
 
+#ifdef __HAIKU__
+#define HAVE_STDINT_H 1
+#endif
+
 #if HAVE_STDINT_H
 #    include <stdint.h>
 #else // HAVE_STDINT_H
-- 
2.23.0


From 962e2c5f581da68cacd0d588ae7bcd2c7f17d12c Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 31 Oct 2019 21:22:03 +1000
Subject: Fix GAME_DIR for Haiku


diff --git a/src/version.h b/src/version.h
index 63f3500..64339a3 100644
--- a/src/version.h
+++ b/src/version.h
@@ -99,6 +99,8 @@ const char *GetVersionString();
 
 #if defined(__APPLE__) || defined(_WIN32)
 #define GAME_DIR GAMENAME
+#elif defined(__HAIKU__)
+#define GAME_DIR "config/settings/" GAMENAME
 #else
 #define GAME_DIR ".config/" GAMENAMELOWERCASE
 #endif
-- 
2.23.0

