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)) 183d3ad63dSJens Wiklanderinclude core/crypto.mk 19a884c935SJens Wiklander 2045082335SJens Wiklandercppflags$(sm) += -D__KERNEL__ 2145082335SJens Wiklander 22a3911433SJerome Forissiercppflags$(sm) += -Icore/include 23b5569a68SPascal Brandcppflags$(sm) += -include $(conf-file) 2489fe7c3cSJerome Forissiercppflags$(sm) += -I$(out-dir)/core/include 25739804b5SJens Wiklandercppflags$(sm) += $(core-platform-cppflags) 26739804b5SJens Wiklandercflags$(sm) += $(core-platform-cflags) 27be715239SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_UNDEFINED),y) 28be715239SJens Wiklandercflags$(sm) += -fsanitize=undefined 29be715239SJens Wiklanderendif 301d171f95SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_KADDRESS),y) 311d171f95SJens Wiklanderifeq ($(CFG_ASAN_SHADOW_OFFSET),) 321d171f95SJens Wiklander$(error error: CFG_CORE_SANITIZE_KADDRESS not supported by platform (flavor)) 331d171f95SJens Wiklanderendif 3498d863a5SJerome Forissierifeq ($(COMPILER),clang) 3598d863a5SJerome Forissier$(error error: CFG_CORE_SANITIZE_KADDRESS not supported with Clang) 3698d863a5SJerome Forissierendif 371d171f95SJens Wiklandercflags_kasan += -fsanitize=kernel-address \ 381d171f95SJens Wiklander -fasan-shadow-offset=$(CFG_ASAN_SHADOW_OFFSET)\ 391d171f95SJens Wiklander --param asan-stack=1 --param asan-globals=1 \ 401d171f95SJens Wiklander --param asan-instrumentation-with-call-threshold=0 411d171f95SJens Wiklandercflags$(sm) += $(cflags_kasan) 421d171f95SJens Wiklanderendif 43*e2f03e07SJerome Forissierifeq ($(CFG_CORE_DEBUG_CHECK_STACKS),y) 44*e2f03e07SJerome Forissierfinstrument-functions := $(call cc-option,-finstrument-functions) 45*e2f03e07SJerome Forissierifeq (,$(finstrument-functions)) 46*e2f03e07SJerome Forissier$(error -finstrument-functions not supported) 47*e2f03e07SJerome Forissierendif 48*e2f03e07SJerome Forissiercflags$(sm) += $(finstrument-functions) 49*e2f03e07SJerome Forissierendif 50099918f6SSumit Gargifeq ($(CFG_SYSCALL_FTRACE),y) 51099918f6SSumit Gargcflags$(sm) += -pg 52099918f6SSumit Gargendif 53739804b5SJens Wiklanderaflags$(sm) += $(core-platform-aflags) 54b0104773SPascal Brand 558a1e7b89SJerome Forissiercppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL) 56156fe685SPascal Brandifeq ($(CFG_TEE_CORE_MALLOC_DEBUG),y) 57156fe685SPascal Brandcppflags$(sm) += -DENABLE_MDBG=1 58156fe685SPascal Brandendif 5999eee037SEtienne Carriereifneq ($(CFG_TEE_CORE_DEBUG),y) 6099eee037SEtienne Carrierecppflags$(sm) += -DNDEBUG 6199eee037SEtienne Carriereendif 62b0104773SPascal Brand 63dd22da8eSJens Wiklandercppflags$(sm) += -Ildelf/include 64b0104773SPascal Brandcppflags$(sm) += -Ilib/libutee/include 65b0104773SPascal Brand 668aeb6c94SJens Wiklanderifeq ($(filter y, $(CFG_CORE_DYN_SHM) $(CFG_CORE_RESERVED_SHM)),) 678aeb6c94SJens Wiklander$(error error: No shared memory configured) 688aeb6c94SJens Wiklanderendif 698aeb6c94SJens Wiklander 70fe52b1f5SJerome Forissier# Tell all libraries and sub-directories (included below) that we have a 71fe52b1f5SJerome Forissier# configuration file 72fe52b1f5SJerome Forissier 73b5569a68SPascal Brandconf-file := $(out-dir)/include/generated/conf.h 74b5569a68SPascal Brandconf-mk-file := $(out-dir)/conf.mk 75b924c494SJens Wiklanderconf-cmake-file := $(out-dir)/conf.cmake 76dde0e235Setienne carriere$(conf-file): $(conf-mk-file) 77dde0e235Setienne carriere 78fe52b1f5SJerome Forissiercleanfiles += $(conf-file) 79dde0e235Setienne carrierecleanfiles += $(conf-mk-file) 8040015a64SJerome Forissiercleanfiles += $(conf-cmake-file) 81fe52b1f5SJerome Forissier 82fe52b1f5SJerome Forissier$(conf-file): FORCE 83fe52b1f5SJerome Forissier $(call check-conf-h) 84fe52b1f5SJerome Forissier 85dde0e235Setienne carriere$(conf-mk-file): FORCE 863354f9b2SJerome Forissier $(call check-conf-mk) 87dde0e235Setienne carriere 88b924c494SJens Wiklander$(conf-cmake-file): FORCE 89b924c494SJens Wiklander $(call check-conf-cmake) 90b924c494SJens Wiklander 91b0104773SPascal Brand# 92b0104773SPascal Brand# Do libraries 93b0104773SPascal Brand# 94b0104773SPascal Brand 95b0104773SPascal Brand# Set a prefix to avoid conflicts with user TAs that will use the same 96b0104773SPascal Brand# source but with different flags below 97b0104773SPascal Brandbase-prefix := $(sm)- 98b0104773SPascal Brandlibname = utils 99b0104773SPascal Brandlibdir = lib/libutils 100b0104773SPascal Brandinclude mk/lib.mk 101b0104773SPascal Brand 10218dd462bSJens Wiklander# CFG_CRYPTOLIB_NAME must not be changed beyond this line 10318dd462bSJens WiklanderCFG_CRYPTOLIB_NAME_$(CFG_CRYPTOLIB_NAME) := y 104e789ada3SJens Wiklander 105fcd21d9eSJens Wiklanderifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt) 106e789ada3SJens Wiklander# We're compiling mbedtls too, but with a limited configuration which only 107e789ada3SJens Wiklander# provides the MPI routines 108e789ada3SJens Wiklanderlibname = mbedtls 109e789ada3SJens Wiklanderlibdir = lib/libmbedtls 110e789ada3SJens Wiklanderinclude mk/lib.mk 111fcd21d9eSJens Wiklanderendif #tomcrypt 112e789ada3SJens Wiklander 11377327d7aSEdison Aiifeq ($(CFG_CRYPTOLIB_NAME),mbedtls) 11477327d7aSEdison Ai$(call force,CFG_CRYPTO_RSASSA_NA1,n,not supported by mbedtls) 115884462feSJens Wiklanderlibname = tomcrypt 116884462feSJens Wiklanderlibdir = core/lib/libtomcrypt 117884462feSJens Wiklanderbase-prefix := 118884462feSJens Wiklanderinclude mk/lib.mk 119884462feSJens Wiklanderbase-prefix := $(sm)- 12077327d7aSEdison Aiendif 12177327d7aSEdison Ai 122fa788ef9SJens Wiklanderifeq ($(firstword $(subst /, ,$(CFG_CRYPTOLIB_DIR))),core) 123fa788ef9SJens Wiklander# If a library can be compiled for both core and user space a base-prefix 124fa788ef9SJens Wiklander# is needed in order to avoid conflicts in the output. However, if the 125fa788ef9SJens Wiklander# library resides under core then it can't be compiled to user space. 126b0104773SPascal Brandbase-prefix := 127fa788ef9SJens Wiklanderendif 128b0104773SPascal Brand 129d2d2d58bSdeebee-v2libname = $(CFG_CRYPTOLIB_NAME) 130d2d2d58bSdeebee-v2libdir = $(CFG_CRYPTOLIB_DIR) 131b0104773SPascal Brandinclude mk/lib.mk 132b0104773SPascal Brand 133fa788ef9SJens Wiklanderbase-prefix := 134fa788ef9SJens Wiklander 135b908c675SJens Wiklanderlibname = fdt 136b908c675SJens Wiklanderlibdir = core/lib/libfdt 137b908c675SJens Wiklanderinclude mk/lib.mk 138b908c675SJens Wiklander 139b3be2f66SJerome Forissierifeq ($(CFG_ZLIB),y) 140b3be2f66SJerome Forissierlibname = zlib 141b3be2f66SJerome Forissierlibdir = core/lib/zlib 142b3be2f66SJerome Forissierinclude mk/lib.mk 143b3be2f66SJerome Forissierendif 144b3be2f66SJerome Forissier 145b0104773SPascal Brand# 146b0104773SPascal Brand# Do main source 147b0104773SPascal Brand# 148bc420748SJens Wiklander 149b0104773SPascal Brandsubdirs = $(core-platform-subdirs) core 150b0104773SPascal Brandinclude mk/subdir.mk 151bc420748SJens Wiklander 152b0104773SPascal Brandinclude mk/compile.mk 153d5a887c8SJens Wiklander 15471315c30SAndrew F. Davisinclude $(if $(wildcard $(platform-dir)/link.mk), \ 15571315c30SAndrew F. Davis $(platform-dir)/link.mk, \ 15671315c30SAndrew F. Davis core/arch/$(ARCH)/kernel/link.mk) 157