From 16ed2ece98e28f5af6c3be682061faec1102b794 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 13 Dec 2021 18:34:51 +1000
Subject: Fix build for Haiku


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3eb2717..fc8ad25 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,7 @@ For more information, please visit <http://www.openshot.org/>.
 
 ################ ADD CMAKE MODULES ##################
 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
+include(GNUInstallDirs)
 
 ################ PROJECT VERSION ####################
 set(PROJECT_VERSION_FULL "0.2.7")
diff --git a/src/AudioBufferSource.h b/src/AudioBufferSource.h
index a899d8d..225de2e 100644
--- a/src/AudioBufferSource.h
+++ b/src/AudioBufferSource.h
@@ -32,6 +32,7 @@
 #define OPENSHOT_AUDIOBUFFERSOURCE_H
 
 #include <iomanip>
+#include <string.h>
 #include <OpenShotAudio.h>
 
 /// This namespace is the default namespace for all code in the openshot library
diff --git a/src/CrashHandler.cpp b/src/CrashHandler.cpp
index 7b6c4e7..6acb8df 100644
--- a/src/CrashHandler.cpp
+++ b/src/CrashHandler.cpp
@@ -200,7 +200,7 @@ void CrashHandler::printStackTrace(FILE *out, unsigned int max_frames)
 	}
 	SymCleanup(process);
 
-#else
+#elif !defined(__HAIKU__)
     // Linux and Mac stack unwinding
 	// Storage array for stack trace address data
 	void* addrlist[max_frames+1];
@@ -320,4 +320,4 @@ void CrashHandler::printStackTrace(FILE *out, unsigned int max_frames)
 
 	fprintf(out, "---- End of Stack Trace ----\n");
 	ZmqLogger::Instance()->LogToFile("---- End of Stack Trace ----\n");
-}
\ No newline at end of file
+}
diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp
index c1eaa74..6d676ad 100644
--- a/src/FFmpegReader.cpp
+++ b/src/FFmpegReader.cpp
@@ -362,7 +362,7 @@ void FFmpegReader::Open() {
 					if( adapter_ptr != NULL && access( adapter_ptr, W_OK ) == 0 ) {
 #elif defined(_WIN32)
 					if( adapter_ptr != NULL ) {
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) || defined(__HAIKU__)
 					if( adapter_ptr != NULL ) {
 #endif
 						ZmqLogger::Instance()->AppendDebugMethod("Decode Device present using device");
diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp
index 8707756..6631950 100644
--- a/src/FFmpegWriter.cpp
+++ b/src/FFmpegWriter.cpp
@@ -1404,7 +1404,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) {
 				snprintf(adapter,sizeof(adapter),"/dev/dri/renderD%d", adapter_num+128);
 				// Maybe 127 is better because the first card would be 1?!
 				adapter_ptr = adapter;
-#elif defined(_WIN32) || defined(__APPLE__)
+#elif defined(_WIN32) || defined(__APPLE__) || defined(__HAIKU__)
 				adapter_ptr = NULL;
 #endif
 			}
@@ -1414,7 +1414,7 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) {
 // Check if it is there and writable
 #if defined(__linux__)
 		if( adapter_ptr != NULL && access( adapter_ptr, W_OK ) == 0 ) {
-#elif defined(_WIN32) || defined(__APPLE__)
+#elif defined(_WIN32) || defined(__APPLE__) || defined(__HAIKU__)
 		if( adapter_ptr != NULL ) {
 #endif
 				ZmqLogger::Instance()->AppendDebugMethod("Encode Device present using device", "adapter", adapter_num);
-- 
2.30.2

