from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
from setuptools import find_packages

import numpy

import os
MKLROOT = os.environ['MKLROOT']

setup(
    name='magpy',
    version='0.1dev',
    packages=find_packages(),
    ext_modules= cythonize(Extension(
        name='magpy.core',
        sources=["magpy/core.pyx"],
        language='c++',
        extra_compile_args=[
            "-std=c++11", '-pthread', '-O3','-fopenmp', '-simd', '-qopenmp', '-xHost',
            '-DUSEMKL', '-DMKL_ILP64', '-I{}/include'.format(MKLROOT)],
        extra_link_args=[
            '-std=c++11', '-pthread', '-fopenmp', '-qopenmp',
            '-Wl,--start-group', '{}/lib/intel64/libmkl_intel_ilp64.a'.format(MKLROOT),
            '{}/lib/intel64/libmkl_sequential.a'.format(MKLROOT),
            '{}/lib/intel64/libmkl_core.a'.format(MKLROOT), '-Wl,--end-group',
            '-lpthread', '-lm', '-ldl'],
        libraries=['moma', 'm', 'dl', 'pthread'],
        library_dirs=['.', '{}/lib/intel64'.format(MKLROOT)],
        include_dirs=[numpy.get_include(), './include']
    ))
)

@@ -178,16 +178,30 @@
 packages
+%0Aimport shutil
 %0A%0Aimport
@@ -222,256 +222,168 @@
  os%0A
-MKLROOT = os.environ%5B'MKLROOT'%5D%0A%0Asetup(%0A    name='magpy',%0A    version='0.1dev',%0A    packages=find_packages(),%0A    ext_modules= cythonize(Extension(%0A        name='magpy.core',%0A        sources=%5B%22magpy/core.pyx%22%5D,%0A        language='c++',%0A        extra
+%0A# Check compiler%0ACXX = os.environ%5B'CXX'%5D%0A%0A# INTEL ARGUMENTS%0AUSE_INTEL = CXX=='icpc'%0AMKLROOT = os.environ%5B'MKLROOT'%5D if 'MKLROOT' in os.environ else False%0Aintel
 _com
@@ -387,35 +387,29 @@
 compile_args
-=
+ = 
 %5B%0A
-        
     %22-std=c+
@@ -475,24 +475,16 @@
 xHost',%0A
-        
     '-DU
@@ -540,45 +540,31 @@
 OOT)
-%5D,%0A        extra_link_args=%5B%0A        
+%0A%5D%0Aintel_link_args = %5B%0A
     
@@ -609,32 +609,24 @@
 '-qopenmp',%0A
-        
     '-Wl,--s
@@ -689,32 +689,24 @@
 t(MKLROOT),%0A
-        
     '%7B%7D/lib/
@@ -751,24 +751,16 @@
 LROOT),%0A
-        
     '%7B%7D/
@@ -830,19 +830,135 @@
     
-       
+'-lpthread', '-lm', '-ldl'%0A%5D%0Aintel_libs = %5B'moma', 'm', 'dl', 'pthread'%5D%0A%0A%0A# GNU ARGUMENTS%0Agnu_compile_args = %5B%22-std=c++11%22,
  '-
-l
 pthr
@@ -969,70 +969,574 @@
 , '-
-lm
+O3
 ', '-
-ldl'%5D,%0A        libraries=%5B'moma', 'm', 'dl', 'pthread'%5D
+fopenmp'%5D%0Agnu_link_args = %5B%0A    '-std=c++11', '-pthread', '-fopenmp', '-llapacke', '-lblas'%0A%5D%0Agnu_libs = %5B'moma', 'pthread', 'lapacke', 'blas'%5D%0A%0Asetup(%0A    name='magpy',%0A    version='0.1dev',%0A    packages=find_packages(),%0A    ext_modules= cythonize(Extension(%0A        name='magpy.core',%0A        sources=%5B%22magpy/core.pyx%22%5D,%0A        language='c++',%0A        extra_compile_args= intel_compile_args if USE_INTEL else gnu_compile_args,%0A        extra_link_args= intel_link_args if USE_INTEL else gnu_link_args,%0A        libraries=intel_libs if USE_INTEL else gnu_libs
 ,%0A  

add gcc build for magpy package