#!/bin/bash

if [[ (`uname` == Darwin) && ($NOMKL == 0) ]]; then
    export ATLAS=1
    export LDFLAGS="-headerpad_max_install_names $LDFLAGS"
fi

if [ `uname` == Darwin ]; then
    WHEELS_BUILD_ARGS=""
    export MACOSX_DEPLOYMENT_TARGET=10.10
#    export CPPFLAGS="$CPPFLAGS -Xpreprocessor -qopenmp"
#    export CPPFLAGS="$CPPFLAGS -I$PREFIX/include -qopenmp"
#    export CFLAGS="$CFLAGS -I$PREFIX/include -qopenmp"
#    export CXXFLAGS="$CXXFLAGS -I$PREFIX/include -qopenmp"
#    export LDFLAGS="$LDFLAGS -qopenmp"
    export LDFLAGS="$LDFLAGS -L$PREFIX/lib -Wl,-rpath,$PREFIX/lib -liomp5"
else
    WHEELS_BUILD_ARGS="-p manylinux1_x86_64"
fi

export CC=icc
export CXX=icc

$PYTHON setup.py config_cc --compiler=intelem install

rm -rf $SP_DIR/scikits

# Build wheel package
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
    $PYTHON setup.py config_cc --compiler=intelem bdist_wheel ${WHEELS_BUILD_ARGS}
    cp dist/scikit_learn*.whl ${WHEELS_OUTPUT_FOLDER}
fi
