xref: /optee_os/core/core.mk (revision f7492391a90d5fa10df014c1cf54a4308a6e9a2a)
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
11include core/arch/$(ARCH)/$(ARCH).mk
12
13PLATFORM_$(PLATFORM) := y
14PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y
15
16$(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA)
17include core/crypto.mk
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
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)	+= -Ildelf/include
54cppflags$(sm)	+= -Ilib/libutee/include
55
56ifeq ($(filter y, $(CFG_CORE_DYN_SHM) $(CFG_CORE_RESERVED_SHM)),)
57$(error error: No shared memory configured)
58endif
59
60# Tell all libraries and sub-directories (included below) that we have a
61# configuration file
62
63conf-file := $(out-dir)/include/generated/conf.h
64conf-mk-file := $(out-dir)/conf.mk
65conf-cmake-file := $(out-dir)/conf.cmake
66$(conf-file): $(conf-mk-file)
67
68cleanfiles += $(conf-file)
69cleanfiles += $(conf-mk-file)
70
71$(conf-file): FORCE
72	$(call check-conf-h)
73
74$(conf-mk-file):  FORCE
75	$(call check-conf-mk)
76
77$(conf-cmake-file):  FORCE
78	$(call check-conf-cmake)
79
80#
81# Do libraries
82#
83
84# Set a prefix to avoid conflicts with user TAs that will use the same
85# source but with different flags below
86base-prefix := $(sm)-
87libname = utils
88libdir = lib/libutils
89include mk/lib.mk
90
91# CFG_CRYPTOLIB_NAME must not be changed beyond this line
92CFG_CRYPTOLIB_NAME_$(CFG_CRYPTOLIB_NAME) := y
93
94ifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt)
95ifeq ($(CFG_CORE_MBEDTLS_MPI),y)
96# We're compiling mbedtls too, but with a limited configuration which only
97# provides the MPI routines
98libname = mbedtls
99libdir = lib/libmbedtls
100include mk/lib.mk
101else
102libname = mpa
103libdir = lib/libmpa
104include mk/lib.mk
105endif
106endif #tomcrypt
107
108ifeq ($(CFG_CRYPTOLIB_NAME),mbedtls)
109$(call force,CFG_CRYPTO_RSASSA_NA1,n,not supported by mbedtls)
110libname = tomcrypt
111libdir = core/lib/libtomcrypt
112base-prefix :=
113include mk/lib.mk
114base-prefix := $(sm)-
115endif
116
117ifeq ($(firstword $(subst /, ,$(CFG_CRYPTOLIB_DIR))),core)
118# If a library can be compiled for both core and user space a base-prefix
119# is needed in order to avoid conflicts in the output. However, if the
120# library resides under core then it can't be compiled to user space.
121base-prefix :=
122endif
123
124libname = $(CFG_CRYPTOLIB_NAME)
125libdir = $(CFG_CRYPTOLIB_DIR)
126include mk/lib.mk
127
128base-prefix :=
129
130ifeq ($(CFG_DT),y)
131libname = fdt
132libdir = core/lib/libfdt
133include mk/lib.mk
134endif
135
136ifeq ($(CFG_ZLIB),y)
137libname = zlib
138libdir = core/lib/zlib
139include mk/lib.mk
140endif
141
142#
143# Do main source
144#
145
146subdirs = $(core-platform-subdirs) core
147include mk/subdir.mk
148
149include mk/compile.mk
150
151include $(if $(wildcard $(platform-dir)/link.mk), \
152		$(platform-dir)/link.mk, \
153		core/arch/$(ARCH)/kernel/link.mk)
154