From 838ef11dbc70e82650549a8ab19f1c96b8573177 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sat, 3 Mar 2018 19:51:08 +0100
Subject: Basic Haiku support


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 092fd2f..d9ccb93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -472,9 +472,9 @@ if(OCE_VISUALISATION)
 		endif(WIN32)
 	endif(OCE_WITH_FREEIMAGE)
 
-	if (NOT WIN32 AND NOT OCE_OSX_USE_COCOA)
+	if (NOT WIN32 AND NOT OCE_OSX_USE_COCOA AND NOT HAIKU)
 		find_package(X11 REQUIRED)
-	endif(NOT WIN32 AND NOT OCE_OSX_USE_COCOA)
+	endif(NOT WIN32 AND NOT OCE_OSX_USE_COCOA AND NOT HAIKU)
 
 	if (NOT APPLE OR OCE_OSX_USE_COCOA)
 		find_package(OpenGL REQUIRED)
@@ -716,6 +716,11 @@ if(UNIX)
 			# remark #981 "operands are evaluated in unspecified order", e.g. a = b() + c()
 			add_definitions("-diag-disable 383,522,858,981")
 		endif(INTEL)
+		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)
 	endif(APPLE)
 	add_definitions(-DHAVE_CONFIG_H -DCSFDB -DOCC_CONVERT_SIGNALS)
 else(UNIX)
diff --git a/src/Aspect/Aspect_DisplayConnection.cxx b/src/Aspect/Aspect_DisplayConnection.cxx
index 72109bf..5eac74a 100644
--- a/src/Aspect/Aspect_DisplayConnection.cxx
+++ b/src/Aspect/Aspect_DisplayConnection.cxx
@@ -25,7 +25,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Aspect_DisplayConnection, Standard_Transient)
 // =======================================================================
 Aspect_DisplayConnection::Aspect_DisplayConnection()
 {
-#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
+#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__HAIKU__)
   OSD_Environment anEnv ("DISPLAY");
   myDisplayName = anEnv.Value();
   Init();
@@ -38,7 +38,7 @@ Aspect_DisplayConnection::Aspect_DisplayConnection()
 // =======================================================================
 Aspect_DisplayConnection::~Aspect_DisplayConnection()
 {
-#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
+#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__HAIKU__)
   if (myDisplay != NULL)
   {
     XCloseDisplay (myDisplay);
@@ -46,7 +46,7 @@ Aspect_DisplayConnection::~Aspect_DisplayConnection()
 #endif
 }
 
-#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
+#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__HAIKU__)
 // =======================================================================
 // function : Aspect_DisplayConnection
 // purpose  :
diff --git a/src/Aspect/Aspect_DisplayConnection.hxx b/src/Aspect/Aspect_DisplayConnection.hxx
index 624cbaf..16d9f28 100644
--- a/src/Aspect/Aspect_DisplayConnection.hxx
+++ b/src/Aspect/Aspect_DisplayConnection.hxx
@@ -20,7 +20,7 @@
 #include <TCollection_AsciiString.hxx>
 #include <NCollection_DataMap.hxx>
 
-#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
+#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__HAIKU__)
   #include <InterfaceGraphic.hxx>
 #endif
 
@@ -39,7 +39,7 @@ public:
   //! Destructor. Close opened connection.
   Standard_EXPORT ~Aspect_DisplayConnection();
 
-#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__HAIKU__)
   //! Constructor. Creates connection with display specified in theDisplayName.
   //! Display name should be in format "hostname:number" or "hostname:number.screen_number", where:
   //! hostname      - Specifies the name of the host machine on which the display is physically attached.
diff --git a/src/InterfaceGraphic/InterfaceGraphic.hxx b/src/InterfaceGraphic/InterfaceGraphic.hxx
index 80ac333..8539a2c 100644
--- a/src/InterfaceGraphic/InterfaceGraphic.hxx
+++ b/src/InterfaceGraphic/InterfaceGraphic.hxx
@@ -23,7 +23,7 @@
   #undef DrawText
 #endif
 
-#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__HAIKU__)
 
 #include <stdio.h>
 
diff --git a/src/OSD/OSD_signal.cxx b/src/OSD/OSD_signal.cxx
index e9a80d6..4e61ac3 100644
--- a/src/OSD/OSD_signal.cxx
+++ b/src/OSD/OSD_signal.cxx
@@ -69,7 +69,7 @@ typedef void (* SIG_PFV) (int);
 
 #include <signal.h>
 
-#if !defined(__ANDROID__)
+#if !defined(__ANDROID__) && !defined(__HAIKU__)
   #include <sys/signal.h>
 #endif
 
diff --git a/src/Standard/Standard_MMgrOpt.cxx b/src/Standard/Standard_MMgrOpt.cxx
index 51464ad..3ed0fa1 100644
--- a/src/Standard/Standard_MMgrOpt.cxx
+++ b/src/Standard/Standard_MMgrOpt.cxx
@@ -25,6 +25,10 @@
 # include <sys/mman.h>    /* mmap() */
 #endif
 
+#ifdef __HAIKU__
+# include <errno.h>
+#endif
+
 #include <fcntl.h>
 //
 #if defined (__sun) || defined(SOLARIS)
diff --git a/src/Standard/Standard_Mutex.cxx b/src/Standard/Standard_Mutex.cxx
index cdf6498..9fd1182 100644
--- a/src/Standard/Standard_Mutex.cxx
+++ b/src/Standard/Standard_Mutex.cxx
@@ -24,6 +24,10 @@
 #include <Standard_Mutex.hxx>
 #include <Standard_OStream.hxx>
 
+#ifdef __HAIKU__
+#include <Errors.h>
+#endif
+
 //=============================================
 // Standard_Mutex::Standard_Mutex
 //=============================================
diff --git a/src/Standard/Standard_Mutex.hxx b/src/Standard/Standard_Mutex.hxx
index 22b8a03..5e81912 100644
--- a/src/Standard/Standard_Mutex.hxx
+++ b/src/Standard/Standard_Mutex.hxx
@@ -24,7 +24,9 @@
   #include <windows.h>
 #else
   #include <pthread.h>
-  #include <sys/errno.h>
+  #ifndef __HAIKU__
+    #include <sys/errno.h>
+  #endif
   #include <unistd.h>
   #include <time.h>
 #endif
diff --git a/src/Xw/Xw_Window.cxx b/src/Xw/Xw_Window.cxx
index a24a3a0..10694c3 100644
--- a/src/Xw/Xw_Window.cxx
+++ b/src/Xw/Xw_Window.cxx
@@ -15,7 +15,7 @@
 
 #include <Xw_Window.hxx>
 
-#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
+#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)  && !defined(__HAIKU__)
 
 #include <Aspect_Convert.hxx>
 #include <Aspect_WindowDefinitionError.hxx>
diff --git a/src/Xw/Xw_Window.hxx b/src/Xw/Xw_Window.hxx
index 53f0c14..da04952 100644
--- a/src/Xw/Xw_Window.hxx
+++ b/src/Xw/Xw_Window.hxx
@@ -16,7 +16,7 @@
 #ifndef _Xw_Window_H__
 #define _Xw_Window_H__
 
-#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
+#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__HAIKU__)
 
 #include <Aspect_Window.hxx>
 
-- 
2.16.2


From 03827b0b856173e015a3eb4c60c729f7ce3a6253 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sun, 4 Mar 2018 08:22:15 +0100
Subject: Data install path fix


diff --git a/CMakeLists.txt b/CMakeLists.txt
index d9ccb93..6ff39cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -903,7 +903,11 @@ endif(NOT DEFINED OCE_INSTALL_SCRIPT_DIR)
 # Data
 if(NOT DEFINED OCE_INSTALL_DATA_DIR)
 	if(NOT MSVC)
-		set(OCE_INSTALL_DATA_DIR share/oce-${OCE_VERSION})
+		if(NOT HAIKU)
+			set(OCE_INSTALL_DATA_DIR share/oce-${OCE_VERSION})
+		else ()
+			set(OCE_INSTALL_DATA_DIR data/oce-${OCE_VERSION})
+		endif(NOT HAIKU)
 	else ()
 		set(OCE_INSTALL_DATA_DIR "share/oce")
 	endif(NOT MSVC)
-- 
2.16.2


From 98c143fbef94320aa5c68dd0340e3660edd5c7ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sun, 4 Mar 2018 08:59:37 +0100
Subject: Adjust .cmake install paths


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6ff39cb..6f7f871 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -931,8 +931,13 @@ if(NOT DEFINED OCE_INSTALL_CMAKE_DATA_DIR)
 			set(OCE_INSTALL_CMAKE_DATA_DIR
 				OCE.framework/Versions/${OCE_VERSION}/Resources)
 		else(APPLE)
-			set(OCE_INSTALL_CMAKE_DATA_DIR
-				lib${LIB_SUFFIX}/oce-${OCE_VERSION})
+			if(NOT HAIKU)
+				set(OCE_INSTALL_CMAKE_DATA_DIR
+					lib${LIB_SUFFIX}/oce-${OCE_VERSION})
+			else(NOT HAIKU)
+				set(OCE_INSTALL_CMAKE_DATA_DIR
+					lib${LIB_SUFFIX}/cmake)
+			endif(NOT HAIKU)
 		endif(APPLE)
 	endif(WIN32)
 endif(NOT DEFINED OCE_INSTALL_CMAKE_DATA_DIR)
-- 
2.16.2

