diff -urN Python-2.6/Modules/resource.c Python-2.6-haiku/Modules/resource.c
--- Python-2.6/Modules/resource.c	2006-09-16 17:36:37.000000000 +0000
+++ Python-2.6-haiku/Modules/resource.c	2008-10-20 01:21:37.000000000 +0000
@@ -86,6 +86,7 @@
 			PyFloat_FromDouble(doubletime(ru.ru_utime)));
 	PyStructSequence_SET_ITEM(result, 1,
 			PyFloat_FromDouble(doubletime(ru.ru_stime)));
+#ifndef __HAIKU__
 	PyStructSequence_SET_ITEM(result, 2, PyInt_FromLong(ru.ru_maxrss));
 	PyStructSequence_SET_ITEM(result, 3, PyInt_FromLong(ru.ru_ixrss));
 	PyStructSequence_SET_ITEM(result, 4, PyInt_FromLong(ru.ru_idrss));
@@ -100,6 +101,7 @@
 	PyStructSequence_SET_ITEM(result, 13, PyInt_FromLong(ru.ru_nsignals));
 	PyStructSequence_SET_ITEM(result, 14, PyInt_FromLong(ru.ru_nvcsw));
 	PyStructSequence_SET_ITEM(result, 15, PyInt_FromLong(ru.ru_nivcsw));
+#endif
 
 	if (PyErr_Occurred()) {
 		Py_DECREF(result);
diff -urN Python-2.6/Modules/selectmodule.c Python-2.6-haiku/Modules/selectmodule.c
--- Python-2.6/Modules/selectmodule.c	2008-09-21 07:14:44.000000000 +0000
+++ Python-2.6-haiku/Modules/selectmodule.c	2008-10-20 01:21:37.000000000 +0000
@@ -50,7 +50,7 @@
 #  include <winsock.h>
 #else
 #  define SOCKET int
-#  ifdef __BEOS__
+#  if defined(__BEOS__) && !defined(__HAIKU__)
 #    include <net/socket.h>
 #  elif defined(__VMS)
 #    include <socket.h>
diff -urN Python-2.6/Modules/socketmodule.c Python-2.6-haiku/Modules/socketmodule.c
--- Python-2.6/Modules/socketmodule.c	2008-08-12 14:49:50.000000000 +0000
+++ Python-2.6-haiku/Modules/socketmodule.c	2008-10-20 01:21:37.000000000 +0000
@@ -264,7 +264,7 @@
 # include <netdb.h>
 
 /* Headers needed for inet_ntoa() and inet_addr() */
-# ifdef __BEOS__
+# if defined(__BEOS__) && !defined(__HAIKU__)
 #  include <net/netdb.h>
 # elif defined(PYOS_OS2) && defined(PYCC_VACPP)
 #  include <netdb.h>
@@ -358,7 +358,7 @@
 #include "getnameinfo.c"
 #endif
 
-#if defined(MS_WINDOWS) || defined(__BEOS__)
+#if defined(MS_WINDOWS) || (defined(__BEOS__) && !defined(__HAIKU__))
 /* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */
 /* seem to be a few differences in the API */
 #define SOCKETCLOSE closesocket
@@ -621,7 +621,7 @@
 #endif
 
 	Py_BEGIN_ALLOW_THREADS
-#ifdef __BEOS__
+#if defined(__BEOS__) && !defined(__HAIKU__)
 	block = !block;
 	setsockopt(s->sock_fd, SOL_SOCKET, SO_NONBLOCK,
 		   (void *)(&block), sizeof(int));
@@ -650,7 +650,7 @@
 	block = !block;
 	socketioctl(s->sock_fd, FIONBIO, (u_long*)&block);
 #endif /* RISCOS */
-#endif /* __BEOS__ */
+#endif /* defined(__BEOS__) && !defined(__HAIKU__) */
 	Py_END_ALLOW_THREADS
 
 	/* Since these don't return anything */
@@ -975,7 +975,7 @@
 		return Py_None;
 	}
 
-#ifdef __BEOS__
+#if defined(__BEOS__) && !defined(__HAIKU__)
 	/* XXX: BeOS version of accept() doesn't set family correctly */
 	addr->sa_family = AF_INET;
 #endif
@@ -1824,7 +1824,7 @@
 	PyObject *buf;
 	socklen_t buflen = 0;
 
-#ifdef __BEOS__
+#if defined(__BEOS__) && !defined(__HAIKU__)
 	/* We have incomplete socket support. */
 	PyErr_SetString(socket_error, "getsockopt not supported");
 	return NULL;
@@ -1865,7 +1865,7 @@
 	}
 	_PyString_Resize(&buf, buflen);
 	return buf;
-#endif /* __BEOS__ */
+#endif /* defined(__BEOS__) && !defined(__HAIKU__) */
 }
 
 PyDoc_STRVAR(getsockopt_doc,
@@ -3474,7 +3474,7 @@
 {
 	char *name;
 	struct protoent *sp;
-#ifdef __BEOS__
+#if defined(__BEOS__) && !defined(__HAIKU__)
 /* Not available in BeOS yet. - [cjh] */
 	PyErr_SetString(socket_error, "getprotobyname not supported");
 	return NULL;
@@ -4630,7 +4630,7 @@
 	/* Socket types */
 	PyModule_AddIntConstant(m, "SOCK_STREAM", SOCK_STREAM);
 	PyModule_AddIntConstant(m, "SOCK_DGRAM", SOCK_DGRAM);
-#ifndef __BEOS__
+#if defined(__BEOS__) && !defined(__HAIKU__)
 /* We have incomplete socket support. */
 	PyModule_AddIntConstant(m, "SOCK_RAW", SOCK_RAW);
 	PyModule_AddIntConstant(m, "SOCK_SEQPACKET", SOCK_SEQPACKET);
diff -urN Python-2.6/Modules/socketmodule.h Python-2.6-haiku/Modules/socketmodule.h
--- Python-2.6/Modules/socketmodule.h	2008-06-14 08:36:07.000000000 +0000
+++ Python-2.6-haiku/Modules/socketmodule.h	2008-10-20 01:21:37.000000000 +0000
@@ -47,6 +47,10 @@
 #  undef AF_NETLINK
 #endif
 
+#if defined(__HAIKU__)
+#undef HAVE_BLUETOOTH_BLUETOOTH_H
+#endif
+
 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/rfcomm.h>
diff -urN Python-2.6/Modules/spwdmodule.c Python-2.6-haiku/Modules/spwdmodule.c
--- Python-2.6/Modules/spwdmodule.c	2008-06-09 04:58:54.000000000 +0000
+++ Python-2.6-haiku/Modules/spwdmodule.c	2008-10-20 01:21:37.000000000 +0000
@@ -79,7 +79,9 @@
 
 	SETS(setIndex++, p->sp_namp);
 	SETS(setIndex++, p->sp_pwdp);
+#ifndef __HAIKU__
 	SETI(setIndex++, p->sp_lstchg);
+#endif
 	SETI(setIndex++, p->sp_min);
 	SETI(setIndex++, p->sp_max);
 	SETI(setIndex++, p->sp_warn);
diff -urN Python-2.6/Modules/timemodule.c Python-2.6-haiku/Modules/timemodule.c
--- Python-2.6/Modules/timemodule.c	2008-07-05 19:19:50.000000000 +0000
+++ Python-2.6-haiku/Modules/timemodule.c	2008-10-20 01:21:37.000000000 +0000
@@ -968,11 +968,11 @@
 		return -1;
 	}
 	Py_END_ALLOW_THREADS
-#elif defined(__BEOS__)
+#elif defined(__BEOS__) || defined(__HAIKU__)
 	/* This sleep *CAN BE* interrupted. */
 	{
 		if( secs <= 0.0 ) {
-			return;
+			return 0;
 		}
 
 		Py_BEGIN_ALLOW_THREADS
diff -urN Python-2.6/Tools/scripts/h2py.py Python-2.6-haiku/Tools/scripts/h2py.py
--- Python-2.6/Tools/scripts/h2py.py	2004-08-09 17:27:55.000000000 +0000
+++ Python-2.6-haiku/Tools/scripts/h2py.py	2008-10-20 02:34:15.000000000 +0000
@@ -50,7 +50,7 @@
         searchdirs=os.environ['INCLUDE'].split(';')
     except KeyError:
         try:
-            if  sys.platform.find("beos") == 0:
+            if  sys.platform.find("beos") == 0 or sys.platform.find("haiku1") == 0:
                 searchdirs=os.environ['BEINCLUDES'].split(';')
             elif sys.platform.startswith("atheos"):
                 searchdirs=os.environ['C_INCLUDE_PATH'].split(':')
diff -urN Python-2.6/configure.in Python-2.6-haiku/configure.in
--- Python-2.6/configure.in	2008-09-07 19:18:16.000000000 +0000
+++ Python-2.6-haiku/configure.in	2008-10-20 01:21:38.000000000 +0000
@@ -694,6 +694,11 @@
     BeOS*)
           LDLIBRARY='libpython$(VERSION).so'
           ;;
+    Haiku*)
+          LDLIBRARY='libpython$(VERSION).so'
+          BLDLIBRARY='-L. -lpython$(VERSION)'
+          RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
+          ;;
     CYGWIN*)
           LDLIBRARY='libpython$(VERSION).dll.a'
           DLLLIBRARY='libpython$(VERSION).dll'
@@ -776,7 +781,7 @@
 AC_SUBST(LN)
 if test -z "$LN" ; then
 	case $ac_sys_system in
-		BeOS*) LN="ln -s";;
+		BeOS*|Haiku*) LN="ln -s";;
 		CYGWIN*) LN="ln -s";;
 		atheos*) LN="ln -s";;
 		*) LN=ln;;
@@ -1614,6 +1619,10 @@
 		BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
 		LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
 		;;
+	Haiku*)
+		LDFLAGS="-L." # help ld find libpythonX.Y.so in root directory
+		LDSHARED="gcc -shared"
+		;;
 	IRIX/5*) LDSHARED="ld -shared";;
 	IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
 	SunOS/5*) 
@@ -1745,6 +1754,7 @@
 		   *) CCSHARED="";;
 		   esac;;
 	atheos*) CCSHARED="-fPIC";;
+	Haiku*) CCSHARED="-fPIC";;
 	esac
 fi
 AC_MSG_RESULT($CCSHARED)
@@ -1878,6 +1888,9 @@
 BeOS*)
 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
 ;;
+Haiku*)
+AC_CHECK_LIB(network, socket, [LIBS="-lnetwork $LIBS"], [], $LIBS) # Haiku
+;;
 esac
 
 AC_MSG_CHECKING(for --with-libs)
@@ -3096,7 +3109,7 @@
 AC_SUBST(LIBM)
 case $ac_sys_system in
 Darwin) ;;
-BeOS) ;;
+BeOS|Haiku) ;;
 *) LIBM=-lm
 esac
 AC_MSG_CHECKING(for --with-libm=STRING)
diff -urN Python-2.6/setup.py Python-2.6-haiku/setup.py
--- Python-2.6/setup.py	2008-09-30 00:15:45.000000000 +0000
+++ Python-2.6-haiku/setup.py	2008-10-20 01:28:27.000000000 +0000
@@ -404,7 +404,7 @@
 
         # Check for MacOS X, which doesn't need libm.a at all
         math_libs = ['m']
-        if platform in ['darwin', 'beos', 'mac']:
+        if platform in ['darwin', 'beos', 'haiku1', 'mac']:
             math_libs = []
 
         # XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -1051,7 +1051,7 @@
                 missing.append('resource')
 
             # Sun yellow pages. Some systems have the functions in libc.
-            if platform not in ['cygwin', 'atheos', 'qnx6']:
+            if platform not in ['cygwin', 'atheos', 'qnx6', haiku1']:
                 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
                     libs = ['nsl']
                 else:
