1# SPDX-License-Identifier: Apache-2.0 2 3zephyr_get(ARCMWDT_TOOLCHAIN_PATH) 4 5set(METAWARE_ROOT $ENV{METAWARE_ROOT}) 6if(NOT DEFINED ARCMWDT_TOOLCHAIN_PATH AND DEFINED METAWARE_ROOT) 7 message(STATUS "ARCMWDT_TOOLCHAIN_PATH is not set, use default toolchain from METAWARE_ROOT: '${METAWARE_ROOT}'") 8 if(NOT EXISTS ${METAWARE_ROOT}) 9 message(FATAL_ERROR "Nothing found at METAWARE_ROOT: '${METAWARE_ROOT}'") 10 endif() 11 cmake_path(GET METAWARE_ROOT PARENT_PATH ARCMWDT_TOOLCHAIN_PATH) 12elseif(NOT DEFINED ARCMWDT_TOOLCHAIN_PATH AND NOT DEFINED METAWARE_ROOT) 13 message(FATAL_ERROR "No MWDT toolchain specified: neither ARCMWDT_TOOLCHAIN_PATH nor METAWARE_ROOT defined") 14endif() 15 16if(NOT EXISTS ${ARCMWDT_TOOLCHAIN_PATH}) 17 message(FATAL_ERROR "Nothing found at ARCMWDT_TOOLCHAIN_PATH: '${ARCMWDT_TOOLCHAIN_PATH}'") 18endif() 19 20# arcmwdt relies on Zephyr SDK for the use of C preprocessor (devicetree) and objcopy 21find_package(Zephyr-sdk 0.15 REQUIRED) 22# Handling to be improved in Zephyr SDK, we can drop setting TOOLCHAIN_HOME after 23# https://github.com/zephyrproject-rtos/sdk-ng/pull/682 got merged and we switch to proper SDK 24# version. 25set(TOOLCHAIN_HOME ${ZEPHYR_SDK_INSTALL_DIR}) 26 27# On very early stage build system needs to get access to DTC preprocessor. 28# MWDT has no it's own preprocessor, so here zephyr-SDK preprocessor is used. 29# At the same time zephyr-SDK requires ARCH variable to be initialized before include "generic.cmake", 30# but in hew HWMv2 model ARCH variable will be initialized more later. 31# This workaround uses any (first awailable, independent on ARCH) toolchain from SDK for DTC preprocessing only. 32# For other build stages ARCMWDT will be used. 33include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/generic.cmake) 34unset(TOOLCHAIN_HAS_NEWLIB CACHE) 35unset(TOOLCHAIN_HAS_PICOLIBC CACHE) 36 37set(ZEPHYR_SDK_CROSS_COMPILE ${CROSS_COMPILE}) 38# Handling to be improved in Zephyr SDK, to avoid overriding ZEPHYR_TOOLCHAIN_VARIANT by 39# find_package(Zephyr-sdk) if it's already set 40set(ZEPHYR_TOOLCHAIN_VARIANT arcmwdt) 41 42set(TOOLCHAIN_HOME ${ARCMWDT_TOOLCHAIN_PATH}/MetaWare) 43 44set(COMPILER arcmwdt) 45set(LINKER arcmwdt) 46set(BINTOOLS arcmwdt) 47 48set(SYSROOT_TARGET arc) 49 50set(CROSS_COMPILE ${TOOLCHAIN_HOME}/arc/bin/) 51set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET}) 52 53set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib") 54