Index: sansmodels/setup.py
===================================================================
--- sansmodels/setup.py	(revision b57e7046296211b2884cffb2d813689ca18eeaab)
+++ sansmodels/setup.py	(revision 13f00a0962afba159513d062e81b6e565199dfcb)
@@ -11,5 +11,31 @@
 # Then build and install the modules
 from distutils.core import Extension, setup
-#from setuptools import setup#, find_packages
+from distutils.command.build_ext import build_ext
+
+# Options to enable OpenMP
+copt =  {'msvc': ['/openmp'],
+         'mingw32' : ['-fopenmp'],
+         'unix' : ['-fopenmp']}
+lopt =  {'msvc': ['/MANIFEST'],
+         'mingw32' : ['-fopenmp'],
+         'unix' : ['-lgomp']}
+
+class build_ext_subclass( build_ext ):
+    def build_extensions(self):
+        # Get 64-bitness
+        is_64bits = sys.maxsize > 2**32
+        
+        c = self.compiler.compiler_type
+        print "Compiling with %s (64bit=%s)" % (c, str(is_64bits))
+        
+        if not (sys.platform=='darwin' and not is_64bits):
+            if copt.has_key(c):
+               for e in self.extensions:
+                   e.extra_compile_args = copt[ c ]
+            if lopt.has_key(c):
+                for e in self.extensions:
+                    e.extra_link_args = lopt[ c ]
+                    
+        build_ext.build_extensions(self)
 
 # Build the module name
@@ -70,14 +96,4 @@
     smearer_sources.append(os.path.join(igordir, "winFuncs.c"))
 
-# Enable OpenMP
-extra_compile_args = []
-extra_link_args = []
-if sys.platform=='linux2' or (sys.platform=='darwin' and platform.architecture()[0]=='64bit'):
-    extra_compile_args = ['-fopenmp']
-    extra_link_args = ['-lgomp']
-elif sys.platform=='win32':
-    extra_compile_args = ['/openmp']    
-    extra_link_args = ['/MANIFEST']
-
 dist = setup(
     name="sansmodels",
@@ -103,6 +119,4 @@
                               sources=model_sources,                 
                               include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path],   
-                              extra_compile_args=extra_compile_args,
-                              extra_link_args=extra_link_args
                               ),
     
@@ -110,5 +124,7 @@
         Extension("sans.models.sans_extension.smearer",
                    sources = smearer_sources,
-                   include_dirs=[igordir, smear_dir, numpy_incl_path]),
+                   include_dirs=[igordir, smear_dir, numpy_incl_path],
+                   ),
+                   
         Extension("sans.models.sans_extension.smearer2d_helper",
                   sources = [os.path.join(smear_dir, 
@@ -116,8 +132,7 @@
                              os.path.join(smear_dir, "smearer2d_helper.cpp"),],
                   include_dirs=[smear_dir,numpy_incl_path],
-                  extra_compile_args=extra_compile_args,
-                  extra_link_args=extra_link_args
-        )
-        ]
+                  )
+        ],
+    cmdclass = {'build_ext': build_ext_subclass }
     )
         
Index: setup.py
===================================================================
--- setup.py	(revision 01de55725029ac80a2759861556feb9b577973f2)
+++ setup.py	(revision 13f00a0962afba159513d062e81b6e565199dfcb)
@@ -24,14 +24,30 @@
 ext_modules = []
 
-# TODO check for sans/__init__.py
-
-# Enable OpenMP
-extra_compile_args = []
-extra_link_args = []
-if sys.platform=='linux2' or (sys.platform=='darwin' and platform.architecture()[0]=='64bit'):
-    extra_compile_args = ['-fopenmp']
-    extra_link_args = ['-lgomp']
-elif os.name=='nt':
-    extra_compile_args = ['/openmp']
+# Options to enable OpenMP
+copt =  {'msvc': ['/openmp'],
+         'mingw32' : ['-fopenmp'],
+         'unix' : ['-fopenmp']}
+lopt =  {'msvc': ['/MANIFEST'],
+         'mingw32' : ['-fopenmp'],
+         'unix' : ['-lgomp']}
+
+class build_ext_subclass( build_ext ):
+    def build_extensions(self):
+        # Get 64-bitness
+        is_64bits = sys.maxsize > 2**32
+        
+        c = self.compiler.compiler_type
+        print "Compiling with %s (64bit=%s)" % (c, str(is_64bits))
+        
+        if not (sys.platform=='darwin' and not is_64bits):
+            if copt.has_key(c):
+               for e in self.extensions:
+                   e.extra_compile_args = copt[ c ]
+            if lopt.has_key(c):
+                for e in self.extensions:
+                    e.extra_link_args = lopt[ c ]
+                    
+        build_ext.build_extensions(self)
+
 
 # sans.invariant
@@ -75,6 +91,4 @@
                                          ],
                               include_dirs=[numpy_incl_path],
-                              extra_compile_args=extra_compile_args,
-                              extra_link_args=extra_link_args                              
                               ) )
         
@@ -126,6 +140,4 @@
                                          os.path.join("park-1.2.1", "park", "lib", "resolution.c"),
                                          ],
-                              extra_compile_args=extra_compile_args,
-                              extra_link_args=extra_link_args
                               ) )
 
@@ -198,6 +210,4 @@
                                 sources=model_sources,                 
                                 include_dirs=[igordir, srcdir, c_model_dir, numpy_incl_path],
-                                extra_compile_args=extra_compile_args,
-                                extra_link_args=extra_link_args
                                 ),       
                     # Smearer extension
@@ -205,6 +215,4 @@
                               sources = smearer_sources,
                               include_dirs=[igordir, smear_dir, numpy_incl_path],
-                              extra_compile_args=extra_compile_args,
-                              extra_link_args=extra_link_args
                               ),
                     
@@ -214,6 +222,4 @@
                                          os.path.join(smear_dir, "smearer2d_helper.cpp"),],
                               include_dirs=[smear_dir,numpy_incl_path],
-                              extra_compile_args=extra_compile_args,
-                              extra_link_args=extra_link_args
                               )
                     ] )
@@ -255,4 +261,5 @@
                                        "sansview = sans.sansview.sansview:run",
                                        ]
-                    }
+                    },
+    cmdclass = {'build_ext': build_ext_subclass }
     )   
