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