ENH: add initial support for HAIKU OS from bug# 7425

This commit is contained in:
Bill Hoffman 2008-09-15 17:53:28 -04:00
parent f49f1d2973
commit 64fc597de2
20 changed files with 97 additions and 16 deletions

View File

@ -50,6 +50,10 @@ PROGRAM CMakeFortranCompilerId
PRINT *, 'INFO:platform[IRIX]' PRINT *, 'INFO:platform[IRIX]'
#elif defined(__hpux) || defined(__hpux__) #elif defined(__hpux) || defined(__hpux__)
PRINT *, 'INFO:platform[HP-UX]' 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) #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
PRINT *, 'INFO:platform[BeOS]' PRINT *, 'INFO:platform[BeOS]'
#elif defined(__QNX__) || defined(__QNXNTO__) #elif defined(__QNX__) || defined(__QNXNTO__)

View File

@ -35,6 +35,12 @@
#elif defined(__hpux) || defined(__hpux__) #elif defined(__hpux) || defined(__hpux__)
# define PLATFORM_ID "HP-UX" # 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) #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
# define PLATFORM_ID "BeOS" # define PLATFORM_ID "BeOS"

View File

@ -16,7 +16,7 @@ int main(int ac, char*av[]){
pthread_create(&tid[0], 0, runner, (void*)1); pthread_create(&tid[0], 0, runner, (void*)1);
pthread_create(&tid[1], 0, runner, (void*)2); 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 usleep(1); // for strange behavior on single-processor sun
#endif #endif

View File

@ -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)

View File

@ -1052,7 +1052,17 @@ bool cmCTestTestHandler::GetValue(const char* tag,
bool ret = true; bool ret = true;
if(line == tag) if(line == tag)
{ {
#ifdef __HAIKU__
int tmp = 0;
fin >> tmp;
value = false;
if(tmp)
{
value = true;
}
#else
fin >> value; fin >> value;
#endif
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
} }
else else

View File

@ -49,10 +49,15 @@
#include <memory> // auto_ptr #include <memory> // auto_ptr
#if defined(__BEOS__) #if defined(__BEOS__) && !defined(__HAIKU__)
#include <be/kernel/OS.h> /* disable_debugger() API. */ #include <be/kernel/OS.h> /* disable_debugger() API. */
#endif #endif
#if defined(__HAIKU__)
#include <os/kernel/OS.h> /* disable_debugger() API. */
#endif
#define DEBUGOUT std::cout << __LINE__ << " "; std::cout #define DEBUGOUT std::cout << __LINE__ << " "; std::cout
#define DEBUGERR std::cerr << __LINE__ << " "; std::cerr #define DEBUGERR std::cerr << __LINE__ << " "; std::cerr
@ -610,7 +615,7 @@ void cmCTest::BlockTestErrorDiagnostics()
cmSystemTools::PutEnv("DASHBOARD_TEST_FROM_CTEST=" CMake_VERSION); cmSystemTools::PutEnv("DASHBOARD_TEST_FROM_CTEST=" CMake_VERSION);
#if defined(_WIN32) #if defined(_WIN32)
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
#elif defined(__BEOS__) #elif defined(__BEOS__) || defined(__HAIKU__)
disable_debugger(1); disable_debugger(1);
#endif #endif
} }

View File

@ -23,7 +23,7 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(__BEOS__) #if defined(__BEOS__) || defined (__HAIKU__)
#include <unistd.h> /* prevents a conflict with a #define later on... */ #include <unistd.h> /* prevents a conflict with a #define later on... */
#endif #endif

View File

@ -38,7 +38,7 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(__BEOS__) #if defined(__BEOS__) || defined(__HAIKU__)
#include <unistd.h> /* prevents a conflict with a #define later on... */ #include <unistd.h> /* prevents a conflict with a #define later on... */
#endif #endif

View File

@ -932,6 +932,7 @@ bool RunCommandViaPopen(const char* command,
cmSystemTools::Stdout(buffer); cmSystemTools::Stdout(buffer);
} }
output += buffer; output += buffer;
buffer[0] = 0;
fgets(buffer, BUFFER_SIZE, cpipe); fgets(buffer, BUFFER_SIZE, cpipe);
} }
@ -971,11 +972,13 @@ bool RunCommandViaPopen(const char* command,
error << "SIGFPE"; error << "SIGFPE";
break; break;
#endif #endif
#ifndef __HAIKU__
#ifdef SIGBUS #ifdef SIGBUS
case SIGBUS: case SIGBUS:
error << "SIGBUS"; error << "SIGBUS";
break; break;
#endif #endif
#endif
#ifdef SIGSEGV #ifdef SIGSEGV
case SIGSEGV: case SIGSEGV:
error << "SIGSEGV"; error << "SIGSEGV";
@ -1698,7 +1701,7 @@ int cmSystemToolsGZStructOpen(void* call_data, const char *pathname,
} }
// no fchmod on BeOS 5...do pathname instead. // 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)) if ((oflags & O_CREAT) && chmod(pathname, mode))
{ {
return -1; return -1;

View File

@ -335,11 +335,21 @@ const char* DynamicLoader::LastError()
#endif //_WIN32 #endif //_WIN32
// --------------------------------------------------------------- // ---------------------------------------------------------------
// 4. Implementation for BeOS // 4. Implementation for BeOS / Haiku
#ifdef __BEOS__ #if defined __BEOS__ || defined(__HAIKU__)
#include <string.h> // for strerror() #include <string.h> // for strerror()
#ifdef __BEOS__
#include <be/kernel/image.h> #include <be/kernel/image.h>
#include <be/support/Errors.h> #include <be/support/Errors.h>
#endif
#ifdef __HAIKU__
#include <os/kernel/image.h>
#include <os/support/Errors.h>
#endif
#define DYNAMICLOADER_DEFINED 1 #define DYNAMICLOADER_DEFINED 1
namespace KWSYS_NAMESPACE namespace KWSYS_NAMESPACE

View File

@ -131,7 +131,12 @@ public:
#define _chdir chdir #define _chdir chdir
#endif #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/kernel/OS.h>
#include <be/storage/Path.h> #include <be/storage/Path.h>

View File

@ -17,10 +17,14 @@
#include KWSYS_HEADER(ios/iostream) #include KWSYS_HEADER(ios/iostream)
#include KWSYS_HEADER(stl/string) #include KWSYS_HEADER(stl/string)
#if defined(__BEOS__) #if defined(__BEOS__) && !defined(__HAIKU__)
#include <be/kernel/OS.h> /* disable_debugger() API. */ #include <be/kernel/OS.h> /* disable_debugger() API. */
#endif #endif
#if defined(__HAIKU__)
#include <os/kernel/OS.h> /* disable_debugger() API. */
#endif
// Work-around CMake dependency scanning limitation. This must // Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers. // duplicate the above list of headers.
#if 0 #if 0

View File

@ -34,7 +34,7 @@
# pragma warn -8060 /* possibly incorrect assignment */ # pragma warn -8060 /* possibly incorrect assignment */
#endif #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. */ /* BeOS 5 doesn't have usleep(), but it has snooze(), which is identical. */
# include <be/kernel/OS.h> # include <be/kernel/OS.h>
static inline void testProcess_usleep(unsigned int msec) static inline void testProcess_usleep(unsigned int msec)

View File

@ -38,7 +38,7 @@ main ()
# define PLATFORM_AIX_V3 # define PLATFORM_AIX_V3
#endif #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" #error "O_NONBLOCK does not work on this platform"
#endif #endif
int socket; int socket;

View File

@ -165,6 +165,8 @@ IF(BEOS)
CHECK_LIBRARY_EXISTS_CONCAT("bnetapi" closesocket HAVE_LIBBNETAPI) CHECK_LIBRARY_EXISTS_CONCAT("bnetapi" closesocket HAVE_LIBBNETAPI)
ENDIF(BEOS) ENDIF(BEOS)
CHECK_LIBRARY_EXISTS_CONCAT("network" recv HAVE_LIBNETWORK)
IF(NOT NOT_NEED_LIBNSL) IF(NOT NOT_NEED_LIBNSL)
CHECK_LIBRARY_EXISTS_CONCAT("nsl" gethostbyname HAVE_LIBNSL) CHECK_LIBRARY_EXISTS_CONCAT("nsl" gethostbyname HAVE_LIBNSL)
ENDIF(NOT NOT_NEED_LIBNSL) ENDIF(NOT NOT_NEED_LIBNSL)

View File

@ -1133,7 +1133,7 @@ typedef enum {
} }
#endif #endif
#ifdef __BEOS__ #if defined __BEOS__ || defined __HAIKU__
#include <support/SupportDefs.h> #include <support/SupportDefs.h>
#endif #endif

View File

@ -237,7 +237,7 @@
# endif # endif
#endif #endif
#if defined (__BEOS__) #if defined (__BEOS__) && !defined (__HAIKU__)
# ifdef ZLIB_DLL # ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL # ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport) # define ZEXPORT __declspec(dllexport)

View File

@ -147,6 +147,12 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define OS_CODE 0x0f # define OS_CODE 0x0f
#endif #endif
/* 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) #if defined(_BEOS_) || defined(RISCOS)
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
#endif #endif

View File

@ -73,6 +73,13 @@ else
cmake_system_beos=false cmake_system_beos=false
fi 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. # Choose the generator to use for bootstrapping.
if ${cmake_system_mingw}; then if ${cmake_system_mingw}; then
# Bootstrapping from an MSYS prompt. # Bootstrapping from an MSYS prompt.
@ -603,6 +610,11 @@ if ${cmake_system_beos}; then
cmake_ld_flags="${LDFLAGS} -lroot -lbe" cmake_ld_flags="${LDFLAGS} -lroot -lbe"
fi fi
# Add Haiku toolkits...
if ${cmake_system_haiku}; then
cmake_ld_flags="${LDFLAGS} -lroot -lbe"
fi
# Test C compiler # Test C compiler
cmake_c_compiler= cmake_c_compiler=