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 mk/checkconf.mk 10include $(platform-dir)/conf.mk 11include mk/config.mk 12include core/arch/$(ARCH)/$(ARCH).mk 13 14PLATFORM_$(PLATFORM) := y 15PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y 16 17$(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA) 18 19# Setup compiler for this sub module 20COMPILER_$(sm) ?= $(COMPILER) 21include mk/$(COMPILER_$(sm)).mk 22 23cppflags$(sm) += -D__KERNEL__ 24 25cppflags$(sm) += -Icore/include 26cppflags$(sm) += -include $(conf-file) 27cppflags$(sm) += -I$(out-dir)/core/include/generated 28cppflags$(sm) += $(core-platform-cppflags) 29cflags$(sm) += $(core-platform-cflags) 30ifeq ($(CFG_CORE_SANITIZE_UNDEFINED),y) 31cflags$(sm) += -fsanitize=undefined 32endif 33ifeq ($(CFG_CORE_SANITIZE_KADDRESS),y) 34ifeq ($(CFG_ASAN_SHADOW_OFFSET),) 35$(error error: CFG_CORE_SANITIZE_KADDRESS not supported by platform (flavor)) 36endif 37cflags_kasan += -fsanitize=kernel-address \ 38 -fasan-shadow-offset=$(CFG_ASAN_SHADOW_OFFSET)\ 39 --param asan-stack=1 --param asan-globals=1 \ 40 --param asan-instrumentation-with-call-threshold=0 41cflags$(sm) += $(cflags_kasan) 42endif 43aflags$(sm) += $(core-platform-aflags) 44 45cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL) 46ifeq ($(CFG_TEE_CORE_MALLOC_DEBUG),y) 47cppflags$(sm) += -DENABLE_MDBG=1 48endif 49ifneq ($(CFG_TEE_CORE_DEBUG),y) 50cppflags$(sm) += -DNDEBUG 51endif 52 53cppflags$(sm) += -Ilib/libutee/include 54 55# Tell all libraries and sub-directories (included below) that we have a 56# configuration file 57 58conf-file := $(out-dir)/include/generated/conf.h 59conf-mk-file := $(out-dir)/conf.mk 60$(conf-file): $(conf-mk-file) 61 62cleanfiles += $(conf-file) 63cleanfiles += $(conf-mk-file) 64 65$(conf-file): FORCE 66 $(call check-conf-h) 67 68$(conf-mk-file): FORCE 69 $(call check-conf-mk) 70 71# 72# Do libraries 73# 74 75# Set a prefix to avoid conflicts with user TAs that will use the same 76# source but with different flags below 77base-prefix := $(sm)- 78libname = utils 79libdir = lib/libutils 80include mk/lib.mk 81 82libname = mpa 83libdir = lib/libmpa 84include mk/lib.mk 85base-prefix := 86 87libname = tomcrypt 88libdir = core/lib/libtomcrypt 89include mk/lib.mk 90 91ifeq ($(CFG_DT),y) 92libname = fdt 93libdir = core/lib/libfdt 94include mk/lib.mk 95endif 96 97ifeq ($(CFG_ZLIB),y) 98libname = zlib 99libdir = core/lib/zlib 100include mk/lib.mk 101endif 102 103# 104# Do main source 105# 106 107subdirs = $(core-platform-subdirs) core 108include mk/subdir.mk 109 110asm-defines-file := core/arch/$(ARCH)/kernel/asm-defines.c 111include mk/compile.mk 112 113include $(if $(wildcard $(platform-dir)/link.mk), \ 114 $(platform-dir)/link.mk, \ 115 core/arch/$(ARCH)/kernel/link.mk) 116