From 3c20e5066491695786dafbc2cd13db116a07dccb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Fri, 8 Jan 2021 19:59:20 +0100
Subject: [PATCH] Haiku platform support, dynamic opencv support

---
 IPL/IPL.pro                                  | 14 +++++++++++---
 IPL/include/IPL_global.h                     |  2 +-
 IPL/include/processes/IPLLoadImageSequence.h |  2 +-
 ImagePlay/ImagePlay.pro                      | 16 +++++++++++++---
 4 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/IPL/IPL.pro b/IPL/IPL.pro
index e38c58b..8749d0a 100644
--- a/IPL/IPL.pro
+++ b/IPL/IPL.pro
@@ -26,7 +26,8 @@ else: DESTDIR  = ../ImagePlay/release
 #define platform variable for folder name
 win32 {contains(QMAKE_TARGET.arch, x86_64) {PLATFORM = x64} else {PLATFORM = Win32}}
 macx {PLATFORM = macx}
-unix:!macx:!android {PLATFORM = linux}
+unix:!macx:!android:!haiku {PLATFORM = linux}
+haiku {PLATFORM = haiku}
 
 #define configuration variable for folder name
 CONFIG(debug, debug|release) {CONFIGURATION = Debug} else {CONFIGURATION = Release}
@@ -117,7 +118,7 @@ macx {
 
 }
 
-linux {
+linux | haiku {
     CONFIG += staticlib
 
     LIBS += -lfreeimage
@@ -162,5 +163,12 @@ gcc:!clang {
 INCLUDEPATH += $$PWD/include/
 INCLUDEPATH += $$PWD/include/processes/
 
-# OpenCV
+# OpenCV
+!haiku {
 INCLUDEPATH += $$PWD/include/opencv/
+}
+haiku {
+    QT_CONFIG -= no-pkg-config
+    CONFIG += link_pkgconfig
+    PKGCONFIG += opencv4
+}
diff --git a/IPL/include/IPL_global.h b/IPL/include/IPL_global.h
index 3378527..b075472 100644
--- a/IPL/include/IPL_global.h
+++ b/IPL/include/IPL_global.h
@@ -34,7 +34,7 @@
 #include <algorithm>
 #include <math.h>
 
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
     #define EXTERNC         extern "C"
     #define IPLSHARED_EXPORT     __attribute__((visibility("default")))
     #define IPLSHARED_IMPORT     __attribute__((visibility("default")))
diff --git a/IPL/include/processes/IPLLoadImageSequence.h b/IPL/include/processes/IPLLoadImageSequence.h
index 41b1d55..5128994 100644
--- a/IPL/include/processes/IPLLoadImageSequence.h
+++ b/IPL/include/processes/IPLLoadImageSequence.h
@@ -26,7 +26,7 @@
 
 #include <string>
 #include <stdio.h>
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
     #include <sys/uio.h>
     #include <dirent.h>
 #else
diff --git a/ImagePlay/ImagePlay.pro b/ImagePlay/ImagePlay.pro
index 944b9ea..ca38b27 100644
--- a/ImagePlay/ImagePlay.pro
+++ b/ImagePlay/ImagePlay.pro
@@ -62,7 +62,8 @@ DEFINES += IMAGEPLAY_APPCAST_URL=\\\"http://cpvrlab.github.io/ImagePlay/Appcast.
 #define platform variable for folder name
 win32 {contains(QMAKE_TARGET.arch, x86_64) {PLATFORM = x64} else {PLATFORM = Win32}}
 macx {PLATFORM = macx}
-unix:!macx:!android {PLATFORM = linux}
+unix:!macx:!android:!haiku {PLATFORM = linux}
+haiku {PLATFORM = haiku}
 
 #define configuration variable for folder name
 CONFIG(debug, debug|release) {CONFIGURATION = Debug} else {CONFIGURATION = Release}
@@ -160,7 +161,7 @@ macx: {
     USE_FERVOR_UPDATER = true
 }
 
-linux: {
+linux | haiku: {
     LIBS += -L../_bin/$$CONFIGURATION/$$PLATFORM/ -lIPL
 
     LIBS += -lfreeimage
@@ -174,7 +175,9 @@ linux: {
     LIBS += -lopencv_xfeatures2d
     LIBS += -lopencv_photo
     LIBS += -lopencv_xphoto
+	!haiku{
     LIBS += -ldl
+	}
 
     QMAKE_POST_LINK +=  $${QMAKE_COPY_DIR} media/process_icons/ ../_bin/$$CONFIGURATION/$$PLATFORM/ && \
                         $${QMAKE_COPY_DIR} media/examples/ ../_bin/$$CONFIGURATION/$$PLATFORM/ &&\
@@ -232,7 +235,14 @@ gcc:!clang {
 INCLUDEPATH += $$PWD/include/
 INCLUDEPATH += $$PWD/../IPL/include/
 INCLUDEPATH += $$PWD/../IPL/include/processes/
-INCLUDEPATH += $$PWD/../IPL/include/opencv/
+!haiku {
+	INCLUDEPATH += $$PWD/../IPL/include/opencv/
+}
+haiku {
+    QT_CONFIG -= no-pkg-config
+    CONFIG += link_pkgconfig
+    PKGCONFIG += opencv4
+}
 DEPENDPATH += $$PWD/../IPL/include/
 
 # Fervor autoupdater
-- 
2.30.0

