#!/bin/bash

export HARK_BOARD_HOME="${HOME}/HARK-Board"
export RELOCATED_HOST_DIR="${HARK_BOARD_HOME}/buildroot/output/host"

export C_INCLUDE_PATH="${RELOCATED_HOST_DIR}/usr/include"
export LIBRARY_PATH="${RELOCATED_HOST_DIR}/usr/lib"
#export LD_LIBRARY_PATH="${LIBRARY_PATH}"
export PATH="${RELOCATED_HOST_DIR}/usr/bin:${PATH}"

# for support cmake toolchain (for libharkio3)
export CMAKE_TOOLCHAIN_FILE="${RELOCATED_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake"

export ARCH="arm"
export INSTALL_MOD_PATH="${HARK_BOARD_HOME}/buildroot/output/target"

PKG_CONFIG_SYSROOT_DIR=`cat ${CMAKE_TOOLCHAIN_FILE} | grep "PKG_CONFIG_SYSROOT_DIR" | awk '{print $2}' | sed "s/[()]//g"`
export PKG_CONFIG_SYSROOT_DIR=`eval echo $"${PKG_CONFIG_SYSROOT_DIR}"`
export PKG_CONFIG="${RELOCATED_HOST_DIR}/usr/bin/pkg-config"
#export PKG_CONFIG_PATH="${PKG_CONFIG_SYSROOT_DIR}/usr/lib/pkgconfig"

# for autoswitch toolchain (hard <=> softfp)
#export CROSS_COMPILE="arm-buildroot-linux-uclibcgnueabi-"
#export CROSS_COMPILE="arm-buildroot-linux-uclibcgnueabihf-"
export TARGET=`cat ${CMAKE_TOOLCHAIN_FILE} | grep "PKG_CONFIG_SYSROOT_DIR" | awk '{print $2}' | sed "s/[()]//g" | sed -E "s/^.+\\/usr\\///g" | sed -E "s/\\/sysroot.+$//g"`
export CROSS_COMPILE="${TARGET}-"

export AR="${CROSS_COMPILE}ar"
export AS="${CROSS_COMPILE}as"
export RANLIB="${CROSS_COMPILE}ranlib"
export STRIP="${CROSS_COMPILE}strip"
export LD="${CROSS_COMPILE}ld"
export CXX="${CROSS_COMPILE}g++"
export CPP="${CROSS_COMPILE}cpp"
export CC="${CROSS_COMPILE}gcc"

export OBJCOPY="${CROSS_COMPILE}objcopy"
export OBJDUMP="${CROSS_COMPILE}objdump"
export NM="${CROSS_COMPILE}nm"

# for lapack (for next gen. libharkio3 implementation)
export GFORTRAN="${CROSS_COMPILE}gfortran"

