  /* BeOS 5 doesn't have usleep(), but it has snooze(), which is identical. */
  # include <be/kernel/OS.h>
  static inline void kwsysProcess_usleep(unsigned int msec)
-diff -ur cmake-2.6.1/Source/kwsys/SystemTools.cxx cmake-2.6.1-haiku/Source/kwsys/SystemTools.cxx
+@@ -2534,6 +2534,7 @@
+     }
+ 
+   /* If this is the first process, enable the signal handler.  */
++#ifndef __HAIKU__
+   if(newProcesses.Count == 1)
+     {
+     /* Install our handler for SIGCHLD.  Repeat call until it is not
+@@ -2554,6 +2555,7 @@
+                      &kwsysProcessesOldSigChldAction) < 0) &&
+           (errno == EINTR));
+     }
++#endif
+   }
+ 
+   return 1;
+diff -urN cmake-2.6.1/Source/kwsys/ProcessUNIX.c.rej cmake-2.6.1-haiku/Source/kwsys/ProcessUNIX.c.rej
+--- cmake-2.6.1/Source/kwsys/ProcessUNIX.c.rej	1970-01-01 00:00:00.000000000 +0000
++++ cmake-2.6.1-haiku/Source/kwsys/ProcessUNIX.c.rej	2008-08-20 13:48:25.000000000 +0000
+@@ -0,0 +1,53 @@
++***************
++*** 135,142 ****
++  static void kwsysProcessKill(pid_t process_id);
++  static int kwsysProcessesAdd(kwsysProcess* cp);
++  static void kwsysProcessesRemove(kwsysProcess* cp);
++  static void kwsysProcessesSignalHandler(int signum, siginfo_t* info,
++                                          void* ucontext);
++  static char** kwsysProcessParseVerbatimCommand(const char* command);
++  
++  /*--------------------------------------------------------------------------*/
++--- 135,144 ----
++  static void kwsysProcessKill(pid_t process_id);
++  static int kwsysProcessesAdd(kwsysProcess* cp);
++  static void kwsysProcessesRemove(kwsysProcess* cp);
+++ #ifndef __HAIKU__
++  static void kwsysProcessesSignalHandler(int signum, siginfo_t* info,
++                                          void* ucontext);
+++ #endif
++  static char** kwsysProcessParseVerbatimCommand(const char* command);
++  
++  /*--------------------------------------------------------------------------*/
++***************
++*** 2396,2401 ****
++  }
++  
++  /*--------------------------------------------------------------------------*/
++  static void kwsysProcessesSignalHandler(int signum, siginfo_t* info,
++                                          void* ucontext)
++  {
++--- 2400,2406 ----
++  }
++  
++  /*--------------------------------------------------------------------------*/
+++ #ifndef __HAIKU__ 
++  static void kwsysProcessesSignalHandler(int signum, siginfo_t* info,
++                                          void* ucontext)
++  {
++***************
++*** 2417,2422 ****
++      write(cp->SignalPipe, &buf, 1);
++      }
++  }
++  
++  /*--------------------------------------------------------------------------*/
++  static int kwsysProcessAppendByte(char* local,
++--- 2422,2428 ----
++      write(cp->SignalPipe, &buf, 1);
++      }
++  }
+++ #endif
++  
++  /*--------------------------------------------------------------------------*/
++  static int kwsysProcessAppendByte(char* local,
+diff -urN cmake-2.6.1/Source/kwsys/SystemTools.cxx cmake-2.6.1-haiku/Source/kwsys/SystemTools.cxx
 --- cmake-2.6.1/Source/kwsys/SystemTools.cxx	2008-08-01 15:34:55.000000000 +0000
-+++ cmake-2.6.1-haiku/Source/kwsys/SystemTools.cxx	2008-08-13 16:07:42.000000000 +0000
++++ cmake-2.6.1-haiku/Source/kwsys/SystemTools.cxx	2008-08-20 13:49:06.000000000 +0000
 @@ -131,7 +131,12 @@
  #define _chdir chdir
  #endif
  
 -#if defined(__BEOS__) && !defined(__ZETA__)
-+#ifdef (__HAIKU__)
-+#include <os/kernel.OS.h>
++#if defined(__HAIKU__)
++#include <os/kernel/OS.h>
 +#include <os/storage/Path.h>
 +#endif
 +

   if ((oflags & O_CREAT) && chmod(pathname, mode & 07777))
     {
     return -1;
diff -ur cmake-2.6.1/Utilities/cmxmlrpc/xmlrpc_curl_transport.c cmake-2.6.1-haiku/Utilities/cmxmlrpc/xmlrpc_curl_transport.c
--- cmake-2.6.1/Utilities/cmxmlrpc/xmlrpc_curl_transport.c	2008-08-01 15:34:58.000000000 +0000
+++ cmake-2.6.1-haiku/Utilities/cmxmlrpc/xmlrpc_curl_transport.c	2008-08-13 16:07:42.000000000 +0000
@@ -10,7 +10,7 @@
 
 #include "xmlrpc_config.h"

 #define DEBUGOUT std::cout << __LINE__ << " "; std::cout
 #define DEBUGERR std::cerr << __LINE__ << " "; std::cerr
 
@@ -607,7 +612,7 @@
   cmSystemTools::PutEnv("DASHBOARD_TEST_FROM_CTEST=" CMake_VERSION);
 #if defined(_WIN32)
   SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
-#elif defined(__BEOS__)
+#elif defined(__BEOS__) || defined(__HAIKU__)
   disable_debugger(1);
 #endif
 }
diff -urN cmake-2.6.1/Source/cmDependsJavaLexer.cxx cmake-2.6.1-haiku/Source/cmDependsJavaLexer.cxx
--- cmake-2.6.1/Source/cmDependsJavaLexer.cxx	2008-08-01 15:34:51.000000000 +0000
+++ cmake-2.6.1-haiku/Source/cmDependsJavaLexer.cxx	2008-08-20 13:49:06.000000000 +0000
@@ -23,7 +23,7 @@
 #include <errno.h>
 #include <stdlib.h>
 
-#if defined(__BEOS__)
+#if defined(__BEOS__) || defined (__HAIKU__)
 #include <unistd.h>   /* prevents a conflict with a #define later on... */
 #endif
 
diff -urN cmake-2.6.1/Source/cmDependsJavaLexer.h cmake-2.6.1-haiku/Source/cmDependsJavaLexer.h
--- cmake-2.6.1/Source/cmDependsJavaLexer.h	2008-08-01 15:34:51.000000000 +0000
+++ cmake-2.6.1-haiku/Source/cmDependsJavaLexer.h	2008-08-20 13:49:06.000000000 +0000
@@ -38,7 +38,7 @@
 #include <errno.h>
 #include <stdlib.h>
 
-#if defined(__BEOS__)
+#if defined(__BEOS__) || defined(__HAIKU__)
 #include <unistd.h>   /* prevents a conflict with a #define later on... */
 #endif
 
diff -urN cmake-2.6.1/Source/cmSystemTools.cxx cmake-2.6.1-haiku/Source/cmSystemTools.cxx
--- cmake-2.6.1/Source/cmSystemTools.cxx	2008-08-01 15:34:53.000000000 +0000
+++ cmake-2.6.1-haiku/Source/cmSystemTools.cxx	2008-08-20 13:49:06.000000000 +0000
@@ -970,11 +970,13 @@
         error << "SIGFPE";
         break;
 #endif
+#ifndef __HAIKU__
 #ifdef SIGBUS
       case SIGBUS:
         error << "SIGBUS";
         break;
 #endif
+#endif
 #ifdef SIGSEGV
       case SIGSEGV:
         error << "SIGSEGV";
@@ -1696,7 +1698,7 @@
     }
 
 // no fchmod on BeOS 5...do pathname instead.
-#if defined(__BEOS__) && !defined(__ZETA__) 
+#if defined(__BEOS__) && !defined(__ZETA__) && !defined(__HAIKU__)
   if ((oflags & O_CREAT) && chmod(pathname, mode))
     {
     return -1;
diff -urN cmake-2.6.1/Source/kwsys/DynamicLoader.cxx cmake-2.6.1-haiku/Source/kwsys/DynamicLoader.cxx
--- cmake-2.6.1/Source/kwsys/DynamicLoader.cxx	2008-08-01 15:34:54.000000000 +0000
+++ cmake-2.6.1-haiku/Source/kwsys/DynamicLoader.cxx	2008-08-20 13:49:06.000000000 +0000
@@ -335,11 +335,21 @@
 #endif //_WIN32
 
 // ---------------------------------------------------------------
-// 4. Implementation for BeOS
-#ifdef __BEOS__
+// 4. Implementation for BeOS / Haiku
+#if defined __BEOS__ || defined(__HAIKU__)
+
 #include <string.h> // for strerror()
+
+#ifdef __BEOS__
 #include <be/kernel/image.h>
 #include <be/support/Errors.h>
+#endif
+
+#ifdef __HAIKU__
+#include <os/kernel/image.h>
+#include <os/support/Errors.h>
+#endif
+
 #define DYNAMICLOADER_DEFINED 1
 
 namespace KWSYS_NAMESPACE
diff -urN cmake-2.6.1/Source/kwsys/ProcessUNIX.c cmake-2.6.1-haiku/Source/kwsys/ProcessUNIX.c
--- cmake-2.6.1/Source/kwsys/ProcessUNIX.c	2008-08-01 15:34:54.000000000 +0000
+++ cmake-2.6.1-haiku/Source/kwsys/ProcessUNIX.c	2008-08-20 13:49:06.000000000 +0000
@@ -75,7 +75,7 @@
 typedef int kwsysProcess_ssize_t;
 #endif
