1include mk/cleanvars.mk 2 3# Set current submodule (used for module specific flags compile result etc) 4sm := core 5sm-$(sm) := y 6 7arch-dir := core/arch/$(ARCH) 8platform-dir := $(arch-dir)/plat-$(PLATFORM) 9include $(platform-dir)/conf.mk 10include mk/config.mk 11# $(ARCH).mk also sets the compiler for the core module 12include core/arch/$(ARCH)/$(ARCH).mk 13 14ifeq ($(CFG_OS_REV_REPORTS_GIT_SHA1),y) 15ifeq ($(arch-bits-core),64) 16git-sha1-len := 16 17else 18git-sha1-len := 8 19endif 20TEE_IMPL_GIT_SHA1 := 0x$(shell git rev-parse --short=$(git-sha1-len) HEAD 2>/dev/null || echo 0 | cut -c -$(git-sha1-len)) 21else 22TEE_IMPL_GIT_SHA1 := 0x0 23endif 24 25PLATFORM_$(PLATFORM) := y 26PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y 27 28$(eval $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA)) 29_CFG_CORE_ASYNC_NOTIF_DEFAULT_IMPL ?= $(CFG_CORE_ASYNC_NOTIF) 30include core/crypto.mk 31 32ifeq ($(CFG_SCMI_SCPFW),y) 33include core/lib/scmi-server/conf.mk 34endif 35 36cppflags$(sm) += -D__KERNEL__ 37 38cppflags$(sm) += -Icore/include 39cppflags$(sm) += -include $(conf-file) 40cppflags$(sm) += -I$(out-dir)/core/include 41cppflags$(sm) += $(core-platform-cppflags) 42cflags$(sm) += $(core-platform-cflags) 43 44core-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR) := -fstack-protector 45core-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_STRONG) := -fstack-protector-strong 46core-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_ALL) := -fstack-protector-all 47cflags$(sm) += $(core-stackp-cflags-y) 48 49ifeq ($(CFG_CORE_SANITIZE_UNDEFINED),y) 50cflags$(sm) += -fsanitize=undefined 51endif 52ifeq ($(CFG_CORE_SANITIZE_KADDRESS),y) 53ifeq ($(CFG_ASAN_SHADOW_OFFSET),) 54$(error error: CFG_CORE_SANITIZE_KADDRESS not supported by platform (flavor)) 55endif 56ifeq ($(COMPILER),clang) 57$(error error: CFG_CORE_SANITIZE_KADDRESS not supported with Clang) 58endif 59cflags_kasan += -fsanitize=kernel-address \ 60 -fasan-shadow-offset=$(CFG_ASAN_SHADOW_OFFSET)\ 61 --param asan-stack=1 --param asan-globals=1 \ 62 --param asan-instrumentation-with-call-threshold=0 63cflags$(sm) += $(cflags_kasan) 64endif 65ifeq ($(CFG_CORE_DEBUG_CHECK_STACKS),y) 66finstrument-functions := $(call cc-option,-finstrument-functions) 67ifeq (,$(finstrument-functions)) 68$(error -finstrument-functions not supported) 69endif 70cflags$(sm) += $(finstrument-functions) 71endif 72ifeq ($(CFG_SYSCALL_FTRACE),y) 73cflags$(sm) += -pg 74endif 75aflags$(sm) += $(core-platform-aflags) 76 77cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL) 78ifeq ($(CFG_TEE_CORE_MALLOC_DEBUG),y) 79cppflags$(sm) += -DENABLE_MDBG=1 80endif 81ifneq ($(CFG_TEE_CORE_DEBUG),y) 82cppflags$(sm) += -DNDEBUG 83endif 84 85cppflags$(sm) += -Ildelf/include 86cppflags$(sm) += -Ilib/libutee/include 87 88ifeq ($(filter y, $(CFG_CORE_DYN_SHM) $(CFG_CORE_RESERVED_SHM)),) 89$(error error: No shared memory configured) 90endif 91 92# Tell all libraries and sub-directories (included below) that we have a 93# configuration file 94 95conf-file := $(out-dir)/include/generated/conf.h 96conf-mk-file := $(out-dir)/conf.mk 97conf-cmake-file := $(out-dir)/conf.cmake 98$(conf-file): $(conf-mk-file) 99 100cleanfiles += $(conf-file) 101cleanfiles += $(conf-mk-file) 102cleanfiles += $(conf-cmake-file) 103 104$(conf-file): FORCE 105 $(call check-conf-h) 106 107$(conf-mk-file): FORCE 108 $(call check-conf-mk) 109 110$(conf-cmake-file): FORCE 111 $(call check-conf-cmake) 112 113# 114# Do libraries 115# 116 117# Set a prefix to avoid conflicts with user TAs that will use the same 118# source but with different flags below 119base-prefix := $(sm)- 120libname = utils 121libdir = lib/libutils 122include mk/lib.mk 123 124# CFG_CRYPTOLIB_NAME must not be changed beyond this line 125CFG_CRYPTOLIB_NAME_$(CFG_CRYPTOLIB_NAME) := y 126 127ifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt) 128# We're compiling mbedtls too, but with a limited configuration which only 129# provides the MPI routines 130libname = mbedtls 131libdir = lib/libmbedtls 132include mk/lib.mk 133endif #tomcrypt 134 135ifeq ($(CFG_CRYPTOLIB_NAME),mbedtls) 136$(call force,CFG_CRYPTO_RSASSA_NA1,n,not supported by mbedtls) 137libname = tomcrypt 138libdir = core/lib/libtomcrypt 139base-prefix := 140include mk/lib.mk 141base-prefix := $(sm)- 142endif 143 144ifeq ($(firstword $(subst /, ,$(CFG_CRYPTOLIB_DIR))),core) 145# If a library can be compiled for both core and user space a base-prefix 146# is needed in order to avoid conflicts in the output. However, if the 147# library resides under core then it can't be compiled to user space. 148base-prefix := 149endif 150 151libname = $(CFG_CRYPTOLIB_NAME) 152libdir = $(CFG_CRYPTOLIB_DIR) 153include mk/lib.mk 154 155base-prefix := 156 157libname = fdt 158libdir = core/lib/libfdt 159include mk/lib.mk 160 161ifeq ($(CFG_ZLIB),y) 162libname = zlib 163libdir = core/lib/zlib 164include mk/lib.mk 165endif 166 167libname = unw 168libdir = lib/libunw 169include mk/lib.mk 170 171ifeq ($(CFG_SCMI_SCPFW),y) 172libname = scmi-server 173libdir = core/lib/scmi-server 174include mk/lib.mk 175endif 176 177# 178# Do main source 179# 180 181subdirs = $(core-platform-subdirs) core 182include mk/subdir.mk 183 184include mk/compile.mk 185 186include $(if $(wildcard $(platform-dir)/link.mk), \ 187 $(platform-dir)/link.mk, \ 188 core/arch/$(ARCH)/kernel/link.mk) 189