#!/bin/sh

if [ "$(uname)" == "Linux" ]; then
  CFLAGS="${CFLAGS} -I${CONDA_PREFIX}/include" LDFLAGS="-L${CONDA_PREFIX}/lib -lvl -Wl,-rpath=${CONDA_PREFIX}/lib "
else
  CFLAGS="${CFLAGS} -I${CONDA_PREFIX}/include" LDFLAGS="-L${CONDA_PREFIX}/lib -lvl "
fi

"$PYTHON" setup.py install --single-version-externally-managed --record=record.txt

if [ "$(uname -s)" == "Darwin" ]; then
  # For some reason Cython refuses to generate @rpath/vlfeat.dylib - so
  # we manually do it here
  find $SP_DIR/cyvlfeat -name "*.so" -print0 | while read -d $'\0' file
  do
    install_name_tool -change @loader_path/libvl.dylib @rpath/libvl.dylib $file
  done
fi
