From fc04fa4da521a34685b4b47955533b9b0b23502c Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 20 Jan 2016 21:13:28 +0000
Subject: llvm-config: use /develop/headers instead of /include

* don't provide obj-root and src-root.

diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 892adc3..c7d458b 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -333,11 +333,16 @@ int main(int argc, char **argv) {
         ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
     ActivePrefix = CurrentExecPrefix;
+#ifdef __HAIKU__
+    ActiveIncludeDir = ActivePrefix + "/develop/headers";
+    ActiveLibDir = ActivePrefix + "/develop/lib" + LLVM_LIBDIR_SUFFIX;
+#else
     ActiveIncludeDir = ActivePrefix + "/include";
+    ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
+#endif
     SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
     sys::fs::make_absolute(ActivePrefix, path);
     ActiveBinDir = path.str();
-    ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
     ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
     ActiveIncludeOption = "-I" + ActiveIncludeDir;
   }
@@ -557,10 +562,16 @@ int main(int argc, char **argv) {
         OS << (LLVM_HAS_GLOBAL_ISEL ? "ON" : "OFF") << '\n';
       } else if (Arg == "--shared-mode") {
         PrintSharedMode = true;
-      } else if (Arg == "--obj-root") {
-        OS << ActivePrefix << '\n';
-      } else if (Arg == "--src-root") {
-        OS << LLVM_SRC_ROOT << '\n';
+      } else if (Arg == "--obj-root" || Arg == "--src-root") {
+        if (IsInDevelopmentTree) {
+          if (Arg == "--obj-root")
+            OS << ActivePrefix << '\n';
+          else
+            OS << LLVM_SRC_ROOT << '\n';
+        } else {
+          llvm::errs() << "llvm-config: sources not installed\n";
+          exit(1);
+        }
       } else if (Arg == "--ignore-libllvm") {
         LinkDyLib = false;
         LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto;
-- 
2.19.0


From 794ef1780b5ce41f7b1d3580de7c25ac5fc41c0e Mon Sep 17 00:00:00 2001
From: Calvin Hill <calvin@hakobaito.co.uk>
Date: Sun, 9 Sep 2018 16:11:42 +0100
Subject: import header dir suffix patch from 3dEyes.


diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index c7d458b..1466ced 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -334,7 +334,7 @@ int main(int argc, char **argv) {
   } else {
     ActivePrefix = CurrentExecPrefix;
 #ifdef __HAIKU__
-    ActiveIncludeDir = ActivePrefix + "/develop/headers";
+    ActiveIncludeDir = ActivePrefix + "/develop/headers" + LLVM_LIBDIR_SUFFIX;
     ActiveLibDir = ActivePrefix + "/develop/lib" + LLVM_LIBDIR_SUFFIX;
 #else
     ActiveIncludeDir = ActivePrefix + "/include";
-- 
2.19.0


From 6ea7bafd02033fede16964fab563808ba035ae86 Mon Sep 17 00:00:00 2001
From: Calvin Hill <calvin@hakobaito.co.uk>
Date: Sun, 9 Sep 2018 16:17:33 +0100
Subject: llvm: allow llvm gtests to build on Haiku.


diff --git a/utils/unittest/googletest/include/gtest/internal/gtest-port.h b/utils/unittest/googletest/include/gtest/internal/gtest-port.h
index d36e820..e6dbb2d 100644
--- a/utils/unittest/googletest/include/gtest/internal/gtest-port.h
+++ b/utils/unittest/googletest/include/gtest/internal/gtest-port.h
@@ -793,7 +793,8 @@ using ::std::tuple_size;
      (GTEST_OS_MAC && !GTEST_OS_IOS) || \
      (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
      GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
-     GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || GTEST_OS_NETBSD)
+     GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || GTEST_OS_NETBSD \
+     || GTEST_OS_HAIKU)
 # define GTEST_HAS_DEATH_TEST 1
 #endif
 
-- 
2.19.0

