From e7bb07853e20ffe3812320cb7fadfee6e42dd080 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 24 Mar 2018 14:19:43 +0100
Subject: Fix search path for Lua headers.


diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake
index 283a3eb..8fd73f2 100644
--- a/Modules/FindLua51.cmake
+++ b/Modules/FindLua51.cmake
@@ -38,7 +38,7 @@ locations other than lua/
 find_path(LUA_INCLUDE_DIR lua.h
   HINTS
     ENV LUA_DIR
-  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include
+  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include lua5.1
   PATHS
   ~/Library/Frameworks
   /Library/Frameworks
-- 
2.30.2


From ee23112124febc01d50f44803aebc00d12b4b3a2 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 7 Sep 2019 17:29:56 +0200
Subject: links against libnetwork


diff --git a/bootstrap b/bootstrap
index a487375..b733b42 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1705,6 +1705,9 @@ else
       uv_c_flags="${uv_c_flags} -D_XOPEN_SOURCE=700"
       libs="${libs} -lsocket"
       ;;
+    *Haiku*)
+      libs="${libs} -lnetwork"
+      ;;
   esac
 fi
 if test "x${bootstrap_system_libuv}" = "x"; then
-- 
2.30.2


From 1969848606683b6613871f57034147349e47bff6 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 7 Sep 2019 23:46:47 +0200
Subject: bootstrap uses cmlibuv


diff --git a/Utilities/cmlibuv/src/unix/core.c b/Utilities/cmlibuv/src/unix/core.c
index 4245e02..e634c70 100644
--- a/Utilities/cmlibuv/src/unix/core.c
+++ b/Utilities/cmlibuv/src/unix/core.c
@@ -1426,7 +1426,9 @@ int uv_os_getpriority(uv_pid_t pid, int* priority) {
     return UV_EINVAL;
 
   errno = 0;
+#ifndef __HAIKU__
   r = getpriority(PRIO_PROCESS, (int) pid);
+#endif
 
   if (r == -1 && errno != 0)
     return UV__ERR(errno);
@@ -1440,8 +1442,10 @@ int uv_os_setpriority(uv_pid_t pid, int priority) {
   if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW)
     return UV_EINVAL;
 
+#ifndef __HAIKU__
   if (setpriority(PRIO_PROCESS, (int) pid, priority) != 0)
     return UV__ERR(errno);
+#endif
 
   return 0;
 }
-- 
2.30.2


From 77ddef9f2837d244fafa9049e4624fdab023f3ce Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 21 Sep 2019 15:30:44 +0200
Subject: also detect secondary arch with clang.


diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake
index b8e3ba6..08b11a4 100644
--- a/Modules/Platform/Haiku.cmake
+++ b/Modules/Platform/Haiku.cmake
@@ -38,6 +38,10 @@ execute_process(
 
 string(REGEX MATCH "libraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/?(:?\n+)" _dummy "${_HAIKU_SEARCH_DIRS}\n")
 set(CMAKE_HAIKU_SECONDARY_ARCH "${CMAKE_MATCH_2}")
+if(NOT CMAKE_HAIKU_SECONDARY_ARCH)
+  string(REGEX MATCH "libraries: =?([^\n]*:)?/system/lib/([^/]*)/?(:?\n+)" _dummy "${_HAIKU_SEARCH_DIRS}\n")
+  set(CMAKE_HAIKU_SECONDARY_ARCH "${CMAKE_MATCH_2}")
+endif()
 
 if(NOT CMAKE_HAIKU_SECONDARY_ARCH)
   set(CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR "")
-- 
2.30.2


From 4ccc91554689dbc64cf1e077e7cebeb2018ad40f Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Fri, 21 Feb 2020 15:38:39 -0500
Subject: Modules/Haiku: Set CMAKE_SYSTEM_FRAMEWORK_PATH.


diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake
index 08b11a4..9a8ae60 100644
--- a/Modules/Platform/Haiku.cmake
+++ b/Modules/Platform/Haiku.cmake
@@ -124,6 +124,9 @@ LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
 
 LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES})
 
+# This is needed for find_package to search develop/lib/cmake/.
+list(APPEND CMAKE_SYSTEM_FRAMEWORK_PATH /boot/system/develop /boot/system/non-packaged/develop)
+
 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
   set(CMAKE_INSTALL_PREFIX "/boot/system" CACHE PATH
     "Install path prefix, prepended onto install directories." FORCE)
-- 
2.30.2


From c4503c077c11b804c75e0d57a89660a083bf9b20 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 15 Apr 2021 21:09:12 +0200
Subject: disable dependency tracking for older GNU compilers


diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 928e726..87d0167 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -48,7 +48,9 @@ macro(__compiler_gnu lang)
     # distcc does not transform -o to -MT when invoking the preprocessor
     # internally, as it ought to.  Work around this bug by setting -MT here
     # even though it isn't strictly necessary.
-    set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
+    if(NOT CMAKE_${lang}_COMPILER_ID STREQUAL "GNU" OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.0)
+      set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
+    endif()
   endif()
 
   # Initial configuration flags.
-- 
2.30.2


From b054b8fc7190ad1188ce4aeb3aa69561725428e4 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 20 Oct 2021 14:28:22 +0200
Subject: Haiku: fix install dirs, let FindPackage search in data/


diff --git a/Source/CMakeInstallDestinations.cmake b/Source/CMakeInstallDestinations.cmake
index e82bec3..7e5f577 100644
--- a/Source/CMakeInstallDestinations.cmake
+++ b/Source/CMakeInstallDestinations.cmake
@@ -1,11 +1,11 @@
 # Keep formatting here consistent with bootstrap script expectations.
-if(BEOS)
+if(BEOS OR HAIKU)
   set(CMAKE_BIN_DIR_DEFAULT "bin") # HAIKU
-  set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU
+  set(CMAKE_DATA_DIR_DEFAULT "data/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU
   set(CMAKE_DOC_DIR_DEFAULT "documentation/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU
   set(CMAKE_INFO_DIR_DEFAULT "documentation/info") # HAIKU
   set(CMAKE_MAN_DIR_DEFAULT "documentation/man") # HAIKU
-  set(CMAKE_XDGDATA_DIR_DEFAULT "share") # HAIKU
+  set(CMAKE_XDGDATA_DIR_DEFAULT "data") # HAIKU
 elseif(CYGWIN)
   set(CMAKE_BIN_DIR_DEFAULT "bin") # CYGWIN
   set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION}") # CYGWIN
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 335ebbe..0f64bbe 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -2335,7 +2335,11 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
     common.emplace_back("libx32");
   }
   common.emplace_back("lib");
+#ifdef __HAIKU__
+  common.emplace_back("data");
+#else
   common.emplace_back("share");
+#endif
 
   //  PREFIX/(lib/ARCH|lib*|share)/cmake/(Foo|foo|FOO).*/
   {
-- 
2.30.2


From d3707e69837792212ff7aa8475c4a3f6e972eb1b Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 23 Feb 2022 13:44:06 +0100
Subject: Disable weak symbols; they do not seem to behave correctly.


diff --git a/Utilities/cmzstd/lib/common/zstd_trace.h b/Utilities/cmzstd/lib/common/zstd_trace.h
index 485cadf..95dc81b 100644
--- a/Utilities/cmzstd/lib/common/zstd_trace.h
+++ b/Utilities/cmzstd/lib/common/zstd_trace.h
@@ -20,7 +20,7 @@ extern "C" {
 /* weak symbol support */
 #if !defined(ZSTD_HAVE_WEAK_SYMBOLS) && defined(__GNUC__) && \
     !defined(__APPLE__) && !defined(_WIN32) && !defined(__MINGW32__) && \
-    !defined(__CYGWIN__) && !defined(_AIX)
+    !defined(__CYGWIN__) && !defined(_AIX) && !defined(__HAIKU__)
 #  define ZSTD_HAVE_WEAK_SYMBOLS 1
 #else
 #  define ZSTD_HAVE_WEAK_SYMBOLS 0
-- 
2.30.2

