1b0104773SPascal Brandinclude mk/cleanvars.mk 2b0104773SPascal Brand 3b0104773SPascal Brand# Set current submodule (used for module specific flags compile result etc) 4b0104773SPascal Brandsm := core 5b0104773SPascal Brandsm-$(sm) := y 6b0104773SPascal Brand 74334e8d7SJerome Forissierarch-dir := core/arch/$(ARCH) 84334e8d7SJerome Forissierplatform-dir := $(arch-dir)/plat-$(PLATFORM) 94334e8d7SJerome Forissierinclude $(platform-dir)/conf.mk 10739804b5SJens Wiklanderinclude mk/config.mk 11331ebf7eSJerome Forissier# $(ARCH).mk also sets the compiler for the core module 120de9a5fbSJens Wiklanderinclude core/arch/$(ARCH)/$(ARCH).mk 13b0104773SPascal Brand 149fc53171SJerome ForissierPLATFORM_$(PLATFORM) := y 159fc53171SJerome ForissierPLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y 169fc53171SJerome Forissier 176b385aafSJerome Forissier$(eval $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA)) 18*a2a3dfbcSJens Wiklander_CFG_CORE_ASYNC_NOTIF_DEFAULT_IMPL ?= $(CFG_CORE_ASYNC_NOTIF) 193d3ad63dSJens Wiklanderinclude core/crypto.mk 20a884c935SJens Wiklander 214c4212e9SVincent Guittotifeq ($(CFG_SCMI_SCPFW),y) 224c4212e9SVincent Guittotinclude core/lib/scmi-server/conf.mk 234c4212e9SVincent Guittotendif 244c4212e9SVincent Guittot 2545082335SJens Wiklandercppflags$(sm) += -D__KERNEL__ 2645082335SJens Wiklander 27a3911433SJerome Forissiercppflags$(sm) += -Icore/include 28b5569a68SPascal Brandcppflags$(sm) += -include $(conf-file) 2989fe7c3cSJerome Forissiercppflags$(sm) += -I$(out-dir)/core/include 30739804b5SJens Wiklandercppflags$(sm) += $(core-platform-cppflags) 31739804b5SJens Wiklandercflags$(sm) += $(core-platform-cflags) 3245507d10SKhoa Hoang 3345507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR) := -fstack-protector 3445507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_STRONG) := -fstack-protector-strong 3545507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_ALL) := -fstack-protector-all 3645507d10SKhoa Hoangcflags$(sm) += $(core-stackp-cflags-y) 3745507d10SKhoa Hoang 38be715239SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_UNDEFINED),y) 39be715239SJens Wiklandercflags$(sm) += -fsanitize=undefined 40be715239SJens Wiklanderendif 411d171f95SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_KADDRESS),y) 421d171f95SJens Wiklanderifeq ($(CFG_ASAN_SHADOW_OFFSET),) 431d171f95SJens Wiklander$(error error: CFG_CORE_SANITIZE_KADDRESS not supported by platform (flavor)) 441d171f95SJens Wiklanderendif 4598d863a5SJerome Forissierifeq ($(COMPILER),clang) 4698d863a5SJerome Forissier$(error error: CFG_CORE_SANITIZE_KADDRESS not supported with Clang) 4798d863a5SJerome Forissierendif 481d171f95SJens Wiklandercflags_kasan += -fsanitize=kernel-address \ 491d171f95SJens Wiklander -fasan-shadow-offset=$(CFG_ASAN_SHADOW_OFFSET)\ 501d171f95SJens Wiklander --param asan-stack=1 --param asan-globals=1 \ 511d171f95SJens Wiklander --param asan-instrumentation-with-call-threshold=0 521d171f95SJens Wiklandercflags$(sm) += $(cflags_kasan) 531d171f95SJens Wiklanderendif 54e2f03e07SJerome Forissierifeq ($(CFG_CORE_DEBUG_CHECK_STACKS),y) 55e2f03e07SJerome Forissierfinstrument-functions := $(call cc-option,-finstrument-functions) 56e2f03e07SJerome Forissierifeq (,$(finstrument-functions)) 57e2f03e07SJerome Forissier$(error -finstrument-functions not supported) 58e2f03e07SJerome Forissierendif 59e2f03e07SJerome Forissiercflags$(sm) += $(finstrument-functions) 60e2f03e07SJerome Forissierendif 61099918f6SSumit Gargifeq ($(CFG_SYSCALL_FTRACE),y) 62099918f6SSumit Gargcflags$(sm) += -pg 63099918f6SSumit Gargendif 64739804b5SJens Wiklanderaflags$(sm) += $(core-platform-aflags) 65b0104773SPascal Brand 668a1e7b89SJerome Forissiercppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL) 67156fe685SPascal Brandifeq ($(CFG_TEE_CORE_MALLOC_DEBUG),y) 68156fe685SPascal Brandcppflags$(sm) += -DENABLE_MDBG=1 69156fe685SPascal Brandendif 7099eee037SEtienne Carriereifneq ($(CFG_TEE_CORE_DEBUG),y) 7199eee037SEtienne Carrierecppflags$(sm) += -DNDEBUG 7299eee037SEtienne Carriereendif 73b0104773SPascal Brand 74dd22da8eSJens Wiklandercppflags$(sm) += -Ildelf/include 75b0104773SPascal Brandcppflags$(sm) += -Ilib/libutee/include 76b0104773SPascal Brand 778aeb6c94SJens Wiklanderifeq ($(filter y, $(CFG_CORE_DYN_SHM) $(CFG_CORE_RESERVED_SHM)),) 788aeb6c94SJens Wiklander$(error error: No shared memory configured) 798aeb6c94SJens Wiklanderendif 808aeb6c94SJens Wiklander 81fe52b1f5SJerome Forissier# Tell all libraries and sub-directories (included below) that we have a 82fe52b1f5SJerome Forissier# configuration file 83fe52b1f5SJerome Forissier 84b5569a68SPascal Brandconf-file := $(out-dir)/include/generated/conf.h 85b5569a68SPascal Brandconf-mk-file := $(out-dir)/conf.mk 86b924c494SJens Wiklanderconf-cmake-file := $(out-dir)/conf.cmake 87dde0e235Setienne carriere$(conf-file): $(conf-mk-file) 88dde0e235Setienne carriere 89fe52b1f5SJerome Forissiercleanfiles += $(conf-file) 90dde0e235Setienne carrierecleanfiles += $(conf-mk-file) 9140015a64SJerome Forissiercleanfiles += $(conf-cmake-file) 92fe52b1f5SJerome Forissier 93fe52b1f5SJerome Forissier$(conf-file): FORCE 94fe52b1f5SJerome Forissier $(call check-conf-h) 95fe52b1f5SJerome Forissier 96dde0e235Setienne carriere$(conf-mk-file): FORCE 973354f9b2SJerome Forissier $(call check-conf-mk) 98dde0e235Setienne carriere 99b924c494SJens Wiklander$(conf-cmake-file): FORCE 100b924c494SJens Wiklander $(call check-conf-cmake) 101b924c494SJens Wiklander 102b0104773SPascal Brand# 103b0104773SPascal Brand# Do libraries 104b0104773SPascal Brand# 105b0104773SPascal Brand 106b0104773SPascal Brand# Set a prefix to avoid conflicts with user TAs that will use the same 107b0104773SPascal Brand# source but with different flags below 108b0104773SPascal Brandbase-prefix := $(sm)- 109b0104773SPascal Brandlibname = utils 110b0104773SPascal Brandlibdir = lib/libutils 111b0104773SPascal Brandinclude mk/lib.mk 112b0104773SPascal Brand 11318dd462bSJens Wiklander# CFG_CRYPTOLIB_NAME must not be changed beyond this line 11418dd462bSJens WiklanderCFG_CRYPTOLIB_NAME_$(CFG_CRYPTOLIB_NAME) := y 115e789ada3SJens Wiklander 116fcd21d9eSJens Wiklanderifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt) 117e789ada3SJens Wiklander# We're compiling mbedtls too, but with a limited configuration which only 118e789ada3SJens Wiklander# provides the MPI routines 119e789ada3SJens Wiklanderlibname = mbedtls 120e789ada3SJens Wiklanderlibdir = lib/libmbedtls 121e789ada3SJens Wiklanderinclude mk/lib.mk 122fcd21d9eSJens Wiklanderendif #tomcrypt 123e789ada3SJens Wiklander 12477327d7aSEdison Aiifeq ($(CFG_CRYPTOLIB_NAME),mbedtls) 12577327d7aSEdison Ai$(call force,CFG_CRYPTO_RSASSA_NA1,n,not supported by mbedtls) 126884462feSJens Wiklanderlibname = tomcrypt 127884462feSJens Wiklanderlibdir = core/lib/libtomcrypt 128884462feSJens Wiklanderbase-prefix := 129884462feSJens Wiklanderinclude mk/lib.mk 130884462feSJens Wiklanderbase-prefix := $(sm)- 13177327d7aSEdison Aiendif 13277327d7aSEdison Ai 133fa788ef9SJens Wiklanderifeq ($(firstword $(subst /, ,$(CFG_CRYPTOLIB_DIR))),core) 134fa788ef9SJens Wiklander# If a library can be compiled for both core and user space a base-prefix 135fa788ef9SJens Wiklander# is needed in order to avoid conflicts in the output. However, if the 136fa788ef9SJens Wiklander# library resides under core then it can't be compiled to user space. 137b0104773SPascal Brandbase-prefix := 138fa788ef9SJens Wiklanderendif 139b0104773SPascal Brand 140d2d2d58bSdeebee-v2libname = $(CFG_CRYPTOLIB_NAME) 141d2d2d58bSdeebee-v2libdir = $(CFG_CRYPTOLIB_DIR) 142b0104773SPascal Brandinclude mk/lib.mk 143b0104773SPascal Brand 144fa788ef9SJens Wiklanderbase-prefix := 145fa788ef9SJens Wiklander 146b908c675SJens Wiklanderlibname = fdt 147b908c675SJens Wiklanderlibdir = core/lib/libfdt 148b908c675SJens Wiklanderinclude mk/lib.mk 149b908c675SJens Wiklander 150b3be2f66SJerome Forissierifeq ($(CFG_ZLIB),y) 151b3be2f66SJerome Forissierlibname = zlib 152b3be2f66SJerome Forissierlibdir = core/lib/zlib 153b3be2f66SJerome Forissierinclude mk/lib.mk 154b3be2f66SJerome Forissierendif 155b3be2f66SJerome Forissier 15602d307b7SJerome Forissierlibname = unw 15702d307b7SJerome Forissierlibdir = lib/libunw 15802d307b7SJerome Forissierinclude mk/lib.mk 15902d307b7SJerome Forissier 1604c4212e9SVincent Guittotifeq ($(CFG_SCMI_SCPFW),y) 1614c4212e9SVincent Guittotlibname = scmi-server 1624c4212e9SVincent Guittotlibdir = core/lib/scmi-server 1634c4212e9SVincent Guittotinclude mk/lib.mk 1644c4212e9SVincent Guittotendif 1654c4212e9SVincent Guittot 166b0104773SPascal Brand# 167b0104773SPascal Brand# Do main source 168b0104773SPascal Brand# 169bc420748SJens Wiklander 170b0104773SPascal Brandsubdirs = $(core-platform-subdirs) core 171b0104773SPascal Brandinclude mk/subdir.mk 172bc420748SJens Wiklander 173b0104773SPascal Brandinclude mk/compile.mk 174d5a887c8SJens Wiklander 17571315c30SAndrew F. Davisinclude $(if $(wildcard $(platform-dir)/link.mk), \ 17671315c30SAndrew F. Davis $(platform-dir)/link.mk, \ 17771315c30SAndrew F. Davis core/arch/$(ARCH)/kernel/link.mk) 178