diff -urN Python-2.5.4/Modules/socketmodule.h Python-2.5.4-haiku/Modules/socketmodule.h
--- Python-2.5.4/Modules/socketmodule.h	2009-01-13 06:55:28.000000000 +0000
+++ Python-2.5.4-haiku/Modules/socketmodule.h	2009-01-13 07:00:07.000000000 +0000
@@ -41,6 +41,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.5.4/Modules/spwdmodule.c Python-2.5.4-haiku/Modules/spwdmodule.c
--- Python-2.5.4/Modules/spwdmodule.c	2009-01-13 06:55:28.000000000 +0000
+++ Python-2.5.4-haiku/Modules/spwdmodule.c	2009-01-13 07:00:07.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.5.4/Modules/timemodule.c Python-2.5.4-haiku/Modules/timemodule.c
--- Python-2.5.4/Modules/timemodule.c	2009-01-13 06:55:28.000000000 +0000
+++ Python-2.5.4-haiku/Modules/timemodule.c	2009-01-13 07:00:07.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.5.4/Tools/scripts/h2py.py Python-2.5.4-haiku/Tools/scripts/h2py.py
--- Python-2.5.4/Tools/scripts/h2py.py	2009-01-13 06:55:41.000000000 +0000
+++ Python-2.5.4-haiku/Tools/scripts/h2py.py	2009-01-13 07:00:08.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.5.4/configure.in Python-2.5.4-haiku/configure.in
--- Python-2.5.4/configure.in	2009-01-13 06:56:08.000000000 +0000
+++ Python-2.5.4-haiku/configure.in	2009-01-13 07:00:08.000000000 +0000
@@ -627,6 +627,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'
@@ -709,7 +714,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;;
@@ -1445,6 +1450,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*) 
@@ -1585,6 +1594,7 @@
 		   *) CCSHARED="";;
 		   esac;;
 	atheos*) CCSHARED="-fPIC";;
+	Haiku*) CCSHARED="-fPIC";;
 	esac
 fi
 AC_MSG_RESULT($CCSHARED)
@@ -1710,6 +1720,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)
@@ -2879,7 +2892,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.5.4/setup.py Python-2.5.4-haiku/setup.py
--- Python-2.5.4/setup.py	2009-01-13 06:56:07.000000000 +0000
+++ Python-2.5.4-haiku/setup.py	2009-01-13 07:00:08.000000000 +0000
@@ -338,7 +338,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
@@ -912,7 +912,7 @@
                 exts.append( Extension('resource', ['resource.c']) )
 
             # Sun yellow pages. Some systems have the functions in libc.
-            if platform not in ['cygwin', 'atheos']:
+            if platform not in ['cygwin', 'atheos', 'haiku1']:
                 if (self.compiler.find_library_file(lib_dirs, 'nsl')):
                     libs = ['nsl']
                 else:
