standalone_sysroot_target="/srv/pokybuild/yocto-worker/qemuriscv64-tc/build/build-st-3042021/tmp/sysroots/qemuriscv64"
standalone_sysroot_native="/srv/pokybuild/yocto-worker/qemuriscv64-tc/build/build-st-3042021/tmp/sysroots/x86_64"
orig=$(pwd); cd /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/openembedded-core; set /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/build-st-3042021 /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/bitbake; . ./oe-init-build-env; cd $orig
export PATH=$standalone_sysroot_native//usr/bin:$standalone_sysroot_native//usr/bin/riscv64-poky-linux:$PATH
export PKG_CONFIG_SYSROOT_DIR=$standalone_sysroot_target
export PKG_CONFIG_PATH=$standalone_sysroot_target/usr/lib/pkgconfig:$standalone_sysroot_target/usr/share/pkgconfig
export CONFIG_SITE="/srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/openembedded-core/meta/site/endian-little /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/openembedded-core/meta/site/common-linux /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/openembedded-core/meta/site/common-glibc /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/openembedded-core/meta/site/riscv64-linux /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/openembedded-core/meta/site/riscv64-linux /srv/pokybuild/yocto-worker/qemuriscv64-tc/build/layers/openembedded-core/meta/site/common"
export SDKTARGETSYSROOT=$standalone_sysroot_target
export OECORE_NATIVE_SYSROOT=$standalone_sysroot_native
export OECORE_TARGET_SYSROOT=$standalone_sysroot_target
export OECORE_ACLOCAL_OPTS="-I $standalone_sysroot_native/usr/share/aclocal"
export OECORE_BASELIB="lib"
export OECORE_TARGET_ARCH="riscv64"
export OECORE_TARGET_OS="linux"
export OECORE_TARGET_BITS="64"
export OECORE_TARGET_ENDIAN="little"
export OECORE_MESON_HOST_SYSTEM="linux"
export OECORE_MESON_HOST_CPU_FAMILY="riscv64"
export OECORE_MESON_HOST_CPU="riscv64"
export OECORE_MESON_HOST_ENDIAN="little"
export OECORE_TARGET_SYS="riscv64-poky-linux"
export CC="riscv64-poky-linux-gcc -march=rv64imafdc_zicsr_zifencei -mabi=lp64d -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
export CXX="riscv64-poky-linux-g++ -march=rv64imafdc_zicsr_zifencei -mabi=lp64d -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
export CPP="riscv64-poky-linux-gcc -E -march=rv64imafdc_zicsr_zifencei -mabi=lp64d -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
export AS="riscv64-poky-linux-as "
export LD="riscv64-poky-linux-ld  --sysroot=$SDKTARGETSYSROOT"
export GDB=riscv64-poky-linux-gdb
export STRIP=riscv64-poky-linux-strip
export RANLIB=riscv64-poky-linux-ranlib
export OBJCOPY=riscv64-poky-linux-objcopy
export OBJDUMP=riscv64-poky-linux-objdump
export READELF=riscv64-poky-linux-readelf
export AR=riscv64-poky-linux-ar
export NM=riscv64-poky-linux-nm
export M4=m4
export TARGET_PREFIX=riscv64-poky-linux-
export CONFIGURE_FLAGS="--target=riscv64-poky-linux --host=riscv64-poky-linux --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"
export CFLAGS=" -O2 -g  -pipe"
export CXXFLAGS=" -O2 -g  -pipe"
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now"
export CPPFLAGS=""
export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"
export OECORE_DISTRO_VERSION="6.0.99+snapshot-0bfb93afa0e8371d673626deb140f49a37f0ba27"
export OECORE_SDK_VERSION="6.0.99+snapshot"
export ARCH=riscv
export CROSS_COMPILE=riscv64-poky-linux-
export OECORE_TUNE_CCARGS="-march=rv64imafdc_zicsr_zifencei -mabi=lp64d"

# Append environment subscripts
if [ -d "$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then
    for envfile in $OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do
	    . $envfile
    done
fi
if [ -d "$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then
    for envfile in $OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do
	    . $envfile
    done
fi
if [ -d "$OECORE_NATIVE_SYSROOT/environment-setup.d/$OECORE_TARGET_SYS" ]; then
    for envfile in $OECORE_NATIVE_SYSROOT/environment-setup.d/$OECORE_TARGET_SYS/*.sh; do
            . $envfile
    done
fi


if [ -d "$OECORE_NATIVE_SYSROOT//usr/share/post-relocate-setup.d/" ]; then
	for s in $OECORE_NATIVE_SYSROOT//usr/share/post-relocate-setup.d/*; do
		if [ ! -x $s ]; then
			continue
		fi
		$s "$1"
		status=$?
		if [ $status != 0 ]; then
			echo "post-relocate command \"$s $1\" failed with status $status" >&2
			exit $status
		fi
	done
fi
