From 7944134c505c44e0e638fed89ff55a036161d235 Mon Sep 17 00:00:00 2001
From: Sergei Reznikov <diver@gelios.net>
Date: Sun, 31 Oct 2021 13:15:08 +0300
Subject: Fix build on Haiku


diff --git a/CMakeLists.txt b/CMakeLists.txt
index 84bc7db..d7fd65c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -151,7 +151,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kio5\")
 ki18n_install(po)
 
 if (KF5DocTools_FOUND)
-    kdoctools_install(po)
+    #kdoctool_install(po)
 endif()
 
 if (KF5DocTools_FOUND)
diff --git a/autotests/jobtest.cpp b/autotests/jobtest.cpp
index f567f3d..7a0f6ae 100644
--- a/autotests/jobtest.cpp
+++ b/autotests/jobtest.cpp
@@ -1847,7 +1847,7 @@ void JobTest::statTimeResolution()
 
     QFile dest_file(filePath);
     QVERIFY(dest_file.open(QIODevice::ReadOnly));
-#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_HAIKU)
     // with nano secs precision
     struct timespec ut[2];
     ut[0].tv_sec = early70sTime;
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index b88f5d4..1fabc11 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -1,3 +1,3 @@
-add_subdirectory(kcookiejar5)
-add_subdirectory(kioslave5)
-add_subdirectory(kcontrol5)
+#add_subdirectory(kcookiejar5)
+#add_subdirectory(kioslave5)
+#add_subdirectory(kcontrol5)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 7e43842..062a6b8 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -233,6 +233,10 @@ if (TARGET KF5::AuthCore)
   target_link_libraries(KF5KIOCore PRIVATE KF5::AuthCore)   #SlaveBase uses KAuth::Action
 endif()
 
+if (HAIKU)
+  target_link_libraries(KF5KIOCore PRIVATE network)
+endif ()
+
 if(ACL_FOUND)
   target_link_libraries(KF5KIOCore PRIVATE ${ACL_LIBS})
 endif()
diff --git a/src/ioslaves/file/CMakeLists.txt b/src/ioslaves/file/CMakeLists.txt
index fec216a..56def3b 100644
--- a/src/ioslaves/file/CMakeLists.txt
+++ b/src/ioslaves/file/CMakeLists.txt
@@ -34,6 +34,10 @@ if(UNIX)
   target_link_libraries(kio_file Qt5::Network KF5::AuthCore)
 endif()
 
+if (HAIKU)
+  target_link_libraries(kio_file gnu network)
+endif ()
+
 if(ACL_FOUND)
    target_link_libraries(kio_file ${ACL_LIBS})
 endif()
diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp
index fe00c11..9162199 100644
--- a/src/ioslaves/file/file_unix.cpp
+++ b/src/ioslaves/file/file_unix.cpp
@@ -59,6 +59,11 @@
 #include <sys/extattr.h>
 #endif
 
+#ifdef __HAIKU__
+#undef HAVE_DIRENT_D_TYPE
+#undef HAVE_SYS_XATTR_H
+#endif
+
 using namespace KIO;
 
 /* 512 kB */
@@ -950,7 +955,7 @@ void FileProtocol::copy(const QUrl &srcUrl, const QUrl &destUrl, int _mode, JobF
 
     // copy access and modification time
     if (!wasKilled()) {
-#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
+#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_HAIKU)
         // with nano secs precision
         struct timespec ut[2];
         ut[0] = buff_src.st_atim;
diff --git a/src/ioslaves/file/kauth/CMakeLists.txt b/src/ioslaves/file/kauth/CMakeLists.txt
index 8b77a28..344c168 100644
--- a/src/ioslaves/file/kauth/CMakeLists.txt
+++ b/src/ioslaves/file/kauth/CMakeLists.txt
@@ -1,6 +1,10 @@
 add_executable(file_helper filehelper.cpp fdsender.cpp)
 target_link_libraries(file_helper Qt5::Network KF5::AuthCore KF5::I18n KF5::KIOCore)
 
+if (HAIKU)
+	target_link_libraries(file_helper network)
+endif ()
+
 #install(TARGETS file_helper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
 #kauth_install_helper_files(file_helper org.kde.kio.file root)
 #kauth_install_actions(org.kde.kio.file file.actions)
diff --git a/src/kpac/CMakeLists.txt b/src/kpac/CMakeLists.txt
index 505d339..79f48ce 100644
--- a/src/kpac/CMakeLists.txt
+++ b/src/kpac/CMakeLists.txt
@@ -51,6 +51,9 @@ if (Qt5Qml_FOUND)
     if (HAVE_RESOLV_LIBRARY)
       target_link_libraries(kded_proxyscout resolv)
     endif ()
+    if (HAIKU)
+      target_link_libraries(kded_proxyscout network)
+    endif ()
 endif()
 
 set_package_properties(Qt5Qml PROPERTIES DESCRIPTION "QtQml, one of the Qt5 modules"
@@ -76,6 +79,10 @@ if (HAVE_SOCKET_LIBRARY)
   target_link_libraries(kpac_dhcp_helper socket)
 endif ()
 
+if (HAIKU)
+  target_link_libraries(kpac_dhcp_helper network)
+endif ()
+
 install(TARGETS kpac_dhcp_helper DESTINATION ${KDE_INSTALL_LIBEXECDIR_KF5} )
 
 ########### install files ###############
diff --git a/src/widgets/previewjob.cpp b/src/widgets/previewjob.cpp
index 400e14b..ee8f6bb 100644
--- a/src/widgets/previewjob.cpp
+++ b/src/widgets/previewjob.cpp
@@ -11,7 +11,7 @@
 #include "previewjob.h"
 #include "kio_widgets_debug.h"
 
-#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_HAIKU)
 #define WITH_SHM 1
 #else
 #define WITH_SHM 0
-- 
2.30.2

