if %PY_VER%==2.7 (
    set VS=vs2008
    set ICC_COMP_BAT="C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\compilervars_arch.bat"
) else (
    set VS=vs2015
    set ICC_COMP_BAT="C:\Program Files (x86)\IntelSWTools\parallel_studio_xe_2016.3.059\compilers_and_libraries_2016\windows\bin\compilervars_arch.bat"
)

call %ICC_COMP_BAT% intel64 %VS%
if errorlevel 1 exit 1
set CC=icl
set LD=xilink

echo # >> numpy\__init__.py
echo __mkl_version__ = '__MKL_VERSION__' >> numpy\__init__.py
if errorlevel 1 exit 1
%SCRIPTS%\mkl-version.exe numpy\__init__.py
if errorlevel 1 exit 1

copy %PREFIX%\cio_files\numpy\site-mkl-%SUBDIR%.cfg site.cfg
if errorlevel 1 exit 1

@rem FIXME: SAT-1495 (do not use mkl_rt until MKL and TBB work together on Windows)
sed -i 's,libs =.*,libs = mkl_rt,g' site.cfg
@rem sed -i 's#libs =.*#libs = mkl_intel_lp64_dll, mkl_intel_thread_dll, mkl_core_dll, libiomp5md#g' site.cfg
if errorlevel 1 exit 1

%SCRIPTS%\replace.exe @PREFIX@ %PREFIX% site.cfg
if errorlevel 1 exit 1

%PYTHON% setup.py build --force --compiler=intelemw
%PYTHON% setup.py install --old-and-unmanageable
if errorlevel 1 exit 1
