diff -Naur pl-6.0.2/src/configure.in pl-6.0.2-haiku/src/configure.in
--- pl-6.0.2/src/configure.in	2012-03-04 13:12:01.001835008 +0000
+++ pl-6.0.2-haiku/src/configure.in	2012-08-20 21:39:21.649330688 +0100
@@ -689,6 +689,10 @@
 	AC_DEFINE(_THREAD_SAFE, 1,
 		  [Required in FreeBSD for compiling thread-safe code])
 	;;
+    *haiku*)
+	pthread_ok=true
+	CFLAGS="$CFLAGS -lroot"
+	;;
     *-win32|*-win64)
         pthread_ok=true
 	AC_CHECK_LIB(pthreadGC2, pthread_create)
diff -Naur pl-6.0.2/src/os/pl-files.c pl-6.0.2-haiku/src/os/pl-files.c
--- pl-6.0.2/src/os/pl-files.c	2012-03-04 13:12:01.011272192 +0000
+++ pl-6.0.2-haiku/src/os/pl-files.c	2012-08-23 14:45:48.981204992 +0100
@@ -239,7 +239,7 @@
       return TRUE;
   }
 
-#ifdef __unix__				/* doesn't work on most not Unix's */
+#if defined(__unix__) || defined(__HAIKU__) /* doesn't work on most not Unix's */
   { statstruct buf1;
     statstruct buf2;
     char tmp[MAXPATHLEN];
diff -Naur pl-6.0.2/src/os/pl-os.c pl-6.0.2-haiku/src/os/pl-os.c
--- pl-6.0.2/src/os/pl-os.c	2012-03-04 13:12:01.011796480 +0000
+++ pl-6.0.2-haiku/src/os/pl-os.c	2012-08-23 16:02:11.794034176 +0100
@@ -590,7 +590,7 @@
   }
 
 retry:
-#ifdef __unix__
+#if defined(__unix__) || defined(__HAIKU__)
 { static int MTOK_temp_counter = 0;
   const char *sep = id[0] ? "_" : "";
 
@@ -732,7 +732,7 @@
 }
 #endif /* O_HPFS */
 
-#ifdef __unix__
+#if defined(__unix__) || defined(__HAIKU__)
 char *
 PrologPath(const char *p, char *buf, size_t len)
 { strncpy(buf, p, len);
@@ -2436,7 +2436,7 @@
   return strcpy(buffer, file ? file : buf);
 }
 
-#ifdef __unix__
+#if defined(__unix__) || defined(__HAIKU__)
 static char *
 okToExec(const char *s)
 { statstruct stbuff;
diff -Naur pl-6.0.2/src/pl-term.c pl-6.0.2-haiku/src/pl-term.c
--- pl-6.0.2/src/pl-term.c	2012-03-04 13:12:01.023592960 +0000
+++ pl-6.0.2-haiku/src/pl-term.c	2012-08-08 20:03:23.111673344 +0100
@@ -296,7 +296,7 @@
   term_t r = A1;
   term_t c = A2;
 
-#ifdef __unix__
+#if defined(__unix__) || defined(__HAIKU__)
   int iorval;
 
 #ifdef TIOCGSIZE
