diff -Naurb flam3-3.0/src/Makefile.am flam3-3.0-haiku/src/Makefile.am
--- flam3-3.0/src/Makefile.am	2010-10-11 22:35:32.020447232 +0200
+++ flam3-3.0-haiku/src/Makefile.am	2010-11-16 10:56:25.806617088 +0100
@@ -11,19 +11,19 @@
 include_HEADERS = flam3.h isaac.h isaacs.h rect.c

 libflam3_la_SOURCES = flam3.c filters.c parser.c variations.c interpolation.c palettes.c jpeg.c png.c isaac.c
-libflam3_la_LDFLAGS = -no-undefined -ljpeg -lpng -lz -lpthread
+libflam3_la_LDFLAGS = -no-undefined -ljpeg -lpng -lz $(LIBPTHREAD)

 flam3_genome_SOURCES = flam3-genome.c docstring.c
-flam3_genome_LDADD = libflam3.la -lm
+flam3_genome_LDADD = libflam3.la $(LIBM)

 flam3_animate_SOURCES = flam3-animate.c docstring.c
-flam3_animate_LDADD = libflam3.la -lm
+flam3_animate_LDADD = libflam3.la $(LIBM)

 flam3_render_SOURCES = flam3-render.c docstring.c
-flam3_render_LDADD = libflam3.la -lm
+flam3_render_LDADD = libflam3.la $(LIBM)

 flam3_convert_SOURCES = flam3-convert.c docstring.c
-flam3_convert_LDADD = libflam3.la -lm
+flam3_convert_LDADD = libflam3.la $(LIBM)

 pkgdata_DATA = flam3-palettes.xml

diff -Naurb flam3-3.0/src/configure.in flam3-3.0-haiku/src/configure.in
--- flam3-3.0/src/configure.in	2010-10-11 22:35:32.020971520 +0200
+++ flam3-3.0-haiku/src/configure.in	2010-11-08 17:38:50.000000000 +0100
@@ -27,6 +27,7 @@
 AC_CHECK_LIB([z],[deflateInit_],,[AC_MSG_ERROR([zlib is required.])])
 AC_CHECK_LIB([png],[png_write_image],,[AC_MSG_ERROR([The png library is required.])])
 AC_CHECK_LIB([xml2],[xmlParseFile],,[AC_MSG_ERROR([The xml2 library is required.])])
+AC_CHECK_LIB([m], [cos], [LIBM="$LIBM -lm"])


 if test "${enable_atomic_ops}" = "" ; then
@@ -68,7 +69,10 @@
 fi

 if test "${enable_pthread}" = "yes" ; then
-  AC_CHECK_LIB([pthread],[pthread_create],,[AC_MSG_WARN([Pthread library not found - threads disabled.])])
+  AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD="-lpthread"],
+  	[AC_CHECK_LIB([root], [pthread_create], [LIBPTHREAD="", AC_DEFINE([HAVE_LIBPTHREAD], 1, [Have builtin pthread API])],
+  	   [AC_MSG_WARN([Pthread library not found - threads disabled.])])])
+#  AC_CHECK_LIB([pthread root],[pthread_create],,[AC_MSG_WARN([Pthread library not found - threads disabled.])])
 fi
 AC_CHECK_LIB([jpeg],[jpeg_start_compress],,[AC_MSG_ERROR([The jpeg library is required.])])
 AC_PATH_PROG(XML2_CONFIG,xml2-config, no, $PATH:/bin:/usr/bin:/usr/local/bin)
diff -Naurb flam3-3.0/src/flam3.c flam3-3.0-haiku/src/flam3.c
--- flam3-3.0/src/flam3.c	2010-10-11 22:35:32.026738688 +0200
+++ flam3-3.0-haiku/src/flam3.c	2010-11-08 17:13:58.000000000 +0100
@@ -50,9 +50,14 @@
 #include <windows.h>
 #define flam3_os "WIN"
 #else
+#ifdef __HAIKU__
+#include <OS.h>
+#define flam3_os "HAIKU"
+#else
 #define flam3_os "LNX"
 #endif
 #endif
+#endif



@@ -1339,6 +1344,11 @@
    return(1);
 #endif

+#ifdef __HAIKU__
+	system_info si;
+	get_system_info(&si);
+	nthreads = si.cpu_count;
+#else
 #ifdef _WIN32
    SYSTEM_INFO sysInfo;
    GetSystemInfo(&sysInfo);
@@ -1380,6 +1390,7 @@
 #endif
 #endif
 #endif
+#endif
    return (nthreads);
 }

