Only in .: build
Only in ./fract4d/c: fract4d_stdlib_exports.cpp
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/c/fract4dmodule.cpp ./fract4d/c/fract4dmodule.cpp
--- ../gnofract4d-3.12_orig/fract4d/c/fract4dmodule.cpp	2009-02-15 16:32:00.000000000 +0000
+++ ./fract4d/c/fract4dmodule.cpp	2010-06-09 14:48:54.000000000 +0100
@@ -26,13 +26,41 @@
 #include "fractFunc.h"
 #include "image.h"
 
+#ifdef MS_WINDOWS
+#define MAX_PATH 260
+#ifndef PATH_MAX
+#define PATH_MAX MAX_PATH
+#endif
+#include <direct.h>
+#ifdef _WIN32
+extern "C" {
+typedef __w64 unsigned int UINT_PTR;
+#else
+typedef unsigned __int64 UINT_PTR;
+#endif
+#define SOCKET UINT_PTR
+__declspec(dllimport) int __stdcall send(SOCKET, const char *, int, int);
+__declspec(dllimport) int __stdcall closesocket(SOCKET);
+#ifdef _WIN32
+}
+#endif
+int __send(SOCKET s, const void * b, int l, int f)
+{
+    return send(s, (const char *)b, l, f);
+}
+#endif
 
 /* not sure why this isn't defined already */
 #ifndef PyMODINIT_FUNC 
 #define PyMODINIT_FUNC void
 #endif
 
+#ifdef MS_WINDOWS
+// Windows uses .pyd, rather than .so..
+#define CMAP_NAME "/fract4d_stdlib.pyd"
+#else
 #define CMAP_NAME "/fract4d_stdlib.so"
+#endif
 
 #ifdef USE_GMP
 #define MODULE_NAME "fract4dcgmp"
@@ -851,8 +879,7 @@
 	{
 	    site = site_;
 
-	    has_pixel_changed_method = 
-		PyObject_HasAttrString(site,"pixel_changed");
+        has_pixel_changed_method = (PyObject_HasAttrString(site,"pixel_changed") != 0 ? true : false);
 
 #ifdef DEBUG_CREATION
 	    fprintf(stderr,"%p : SITE : CTOR\n",this);
@@ -1033,8 +1060,9 @@
     STATS,
 } msg_type_t;
     
-struct calc_args
+class calc_args
 {
+public:
     double params[N_PARAMS];
     int eaa, maxiter, nThreads;
     int auto_deepen, yflip, periodicity, dirty;
@@ -1115,9 +1143,15 @@
 class FDSite :public IFractalSite
 {
 public:
-    FDSite(int fd_) : fd(fd_), tid((pthread_t)0), 
-		      interrupted(false), params(NULL) 
-	{
+#ifndef MS_WINDOWS
+    FDSite(int fd_) : fd(fd_),
+    tid((pthread_t)0),
+#else
+    FDSite(int fd_) : fd((SOCKET)fd_),
+    tid(NULL),
+#endif
+              interrupted(false), params(NULL) 
+    {
 #ifdef DEBUG_CREATION
 	    fprintf(stderr,"%p : FD : CTOR\n",this);
 #endif
@@ -1127,9 +1161,15 @@
     inline void send(msg_type_t type, int size, void *buf)
 	{
 	    pthread_mutex_lock(&write_lock);
+#ifndef MS_WINDOWS
 	    if (write(fd,&type,sizeof(type))) {};
 	    if (write(fd,&size,sizeof(size))) {};
 	    if (write(fd,buf,size)) {};
+#else
+	    if (__send(fd, &type, sizeof(type), 0)) {};
+	    if (__send(fd, &size, sizeof(size), 0)) {};
+	    if (__send(fd, buf, size, 0)) {};
+#endif
 	    pthread_mutex_unlock(&write_lock);
 	}
     virtual void iters_changed(int numiters)
@@ -1219,8 +1259,12 @@
 #ifdef DEBUG_THREADS
 	    fprintf(stderr,"%p : CA : SET(%p)\n", this,tid_);
 #endif
+#ifndef MS_WINDOWS
 	    tid = tid_;
-	}
+#else
+	    tid = &tid_;
+#endif
+    }
 
     virtual void wait()
 	{
@@ -1229,7 +1273,11 @@
 #ifdef DEBUG_THREADS
 		fprintf(stderr,"%p : CA : WAIT(%p)\n", this,tid);
 #endif
+#ifndef MS_WINDOWS
 		pthread_join(tid,NULL);
+#else
+		pthread_join(*tid, NULL);
+#endif
 	    }
 	}
     ~FDSite()
@@ -1237,11 +1285,20 @@
 #ifdef DEBUG_CREATION
 	    fprintf(stderr,"%p : FD : DTOR\n",this);
 #endif
+#ifndef MS_WINDOWS
 	    close(fd);
+#else
+	    closesocket(fd);
+#endif
 	}
 private:
+#ifndef MS_WINDOWS
     int fd;
     pthread_t tid;
+#else
+    SOCKET fd;
+    pthread_t *tid;
+#endif
     volatile bool interrupted;
     calc_args *params;
     pthread_mutex_t write_lock;
@@ -2506,6 +2563,12 @@
     return pyRet;
 }
 
+#ifdef MS_WINDOWS
+extern PyObject *PyPipe(PyObject *self, PyObject *);
+extern PyObject *Py_io_add_watch(PyObject *self, PyObject *args);
+extern PyObject *PyRead(PyObject *self, PyObject *args);
+#endif
+
 static PyMethodDef PfMethods[] = {
     {"pf_load",  pf_load, METH_VARARGS, 
      "Load a new point function shared library"},
@@ -2618,6 +2681,15 @@
 
     { "array_set_int", pyarray_set, METH_VARARGS,
       "Set an element in an array allocated in an arena" },
+
+#ifdef MS_WINDOWS
+    { "pipe", PyPipe, METH_NOARGS,
+      "Gets a Windows pipe using the fract4dc CRT" },
+    { "io_add_watch", Py_io_add_watch, METH_VARARGS,
+      "Adds an io watch onto a specific file descriptor (as per GLib)" },
+    { "read", PyRead, METH_VARARGS,
+      "replaces os.read for file descriptors returned from fract4dc.pipe()" },
+#endif
     
     {NULL, NULL, 0, NULL}        /* Sentinel */
 };
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/c/fractFunc.cpp ./fract4d/c/fractFunc.cpp
--- ../gnofract4d-3.12_orig/fract4d/c/fractFunc.cpp	2009-04-25 18:53:12.000000000 +0100
+++ ./fract4d/c/fractFunc.cpp	2009-12-13 14:02:18.000000000 +0000
@@ -2,7 +2,23 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#ifndef WIN32
 #include <sys/time.h>
+#else
+struct timeval {
+        long    tv_sec;         /* seconds */
+        long    tv_usec;        /* and microseconds */
+};
+#include <sys/timeb.h>
+int gettimeofday (struct timeval *t, void *foo)
+{
+	struct _timeb temp;
+	_ftime(&temp);
+	t->tv_sec = (long)temp.time;
+	t->tv_usec = temp.millitm * 1000;
+	return (0);
+}
+#endif
 
 dmat4
 rotated_matrix(double *params)
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/c/image.cpp ./fract4d/c/image.cpp
--- ../gnofract4d-3.12_orig/fract4d/c/image.cpp	2007-09-08 19:03:12.000000000 +0100
+++ ./fract4d/c/image.cpp	2009-12-13 14:07:20.000000000 +0000
@@ -10,6 +10,11 @@
 #define GREEN 1
 #define BLUE 2
 
+#ifdef WIN32
+#include <float.h>
+#define finite _finite
+#endif
+
 const int 
 image::N_SUBPIXELS = 4;
 
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/c/MTFractWorker.cpp ./fract4d/c/MTFractWorker.cpp
--- ../gnofract4d-3.12_orig/fract4d/c/MTFractWorker.cpp	2009-02-21 19:16:18.000000000 +0000
+++ ./fract4d/c/MTFractWorker.cpp	2009-12-13 14:03:20.000000000 +0000
@@ -1,7 +1,9 @@
 #include "fractWorker.h" 
 #include "fractFunc.h"
 
+#ifndef WIN32
 #include "unistd.h"
+#endif
 
 /* redirect back to a member function */
 void worker(job_info_t& tdata, STFractWorker *pFunc)
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/c/pointFunc.cpp ./fract4d/c/pointFunc.cpp
--- ../gnofract4d-3.12_orig/fract4d/c/pointFunc.cpp	2009-03-01 00:31:48.000000000 +0000
+++ ./fract4d/c/pointFunc.cpp	2009-12-13 13:41:44.000000000 +0000
@@ -9,7 +9,9 @@
 #include "pointFunc_public.h"
 #include "fract_public.h"
 
+#ifndef WIN32
 #include <unistd.h>
+#endif
 #include <dlfcn.h>
 #include <stdio.h>
 
Only in ./fract4d/c: win32func.cpp
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/cache.py ./fract4d/cache.py
--- ../gnofract4d-3.12_orig/fract4d/cache.py	2009-03-08 04:19:24.000000000 +0000
+++ ./fract4d/cache.py	2009-12-18 19:59:02.000000000 +0000
@@ -34,7 +34,10 @@
     
     def clear(self):
         for f in os.listdir(self.dir):
-            os.remove(os.path.join(self.dir,f))
+            try:
+                os.remove(os.path.join(self.dir,f))
+            except:
+                pass
 
     def makefilename(self,name,ext):
         return os.path.join(self.dir, "fract4d_%s%s" % (name, ext))
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/codegen.py ./fract4d/codegen.py
--- ../gnofract4d-3.12_orig/fract4d/codegen.py	2009-02-15 05:41:20.000000000 +0000
+++ ./fract4d/codegen.py	2009-12-15 19:37:10.000000000 +0000
@@ -76,6 +76,10 @@
     %(struct_members)s
 } pf_real ;
 
+#ifdef WIN32
+#pragma comment(linker, "/EXPORT:_pf_new")
+#endif
+
 static void pf_init(
     struct s_pf_data *p_stub,
     double *pos_params,
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/fc.py ./fract4d/fc.py
--- ../gnofract4d-3.12_orig/fract4d/fc.py	2009-04-27 04:54:42.000000000 +0100
+++ ./fract4d/fc.py	2010-06-05 11:47:42.000000000 +0100
@@ -28,6 +28,10 @@
 import os.path
 import stat
 import random
+#try:
+#    from hashlib import md5
+#except:
+#    import md5
 import md5
 import re
 import copy
@@ -146,9 +150,16 @@
         self.cache = cache.T()
         self.cache_dir = os.path.expanduser("~/.gnofract4d-cache/")
         self.init_cache()
-        self.compiler_name = "gcc"
-        self.flags = "-fPIC -DPIC -g -O3 -shared"
-        self.libs = "-lm"
+        if 'win' != sys.platform[:3]:
+            self.compiler_name = "gcc"
+            self.flags = "-fPIC -DPIC -g -O3 -shared"
+            self.output_flag = "-o "
+            self.libs = "-lm"
+        else:
+            self.compiler_name = "cl"
+            self.flags = "/EHsc /Gd /nologo /W3 /LD /MT /TP /DWIN32 /DWINDOWS /D_USE_MATH_DEFINES"
+            self.output_flag = "/Fe"
+            self.libs = "/link /LIBPATH:\"%s/fract4d\" fract4d_stdlib.lib" % sys.path[0] # /DELAYLOAD:fract4d_stdlib.pyd DelayImp.lib
         self.tree_cache = {}
         self.leave_dirty = False
         self.next_inline_number = 0
@@ -400,15 +411,20 @@
             if os.path.exists(outputfile):
                 # skip compilation - we already have this code
                 return outputfile
-        
+
         if cfile == None:
             cfile = self.cache.makefilename(hash,".c")
-            
+            if 'win' == sys.platform[:3]:
+                objfile = self.cache.makefilename(hash, ".obj")
+
         open(cfile,"w").write(self.c_code)
 
         # -march=i686 for 10% speed gain
-        cmd = "%s %s %s -o %s %s" % \
-              (self.compiler_name, cfile, self.flags, outputfile, self.libs)
+        cmd = "%s \"%s\" %s %s\"%s\"" % \
+              (self.compiler_name, cfile, self.flags, self.output_flag, outputfile)
+        if 'win' == sys.platform[:3]:
+            cmd += " /Fo\"%s\"" % objfile
+        cmd += " %s" % self.libs
         #print "cmd: %s" % cmd
 
         (status,output) = commands.getstatusoutput(cmd)
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/fractal.py ./fract4d/fractal.py
--- ../gnofract4d-3.12_orig/fract4d/fractal.py	2009-04-27 04:52:08.000000000 +0100
+++ ./fract4d/fractal.py	2010-06-09 15:57:38.000000000 +0100
@@ -268,9 +268,11 @@
             params.dict["function"],
             which_transform)
         self.transforms[which_transform].load_param_bag(params)
-        
+
     def __del__(self):
-        pass #print "deleting fractal %s" % self
+        #print "deleting fractal %s" % self
+        del self.pfunc
+        del self.handle
 
     def __copy__(self):
         # override shallow-copy to do a deeper copy than normal,
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4d/fractconfig.py ./fract4d/fractconfig.py
--- ../gnofract4d-3.12_orig/fract4d/fractconfig.py	2009-05-18 00:15:54.000000000 +0100
+++ ./fract4d/fractconfig.py	2010-06-05 11:50:46.000000000 +0100
@@ -7,9 +7,13 @@
     def __init__(self, file):
         _shared_formula_dir = self.get_data_path("formulas")
         _shared_map_dir = self.get_data_path("maps")
+        if 'win' == sys.platform[:3]:
+            comp = 'cl'
+        else:
+            comp = 'gcc'
         _defaults = {
             "compiler" : {
-              "name" : "gcc",
+              "name" : comp,
               "options" : self.get_default_compiler_options()
             },
             "optimize" : {
@@ -133,7 +137,10 @@
 
     def get_default_compiler_options(self):
         # appears to work for most unixes
-        return "-fPIC -DPIC -D_REENTRANT -O2 -shared -ffast-math"
+		if 'win' == sys.platform[:3]:
+			return "/EHsc /Gd /nologo /W3 /LD /MT /TP /DWIN32 /DWINDOWS /D_USE_MATH_DEFINES"
+		else:
+			return "-fPIC -DPIC -D_REENTRANT -O2 -shared -ffast-math"
         
     def set(self,section,key,val):
         if self.has_section(section) and \
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4dgui/gtkfractal.py ./fract4dgui/gtkfractal.py
--- ../gnofract4d-3.12_orig/fract4dgui/gtkfractal.py	2009-03-15 05:01:58.000000000 +0000
+++ ./fract4dgui/gtkfractal.py	2010-06-09 16:00:00.000000000 +0100
@@ -15,6 +15,7 @@
 from fract4d import fractal,fract4dc,fracttypes, image, messages
 
 import utils, fourway
+from gtkio import gtkio
 
 class Hidden(gobject.GObject):
     """This class implements a fractal which calculates asynchronously
@@ -51,8 +52,9 @@
     def __init__(self,comp,width,height,total_width=-1,total_height=-1):
         gobject.GObject.__init__(self)
 
-        (self.readfd,self.writefd) = os.pipe()
-        self.nthreads = 1        
+        self.io_subsys = gtkio();
+        (self.readfd, self.writefd) = self.io_subsys.pipe();
+        self.nthreads = 1
 
         self.compiler = comp
 
@@ -80,11 +82,12 @@
         f = fractal.T(self.compiler,self.site)
         self.set_fractal(f)
         self.f.compile()
-            
+
     def set_fractal(self,f):
         if f != self.f:
             if self.f:
                 self.interrupt()
+                del self.f
             self.f = f
 
             # take over fractal's changed function
@@ -162,15 +165,15 @@
         self.f.set_formula(fname, formula,index)
 
     def onData(self,fd,condition):
-        self.msgbuf = self.msgbuf + os.read(fd, 8 - len(self.msgbuf))
-        
+        self.msgbuf = self.msgbuf + self.io_subsys.read(fd, 8 - len(self.msgbuf))
+
         if len(self.msgbuf) < 8:            
             #print "incomplete message: %s" % list(self.msgbuf)
             return True
 
         (t,size) = struct.unpack("2i",self.msgbuf)
         self.msgbuf = ""
-        bytes = os.read(fd,size)
+        bytes = self.io_subsys.read(fd,size)
         if len(bytes) < size:
             print "not enough bytes, got %d instead of %d" % (len(bytes),size)
             return True
@@ -205,6 +208,7 @@
         elif t == fract4dc.MESSAGE_TYPE_STATS:
             if not self.skip_updates: self.stats_changed(m)
         else:
+            print "Data incomprehandable, Threads out of sync? Expect a crash to occur."
             print "Unknown message from fractal thread; %s" % list(bytes)
 
         if utils.threads_enabled:
@@ -454,7 +458,7 @@
             )
 
         self.notice_mouse = False
-        
+
         drawing_area.connect('motion_notify_event', self.onMotionNotify)
         drawing_area.connect('button_release_event', self.onButtonRelease)
         drawing_area.connect('button_press_event', self.onButtonPress)
@@ -470,6 +474,15 @@
     def image_changed(self,x1,y1,x2,y2):
         self.redraw_rect(x1,y1,x2-x1,y2-y1)
 
+#    def changed(self):
+#        Hidden.changed(self)
+#        try:
+#            widget = self.widget
+#        except Exception, e:
+#            return
+#        self.widget.queue_draw_area(0, 0, self.width, self.height)
+#        #self.expose()
+
     def make_numeric_entry(self, form, param, order):
         param_type = form.paramtypes[order]
 
Only in ./fract4dgui: gtkio.py
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4dgui/main_window.py ./fract4dgui/main_window.py
--- ../gnofract4d-3.12_orig/fract4dgui/main_window.py	2009-04-19 23:10:06.000000000 +0100
+++ ./fract4dgui/main_window.py	2010-06-09 16:02:50.000000000 +0100
@@ -113,7 +113,7 @@
         
         self.statuses = [ _("Done"),
                           _("Calculating"),
-                          _("Deepening (%d iterations)"),
+                          _("Deepening ({0} iterations)"),
                           _("Antialiasing"),
                           _("Paused"),
                           _("Reducing Periodicity Tolerance")]
@@ -507,7 +507,7 @@
     def status_changed(self,f,status):
         if status == 2:
             # deepening
-            text = self.statuses[status] % self.f.maxiter
+            text = self.statuses[status].format(self.f.maxiter)
         elif status == 0:
             # done
             text = self.statuses[status] 
@@ -1289,16 +1289,16 @@
         """Reset rotation to show the YZ (Elliptic) plane."""
         # left = +z, down = +y
         self.f.set_plane(self.f.XZANGLE, None)
-	    
+
     def set_wy_plane(self,*args):
         """Reset rotation to show the WY (Rectangular) plane."""
         # left =+w, down = +y
         self.f.set_plane(self.f.XWANGLE, None)
-	
+
     def autozoom(self,*args):
         """Display AutoZoom dialog."""
         autozoom.show_autozoom(self.window, self.f)
-        
+
     def contents(self,*args):
         """Show help file contents page."""
         self.display_help()
@@ -1443,15 +1443,21 @@
         
         try:
             preferences.userPrefs.save()
+            del self.f
+            for f in self.subfracts:
+                del f
             self.compiler.clear_cache()
         finally:
             gtk.main_quit()
+            if 'win' == sys.platform[:3]:
+                exit(0);
+            return False
 
     def apply_options(self,opts):
         "Deal with opts gathered from cmd-line"
         width = opts.width or preferences.userPrefs.getint("display","width")
         height = opts.height or preferences.userPrefs.getint("display","height")
-        
+
         self.quit_when_done = opts.quit_when_done
         self.save_filename = opts.save_filename
         self.use_preview = opts.preview
@@ -1475,7 +1481,5 @@
 
         if opts.explore:
             self.set_explorer_state(True)
-        
-        self.f.set_size(width,height)
 
-    
+        self.f.set_size(width,height)
\ No newline at end of file
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fract4dgui/utils.py ./fract4dgui/utils.py
--- ../gnofract4d-3.12_orig/fract4dgui/utils.py	2008-06-29 23:25:00.000000000 +0100
+++ ./fract4dgui/utils.py	2010-06-07 22:47:18.000000000 +0100
@@ -14,6 +14,11 @@
 import gtk
 import gobject
 
+try:
+	from fract4d import fract4dcgmp as fract4dc
+except ImportError, err:
+    from fract4d import fract4dc
+
 threads_enabled = False
 break_new_things = False
 
@@ -59,15 +64,17 @@
     except AttributeError:
         gtk.timeout_add(time,callable)
 
-def input_add(fd,cb):
-    try:
-        _throwback()
-        return gobject.io_add_watch(
-            fd, gobject.IO_IN | gobject.IO_HUP, cb)
-    except AttributeError, err:
-        return gtk.input_add(fd, gtk.gdk.INPUT_READ, cb)
+if 'win' != sys.platform[:3]:
+    def input_add(fd,cb):
+        try:
+            _throwback()
+            return gobject.io_add_watch(fd, gobject.IO_IN | gobject.IO_HUP, cb)
+        except AttributeError, err:
+            return gtk.input_add(fd, gtk.gdk.INPUT_READ, cb)
+else:
+    def input_add(fd, cb):
+        return fract4dc.io_add_watch(fd, gobject.IO_IN | gobject.IO_HUP, cb)
 
-    
 def find_in_path(exe):
     # find an executable along PATH env var
     pathstring = os.environ["PATH"]
@@ -271,15 +278,15 @@
             self.widget.connect('clicked', self.run_colorsel)
 
     def on_color_set(self, widget):
-	self.color_changed(widget.get_color())
+        self.color_changed(widget.get_color())
 
     def set_color(self, rgb):
         self.color = create_color(rgb[0], rgb[1], rgb[2])
-	
-	try:
+    
+        try:
             _throwback()
             self.widget.set_color(self.color)
-	except:
+        except:
             #print "sc", self.area, rgb
             if self.area:
                 self.area_expose(
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/fractutils/slave.py ./fractutils/slave.py
--- ../gnofract4d-3.12_orig/fractutils/slave.py	2008-04-22 06:03:28.000000000 +0100
+++ ./fractutils/slave.py	2010-06-09 16:05:10.000000000 +0100
@@ -3,7 +3,11 @@
 import sys
 import os
 
-import fcntl
+if "win" not in sys.platform:
+    import fcntl
+else:
+    import win32api
+	# Work in this module is not complete, the following code does /NOT/ work on Windows.
 import signal
 import select
 import errno
diff -ur --exclude='*.pyd' --exclude='*.pyc' --exclude='*.lib' --exclude='*.diff' --exclude='*.cache' ../gnofract4d-3.12_orig/setup.py ./setup.py
--- ../gnofract4d-3.12_orig/setup.py	2009-05-18 00:27:18.000000000 +0100
+++ ./setup.py	2010-06-09 15:27:20.000000000 +0100
@@ -51,21 +51,64 @@
 
 extra_macros = []
 
-png_flags = call_package_config("libpng", "--cflags", True)
-if png_flags != []:
-    extra_macros.append(('PNG_ENABLED', 1))
-else:
-    print "NO PNG HEADERS FOUND"
-    
-png_libs = call_package_config("libpng", "--libs", True)
+if 'win' == sys.platform[:3]:
+    from win32api import GetLogicalDriveStrings
+    def scan_for_file(out, file, BaseDir = ""):
+        for drive in GetLogicalDriveStrings().split('\0'):
+            for (root, dirs, files) in os.walk(drive + BaseDir + '\\'):
+                if len(files) == 0:
+                    continue
+                if file in files:
+                    out += [ root + '\\' + file ]
+                    return out
+        print "FILE NOT FOUND"
+    cache_file = os.path.join(os.getcwd(), 'setup.cache')
+    if os.path.exists(cache_file) == False:
+        png_flags = scan_for_file([], 'png.h', 'Program Files')
+        if png_flags != []:
+            png_flags[0] = '/I' + png_flags[0] + ''
+        png_libs = scan_for_file([], 'libpng.lib', 'Program Files')
+        jpg_flags = scan_for_file([], 'jpeglib.h', 'Program Files')
+        jpg_libs = scan_for_file([], 'jpeg.lib', 'Program Files')
+        cache_file = open(cache_file, 'w')
+        cache_file.writelines(png_flags + '\n' + png_libs + '\n' + jpg_flags + '\n' + jpg_libs)
+        cache_file.close()
+    else:
+        cache_file = open(cache_file)
+        lines = cache_file.readlines()
+        png_flags = [ lines[0].strip() ]
+        png_libs = [ lines[1].strip() ]
+        jpg_flags = [ lines[2].strip() ]
+        jpg_libs = [ lines[3].strip() ]
+        cache_file.close()
+        del lines
+#        def scan_for_libjpeg_h(jpg_libs):
+#            for drive in GetLogicalDriveStrings().split('\0'):
+#                for (root, dirs, files) in os.walk(drive + 'Program Files\\'):
+#                    if len(files) == 0:
+#                        continue
+#                    if 'jpeglib.h' in files:
+#                        jpg_libs += [ root + '\\jpeglib.h' ]
+#                        return jpg_libs
+#            if jpg_libs == []:
+#                print "NO JPEG HEADERS FOUND"
 
-jpg_lib = "jpeg"
-if os.path.isfile("/usr/include/jpeglib.h"):
-    extra_macros.append(('JPG_ENABLED', 1))
-    jpg_libs = [ jpg_lib ]
 else:
-    print "NO JPEG HEADERS FOUND"
-    jpg_libs = []
+    png_flags = call_package_config("libpng", "--cflags", True)
+    if png_flags != []:
+        extra_macros.append(('PNG_ENABLED', 1))
+    else:
+        print "NO PNG HEADERS FOUND"
+        
+    png_libs = call_package_config("libpng", "--libs", True)
+
+    jpg_lib = "jpeg"
+    if os.path.isfile("/usr/include/jpeglib.h"):
+        extra_macros.append(('JPG_ENABLED', 1))
+        jpg_libs = [ jpg_lib ]
+    else:
+        print "NO JPEG HEADERS FOUND"
+        jpg_libs = []
 
 #not ready yet. 
 have_gmp = False # os.path.isfile("/usr/include/gmp.h")
@@ -136,22 +179,36 @@
     undef_macros = [ 'NDEBUG']    
     )
 
+if "win" == sys.platform[:3]:
+	warnings = '/W3'
+	libs = [ 'pthreadVC2', 'libdl', 'ws2_32' ]
+	osdep = [ '/DWIN32', '/DWINDOWS', '/D_USE_MATH_DEFINES', '/D_CRT_SECURE_NO_WARNINGS', '/EHsc', '/Ox' ]
+	osdep += [ '/I"F:/Gamma/GTK+/Win32/include/glib-2.0/"', '/I"F:/Gamma/GTK+/Win32/lib/glib-2.0/include/"' ]
+	extra_source = [ 'fract4d/c/win32func.cpp', 'fract4d/c/fract4d_stdlib_exports.cpp' ]
+	extra_link = [ '/LIBPATH:"F:/Gamma/GTK+/Win32/lib"' ]
+else:
+	warnings = '-Wall'
+	libs = [ 'stdc++' ]
+	osdep = []
+	extra_source = []
+	extra_link = []
+
+fract4d_sources += extra_source
+
 module_fract4dc = Extension(
     'fract4d.fract4dc',
     sources = fract4d_sources,
     include_dirs = [
     'fract4d/c'
     ],
-    libraries = [
-    'stdc++', 
-    ] + jpg_libs,
-    library_dirs=['/home/edwin/gnofract4d'],
+    libraries = libs + jpg_libs,
+    #library_dirs=['/home/edwin/gnofract4d'],
     extra_compile_args = [
-    '-Wall', 
-    ] + png_flags,
-    extra_link_args = png_libs,
+    warnings,
+    ] + osdep + png_flags,
+    extra_link_args = extra_link + png_libs,
     define_macros = defines + extra_macros,
-    undef_macros = [ 'NDEBUG'],
+    #undef_macros = [ 'NDEBUG'],
     )
 
 module_cmap = Extension(
@@ -160,13 +217,12 @@
     'fract4d/c/cmap.cpp',
     'fract4d/c/image.cpp',
     'fract4d/c/fract_stdlib.cpp'
-    ],
+    ] + extra_source,
     include_dirs = [
     'fract4d/c'
     ],
-    libraries = [
-    'stdc++'
-    ],
+    libraries = libs,
+    extra_link_args = extra_link,
     define_macros = [ ('_REENTRANT', 1)]
     )
 
@@ -258,6 +314,8 @@
     "fract4dcgmp" + so_extension : "fract4d",
     "gmpy" + so_extension: "fract4d"
     }
+if 'win' == sys.platform[:3]:
+    lib_targets["fract4d_stdlib.lib"] = "fract4d"
 
 def copy_libs(dummy,dirpath,namelist):
      for name in namelist:
@@ -267,4 +325,6 @@
              shutil.copy(name, target)
             
 os.path.walk("build",copy_libs,None)
+if 'win' == sys.platform[:3]:
+    shutil.copy("fract4d/fract4d_stdlib.pyd", "fract4d_stdlib.pyd")
 
