1# SPDX-License-Identifier: Apache-2.0
2
3zephyr_get(XTENSA_TOOLCHAIN_PATH)
4assert(    XTENSA_TOOLCHAIN_PATH "XTENSA_TOOLCHAIN_PATH is not set")
5
6if(NOT EXISTS ${XTENSA_TOOLCHAIN_PATH})
7  message(FATAL_ERROR "Nothing found at XTENSA_TOOLCHAIN_PATH: '${XTENSA_TOOLCHAIN_PATH}'")
8endif()
9
10zephyr_get(TOOLCHAIN_VER)
11if(DEFINED TOOLCHAIN_VER)
12  set(XTENSA_TOOLCHAIN_VER ${TOOLCHAIN_VER})
13else()
14  zephyr_get(TOOLCHAIN_VER_${NORMALIZED_BOARD_TARGET})
15  if(DEFINED TOOLCHAIN_VER_${NORMALIZED_BOARD_TARGET})
16    set(XTENSA_TOOLCHAIN_VER ${TOOLCHAIN_VER_${NORMALIZED_BOARD_TARGET}})
17  else()
18    message(FATAL "Environment variable TOOLCHAIN_VER must be set or given as -DTOOLCHAIN_VER=<var>")
19  endif()
20endif()
21
22zephyr_get(XTENSA_CORE_${NORMALIZED_BOARD_TARGET})
23if(DEFINED XTENSA_CORE_${NORMALIZED_BOARD_TARGET})
24  set(XTENSA_CORE_LOCAL_C_FLAG "--xtensa-core=${XTENSA_CORE_${NORMALIZED_BOARD_TARGET}}")
25  list(APPEND TOOLCHAIN_C_FLAGS "--xtensa-core=${XTENSA_CORE_${NORMALIZED_BOARD_TARGET}}")
26else()
27  # Not having XTENSA_CORE is not necessarily fatal as
28  # the toolchain can have a default core configuration to use.
29  set(XTENSA_CORE_LOCAL_C_FLAG)
30endif()
31
32set(TOOLCHAIN_HOME ${XTENSA_TOOLCHAIN_PATH}/${XTENSA_TOOLCHAIN_VER}/XtensaTools)
33
34set(LINKER ld)
35set(BINTOOLS gnu)
36
37set(CROSS_COMPILE_TARGET xt)
38set(SYSROOT_TARGET       xtensa-elf)
39
40set(CROSS_COMPILE  ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-)
41set(SYSROOT_DIR    ${TOOLCHAIN_HOME}/${SYSROOT_TARGET})
42
43set(NOSYSDEF_CFLAG "")
44
45list(APPEND TOOLCHAIN_C_FLAGS -fms-extensions)
46
47set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
48