diff --git a/Modules/CMakeFortranCompilerId.F90.in b/Modules/CMakeFortranCompilerId.F90.in
index 0949b5051f8c0fdc7e835ef99ab3ab2d2b83adc4..c7facb55033f68e3266fb2093ecc59b993a3a506 100644
--- a/Modules/CMakeFortranCompilerId.F90.in
+++ b/Modules/CMakeFortranCompilerId.F90.in
@@ -50,6 +50,10 @@ PROGRAM CMakeFortranCompilerId
    PRINT *, 'INFO:platform[IRIX]'
 #elif defined(__hpux) || defined(__hpux__)
    PRINT *, 'INFO:platform[HP-UX]'
+#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU)
+   PRINT *, 'INFO:platform[Haiku]'
+! Haiku also defines __BEOS__ so we must 
+! put it prior to the check for __BEOS__
 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
    PRINT *, 'INFO:platform[BeOS]'
 #elif defined(__QNX__) || defined(__QNXNTO__)
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 1f1fca6ff8c1b58af50403eff44e6443fffd28c6..8e786ba79fc28562dc49fb6d10c53fbbf1ffa3e0 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -35,6 +35,12 @@
 #elif defined(__hpux) || defined(__hpux__)
 # define PLATFORM_ID "HP-UX"
 
+#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU)
+# define PLATFORM_ID "Haiku"
+/* Haiku also defines __BEOS__ so we must 
+   put it prior to the check for __BEOS__
+*/
+
 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
 # define PLATFORM_ID "BeOS"
 
diff --git a/Modules/CheckForPthreads.c b/Modules/CheckForPthreads.c
index a846567ffc42b76296ecca291e856c73b22ccd67..d831078510221e2cd7d1b8b373ff0355318ba19a 100644
--- a/Modules/CheckForPthreads.c
+++ b/Modules/CheckForPthreads.c
@@ -16,7 +16,7 @@ int main(int ac, char*av[]){
   pthread_create(&tid[0], 0, runner, (void*)1);
   pthread_create(&tid[1], 0, runner, (void*)2);
   
-#if defined(__BEOS__) && !defined(__ZETA__)  // (no usleep on BeOS 5.)
+#if defined(__BEOS__) && !defined(__ZETA__)  && !defined(__HAIKU__) // (no usleep on BeOS 5.)
   usleep(1); // for strange behavior on single-processor sun
 #endif
 
diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..b3c2ea3301d5b6afd4a72182b3252b6fd5f07f11
--- /dev/null
+++ b/Modules/Platform/Haiku.cmake
@@ -0,0 +1,14 @@
+SET(BEOS 1)
+
+# GCC is the default compiler on Haiku.
+INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake)
+
+SET(CMAKE_DL_LIBS root be)
+SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
+SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostart")
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
+SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
+SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,")
+
+INCLUDE(Platform/UnixPaths)
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 90a33cb73beb84fc7c4d248f0eb42b8217eda02d..83d882b4215990a307149cb27286e77a4f7055a0 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1052,7 +1052,17 @@ bool cmCTestTestHandler::GetValue(const char* tag,
   bool ret = true;
   if(line == tag)
     {
+#ifdef __HAIKU__
+    int tmp = 0;
+    fin >> tmp;
+    value = false;
+    if(tmp)
+      {
+      value = true;
+      }
+#else
     fin >> value;
+#endif
     ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
     }
   else
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 77bf10267e635f727d1a54e10043c6fb4babbc5f..012571f922291bd83af804b870a5eab0192d8719 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -49,10 +49,15 @@
 
 #include <memory> // auto_ptr
 
-#if defined(__BEOS__)
+#if defined(__BEOS__) && !defined(__HAIKU__)
 #include <be/kernel/OS.h>   /* disable_debugger() API. */
 #endif
 
+#if defined(__HAIKU__)
+#include <os/kernel/OS.h>   /* disable_debugger() API. */
+#endif
+
+
 #define DEBUGOUT std::cout << __LINE__ << " "; std::cout
 #define DEBUGERR std::cerr << __LINE__ << " "; std::cerr
 
@@ -610,7 +615,7 @@ void cmCTest::BlockTestErrorDiagnostics()
   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 --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx
index 3af688adbbb4749d350d204f96711e08b70c8577..1a5907f479268837a0e4fb63ce1c7eddb48d26d0 100644
--- a/Source/cmDependsJavaLexer.cxx
+++ b/Source/cmDependsJavaLexer.cxx
@@ -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 --git a/Source/cmDependsJavaLexer.h b/Source/cmDependsJavaLexer.h
index 78ee089ca3a49b8037f386944fc39ed0401dbc3e..df7cffd70574e7675f93d401b0548441e0d3d6e9 100644
--- a/Source/cmDependsJavaLexer.h
+++ b/Source/cmDependsJavaLexer.h
@@ -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 --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 1d2a0cf49db6aeff0ad5269dbae7f811a2aa7c49..298d779e2d068fd0df02143f9846a9b17790d6b1 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -932,6 +932,7 @@ bool RunCommandViaPopen(const char* command,
       cmSystemTools::Stdout(buffer);
       }
     output += buffer;
+    buffer[0] = 0;
     fgets(buffer, BUFFER_SIZE, cpipe);
     }
 
@@ -971,11 +972,13 @@ bool RunCommandViaPopen(const char* command,
         error << "SIGFPE";
         break;
 #endif
+#ifndef __HAIKU__
 #ifdef SIGBUS
       case SIGBUS:
         error << "SIGBUS";
         break;
 #endif
+#endif
 #ifdef SIGSEGV
       case SIGSEGV:
         error << "SIGSEGV";
@@ -1698,7 +1701,7 @@ int cmSystemToolsGZStructOpen(void* call_data, const char *pathname,
     }
 
 // 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 --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index 1fdcaf011588edafab222d763c946e0d005cd33f..9ca914639902d76c62720d03444e19b133a6e961 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -335,11 +335,21 @@ const char* DynamicLoader::LastError()
 #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 --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 515bceb8c96d2324c5934e35c8ed967cb310cb7e..32b4d9e928ce86932117aa2309240d99fa00a3f7 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -75,7 +75,7 @@ typedef ssize_t kwsysProcess_ssize_t;
 typedef int kwsysProcess_ssize_t;
 #endif
 
-#if defined(__BEOS__) && !defined(__ZETA__)
+#if defined(__BEOS__) && !defined(__ZETA__) 
 /* 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 --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 1277d71a4c7ca564ba219fcba6f3c5a832ef9f6c..d4a81745c8ee20ddbbb94b92529a935b2b36d221 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -131,7 +131,12 @@ public:
 #define _chdir chdir
 #endif
 
-#if defined(__BEOS__) && !defined(__ZETA__)
+#if defined(__HAIKU__)
+#include <os/kernel/OS.h>
+#include <os/storage/Path.h>
+#endif
+
+#if defined(__BEOS__) && !defined(__ZETA__) && !defined(__HAIKU__)
 #include <be/kernel/OS.h>
 #include <be/storage/Path.h>
 
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index 9021239d5da6f5a525e2e60caae2258460a9b1e0..e2ab12a0b7fbdbfff61fc79c80f4f810ba238fb2 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -17,10 +17,14 @@
 #include KWSYS_HEADER(ios/iostream)
 #include KWSYS_HEADER(stl/string)
 
-#if defined(__BEOS__)
+#if defined(__BEOS__) && !defined(__HAIKU__)
 #include <be/kernel/OS.h>  /* disable_debugger() API. */
 #endif
 
+#if defined(__HAIKU__)
+#include <os/kernel/OS.h>  /* disable_debugger() API. */
+#endif
+
 // Work-around CMake dependency scanning limitation.  This must
 // duplicate the above list of headers.
 #if 0
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index 8ca56ed0c4e69953d5b8fe368d25622c5f3e74f2..9002035cf507d2e4097dd5a8ab3142016a453011 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -34,7 +34,7 @@
 # pragma warn -8060 /* possibly incorrect assignment */
 #endif
 
-#if defined(__BEOS__) && !defined(__ZETA__)
+#if defined(__BEOS__) && !defined(__ZETA__) && !defined(__HAIKU__)
 /* BeOS 5 doesn't have usleep(), but it has snooze(), which is identical. */
 # include <be/kernel/OS.h>
 static inline void testProcess_usleep(unsigned int msec)
diff --git a/Utilities/cmcurl/CMake/CurlTests.c b/Utilities/cmcurl/CMake/CurlTests.c
index c5ba7c28fc3714b3b82e65069a7aa43ef26245d9..d74a4f01664c3c366a55184e4c0e73c13e5505e8 100644
--- a/Utilities/cmcurl/CMake/CurlTests.c
+++ b/Utilities/cmcurl/CMake/CurlTests.c
@@ -38,7 +38,7 @@ main ()
 # define PLATFORM_AIX_V3
 #endif
 
-#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
+#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || (defined(__BEOS__) && !defined(__HAIKU__))
 #error "O_NONBLOCK does not work on this platform"
 #endif
   int socket;
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index d2f319de29db7cf76202ad865590c6cc2fd936b9..bd5ddfb171c70721ed89231cacc10b57a68dc4f1 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -165,6 +165,8 @@ IF(BEOS)
   CHECK_LIBRARY_EXISTS_CONCAT("bnetapi" closesocket HAVE_LIBBNETAPI)
 ENDIF(BEOS)
 
+CHECK_LIBRARY_EXISTS_CONCAT("network" recv HAVE_LIBNETWORK)
+
 IF(NOT NOT_NEED_LIBNSL)
   CHECK_LIBRARY_EXISTS_CONCAT("nsl"    gethostbyname  HAVE_LIBNSL)
 ENDIF(NOT NOT_NEED_LIBNSL)
diff --git a/Utilities/cmcurl/curl/curl.h b/Utilities/cmcurl/curl/curl.h
index f6dad457b67ef0031c0298f421eeea82739c88d5..157c634a46f8d3c45b31014cc78acb63ec4e7a5e 100644
--- a/Utilities/cmcurl/curl/curl.h
+++ b/Utilities/cmcurl/curl/curl.h
@@ -1133,7 +1133,7 @@ typedef enum {
 }
 #endif
 
-#ifdef __BEOS__
+#if defined __BEOS__ || defined __HAIKU__
 #include <support/SupportDefs.h>
 #endif
 
diff --git a/Utilities/cmzlib/zconf.h b/Utilities/cmzlib/zconf.h
index 7a3b6fdc1fe9ad0f36f65d5980647e2e6851bec7..6eb52d1334852bb58567eabee2348a41cc37d8be 100644
--- a/Utilities/cmzlib/zconf.h
+++ b/Utilities/cmzlib/zconf.h
@@ -237,7 +237,7 @@
 #  endif
 #endif
 
-#if defined (__BEOS__)
+#if defined (__BEOS__) && !defined (__HAIKU__)
 #  ifdef ZLIB_DLL
 #    ifdef ZLIB_INTERNAL
 #      define ZEXPORT   __declspec(dllexport)
diff --git a/Utilities/cmzlib/zutil.h b/Utilities/cmzlib/zutil.h
index b7d5eff81b69a3c23daec86c42dff4ba4746b1dd..74ef1f89fd67e9fee2faa279374f07795632dde3 100644
--- a/Utilities/cmzlib/zutil.h
+++ b/Utilities/cmzlib/zutil.h
@@ -147,7 +147,13 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 #  define OS_CODE  0x0f
 #endif
 
-#if defined(_BEOS_) || defined(RISCOS)
+/* Haiku defines both __HAIKU__ and __BEOS__ (for now) */
+/* many BeOS workarounds are no longer needed in Haiku */
+#if defined(__HAIKU__) && defined(__BEOS__)
+#undef __BEOS__
+#endif
+
+#if defined(_BEOS_) || defined(RISCOS) 
 #  define fdopen(fd,mode) NULL /* No fdopen() */
 #endif
 
diff --git a/bootstrap b/bootstrap
index 1dd0a65d4b53cfab3afd93fc9d3c25c419da2d73..3008d070bbb67f1a0e40f5c6fb697675b02e631c 100755
--- a/bootstrap
+++ b/bootstrap
@@ -73,6 +73,13 @@ else
   cmake_system_beos=false
 fi
 
+# Determine whether this is Haiku 
+if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
+  cmake_system_haiku=true
+else
+  cmake_system_haiku=false
+fi
+
 # Choose the generator to use for bootstrapping.
 if ${cmake_system_mingw}; then
   # Bootstrapping from an MSYS prompt.
@@ -603,6 +610,11 @@ if ${cmake_system_beos}; then
   cmake_ld_flags="${LDFLAGS} -lroot -lbe"
 fi
 
+# Add Haiku toolkits...
+if ${cmake_system_haiku}; then
+  cmake_ld_flags="${LDFLAGS} -lroot -lbe"
+fi
+
 # Test C compiler
 cmake_c_compiler=