# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

export RUST_TARGET_PATH="$(pwd)"
export RUST_COMPILER_RT_ROOT=$RUST_TARGET_PATH/rust/rust/src/llvm-project/compiler-rt
if [ -z "$OPTEE_DIR" ]
then
  export OPTEE_DIR="$(pwd)/optee"
fi
export OPTEE_OS_DIR="$OPTEE_DIR/optee_os"
export OPTEE_CLIENT_DIR="$OPTEE_DIR/optee_client/out"
export OPTEE_CLIENT_INCLUDE="$OPTEE_DIR/optee_client/out/export/usr/include"
if [ "$ARCH" = "arm" ]
then
  export ARCH="arm"
  export PATH=$PATH:$OPTEE_DIR/toolchains/aarch32/bin
  export VENDOR="qemu.mk"
  export OPTEE_OS_INCLUDE="$OPTEE_DIR/optee_os/out/arm/export-ta_arm32/include"
  export CC=$OPTEE_DIR/toolchains/aarch32/bin/arm-linux-gnueabihf-gcc
else
  # export ARCH="aarch64" # comment this because currently optee_os cannot be compiled in the aarch64 target
  unset ARCH
  export PATH=$PATH:$OPTEE_DIR/toolchains/aarch64/bin
  export VENDOR="qemu_v8.mk"
  export OPTEE_OS_INCLUDE="$OPTEE_DIR/optee_os/out/arm/export-ta_arm64/include"
  export CC=$OPTEE_DIR/toolchains/aarch64/bin/aarch64-linux-gnu-gcc
fi
