--- ./SConstruct.orig	Sat Jul 21 15:53:06 2007
+++ ./SConstruct	Wed Aug  1 08:00:59 2007
@@ -188,6 +188,15 @@
         else:
             print 'Configuring unknown system (assuming the system is POSIX-like) ...'
 
+        # pthreads
+        if str(Platform()) == 'posix':
+            if env['multithreaded']:
+                if conf.CheckCHeader('pthread.h') and conf.CheckLib('pthread', 'pthread_create', autoadd = 0):
+                    env.AppendUnique(CCFLAGS = ['-pthread'])
+                    env.AppendUnique(LINKFLAGS = ['-pthread'])
+                else:
+                    Exit(1)
+
         # Python
         import distutils.sysconfig
         if str(Platform()) == 'win32':
@@ -207,6 +216,8 @@
             matches = regex.findall(distutils.sysconfig.get_config_var('LDLIBRARY'))
             if len(matches):
                 python_libname = matches[0]
+	    elif os.environ.has_key('PYTHON_LIB'):
+	        python_libname = os.environ['PYTHON_LIB']
             else:
                 print 'Unable to determine the name of the Python runtime library.  Terminating....'
                 Exit(1)
@@ -253,15 +264,6 @@
                 env.AppendUnique(LIBS = [
                     BoostLibWin32Name('python', env)
                     ])
-
-            # pthreads
-            if str(Platform()) == 'posix':
-                if env['multithreaded']:
-                    if conf.CheckCHeader('pthread.h') and conf.CheckLib('pthread', 'pthread_create', autoadd = 0):
-                        env.AppendUnique(CCFLAGS = ' -pthread')
-                        env.AppendUnique(LINKFLAGS = ' -pthread')
-                    else:
-                        Exit(1)
 
             # GL and GLU
             if str(Platform()) == 'win32':
