2021-05-07 23:04:13 +08:00
|
|
|
if(CONFIG_MBEDTLS)
|
|
|
|
zephyr_interface_library_named(mbedTLS)
|
|
|
|
|
|
|
|
if(CONFIG_MBEDTLS_BUILTIN)
|
|
|
|
target_compile_definitions(mbedTLS INTERFACE
|
|
|
|
MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CFG_FILE}"
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(mbedTLS INTERFACE
|
2021-10-15 03:59:12 +08:00
|
|
|
${ZEPHYR_CURRENT_MODULE_DIR}/include
|
2021-05-08 00:53:05 +08:00
|
|
|
configs
|
2021-05-07 23:04:13 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
zephyr_library()
|
|
|
|
|
|
|
|
file(GLOB
|
|
|
|
mbedtls_sources # This is an output parameter
|
2021-10-15 03:59:12 +08:00
|
|
|
${ZEPHYR_CURRENT_MODULE_DIR}/library/*.c
|
2021-05-07 23:04:13 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
zephyr_library_sources(
|
|
|
|
zephyr_init.c
|
|
|
|
${mbedtls_sources}
|
|
|
|
)
|
|
|
|
|
2021-06-08 08:58:36 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_MBEDTLS_SHELL shell.c)
|
|
|
|
|
2021-05-07 23:04:13 +08:00
|
|
|
zephyr_library_app_memory(k_mbedtls_partition)
|
|
|
|
if(CONFIG_ARCH_POSIX AND CONFIG_ASAN AND NOT CONFIG_64BIT)
|
|
|
|
# i386 assembly code used in MBEDTLS does not compile with size optimization
|
|
|
|
# if address sanitizer is enabled, as such switch default optimization level
|
|
|
|
# to speed
|
2021-05-08 01:27:49 +08:00
|
|
|
set_property(SOURCE ${ZEPHYR_CURRENT_MODULE_DIR}/mbedtls/library/bignum.c APPEND PROPERTY COMPILE_OPTIONS
|
2021-05-07 23:04:13 +08:00
|
|
|
"${OPTIMIZE_FOR_SPEED_FLAG}")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
zephyr_library_link_libraries(mbedTLS)
|
2021-05-25 19:04:46 +08:00
|
|
|
elseif (CONFIG_MBEDTLS_LIBRARY)
|
2021-05-07 23:04:13 +08:00
|
|
|
|
|
|
|
# NB: CONFIG_MBEDTLS_LIBRARY is not regression tested and is
|
|
|
|
# therefore susceptible to bit rot
|
|
|
|
|
|
|
|
target_include_directories(mbedTLS INTERFACE
|
|
|
|
${CONFIG_MBEDTLS_INSTALL_PATH}
|
|
|
|
)
|
|
|
|
|
|
|
|
zephyr_link_libraries(
|
|
|
|
mbedtls_external
|
|
|
|
-L${CONFIG_MBEDTLS_INSTALL_PATH}
|
|
|
|
gcc
|
|
|
|
)
|
|
|
|
# Lib mbedtls_external depends on libgcc (I assume?) so to allow
|
|
|
|
# mbedtls_external to link with gcc we need to ensure it is placed
|
|
|
|
# after mbedtls_external on the linkers command line.
|
2021-05-25 19:04:46 +08:00
|
|
|
else()
|
|
|
|
# If none of either CONFIG_MBEDTLS_BUILTIN or CONFIG_MBEDTLS_LIBRARY
|
|
|
|
# are defined the users need add a custom Kconfig choice to the
|
|
|
|
# MBEDTLS_IMPLEMENTATION and manually add the mbedtls library and
|
|
|
|
# included the required directories for mbedtls in their projects.
|
2021-05-07 23:04:13 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|