diff --git a/SConstruct b/SConstruct
index 34ef935..ff0e5f8 100644
--- a/SConstruct
+++ b/SConstruct
@@ -7,6 +7,12 @@ python = 'python%d.%d' % (sys.version_info[0], sys.version_info[1])
 print 'Building for', python
 
 try: 
+    Glob
+except:
+    # compatibility with SCons version 0.97
+    from glob import glob as Glob
+
+try: 
     import numpy
 except ImportError:
     print 'You need to have numpy installed.'
@@ -21,11 +27,15 @@ SConsignFile() # no .scsonsign into $PREFIX please
 #else:
 
 opts = Variables()
-opts.Add(PathVariable('prefix', 'autotools-style installation prefix', '/usr/local', validator=PathVariable.PathIsDirCreate))
+if sys.platform == "darwin":
+    opts.Add(PathVariable('prefix', 'autotools-style installation prefix', '/opt/local/', validator=PathVariable.PathIsDirCreate))
+else:
+    opts.Add(PathVariable('prefix', 'autotools-style installation prefix', '/usr/local', validator=PathVariable.PathIsDirCreate))
+
 opts.Add(BoolVariable('debug', 'enable HEAVY_DEBUG and disable optimizations', False))
 env = Environment(ENV=os.environ, options=opts)
 if sys.platform == "win32":
-    env = Environment(tools=['mingw'], ENV=os.environ, options=opts)
+    env.Prepend(tools=['mingw'])
 opts.Update(env)
 
 env.ParseConfig('pkg-config --cflags --libs glib-2.0')
@@ -40,13 +50,17 @@ env.Append(CPPPATH=numpy_path)
 if sys.platform == "win32":
     env.ParseConfig('pkg-config --cflags --libs python25') # These two '.pc' files you probably have to make for yourself.
     env.ParseConfig('pkg-config --cflags --libs numpy')    # Place them among the other '.pc' files ( where the 'glib-2.0.pc' is located .. probably )
+elif sys.platform == "darwin":
+        env.ParseConfig('python-config --cflags')
+        env.ParseConfig('python-config --ldflags')
 else:
     # some distros use python2.5-config, others python-config2.5
     try:
         env.ParseConfig(python + '-config --cflags --ldflags')
     except OSError:
         print 'going to try python-config instead'
-        env.ParseConfig('python-config --cflags --ldflags')
+        env.ParseConfig('python-config --ldflags')
+        env.ParseConfig('python-config --cflags')
 
 if env.get('CPPDEFINES'):
     # make sure assertions are enabled
@@ -80,10 +94,6 @@ def burn_python_version(target, source, env):
 
 env.Command('mypaint', 'mypaint.py', [burn_python_version, Chmod('$TARGET', 0755)])
 
-env.Clean('.', Glob('*.pyc'))
-env.Clean('.', Glob('gui/*.pyc'))
-env.Clean('.', Glob('lib/*.pyc'))
-
 env.Alias('install', env['prefix'])
 def install(dst, pattern):
     env.Install(join(env['prefix'], dst), Glob(pattern))
diff --git a/lib/SConscript b/lib/SConscript
index ae04cf3..771106b 100644
--- a/lib/SConscript
+++ b/lib/SConscript
@@ -5,8 +5,7 @@ import sys
 # 
 # I have given up. Scons just can't get the dependencies right with those
 # code generators. Let's give scons a "normal" c++ project to dependency-scan.
-if env.Execute('swig -o mypaintlib_wrap.cpp -noproxydel -python -c++ mypaintlib.i'):
-    Exit(1)
+env.Execute('swig -o mypaintlib_wrap.cpp -python -c++ mypaintlib.i')
 env.Clean('.', 'mypaintlib_wrap.cpp')
 env.Clean('.', 'mypaintlib.py')
 
@@ -14,6 +13,8 @@ env.Clean('.', 'mypaintlib.py')
 src = 'mypaintlib_wrap.cpp'
 if sys.platform == "win32": # there 's a better way to do this 
     module = env.LoadableModule('_mypaintlib', Split(src), SHLIBPREFIX="", SHLIBSUFFIX=".pyd")
+elif sys.platform == "darwin":
+    module = env.LoadableModule('_mypaintlib', Split(src), SHLIBPREFIX="", SHLIBSUFFIX=".so")
 else:
     module = env.LoadableModule('_mypaintlib', Split(src), SHLIBPREFIX="")
 
