xref: /optee_os/core/core.mk (revision 45507d1093f7b546acdf3060939f61d5c7f19817)
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)
27*45507d10SKhoa Hoang
28*45507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR) := -fstack-protector
29*45507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_STRONG) := -fstack-protector-strong
30*45507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_ALL) := -fstack-protector-all
31*45507d10SKhoa Hoangcflags$(sm)	+= $(core-stackp-cflags-y)
32*45507d10SKhoa Hoang
33be715239SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_UNDEFINED),y)
34be715239SJens Wiklandercflags$(sm)	+= -fsanitize=undefined
35be715239SJens Wiklanderendif
361d171f95SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_KADDRESS),y)
371d171f95SJens Wiklanderifeq ($(CFG_ASAN_SHADOW_OFFSET),)
381d171f95SJens Wiklander$(error error: CFG_CORE_SANITIZE_KADDRESS not supported by platform (flavor))
391d171f95SJens Wiklanderendif
4098d863a5SJerome Forissierifeq ($(COMPILER),clang)
4198d863a5SJerome Forissier$(error error: CFG_CORE_SANITIZE_KADDRESS not supported with Clang)
4298d863a5SJerome Forissierendif
431d171f95SJens Wiklandercflags_kasan	+= -fsanitize=kernel-address \
441d171f95SJens Wiklander		   -fasan-shadow-offset=$(CFG_ASAN_SHADOW_OFFSET)\
451d171f95SJens Wiklander		   --param asan-stack=1 --param asan-globals=1 \
461d171f95SJens Wiklander		   --param asan-instrumentation-with-call-threshold=0
471d171f95SJens Wiklandercflags$(sm)	+= $(cflags_kasan)
481d171f95SJens Wiklanderendif
49e2f03e07SJerome Forissierifeq ($(CFG_CORE_DEBUG_CHECK_STACKS),y)
50e2f03e07SJerome Forissierfinstrument-functions := $(call cc-option,-finstrument-functions)
51e2f03e07SJerome Forissierifeq (,$(finstrument-functions))
52e2f03e07SJerome Forissier$(error -finstrument-functions not supported)
53e2f03e07SJerome Forissierendif
54e2f03e07SJerome Forissiercflags$(sm) += $(finstrument-functions)
55e2f03e07SJerome Forissierendif
56099918f6SSumit Gargifeq ($(CFG_SYSCALL_FTRACE),y)
57099918f6SSumit Gargcflags$(sm)	+= -pg
58099918f6SSumit Gargendif
59739804b5SJens Wiklanderaflags$(sm)	+= $(core-platform-aflags)
60b0104773SPascal Brand
618a1e7b89SJerome Forissiercppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL)
62156fe685SPascal Brandifeq ($(CFG_TEE_CORE_MALLOC_DEBUG),y)
63156fe685SPascal Brandcppflags$(sm) += -DENABLE_MDBG=1
64156fe685SPascal Brandendif
6599eee037SEtienne Carriereifneq ($(CFG_TEE_CORE_DEBUG),y)
6699eee037SEtienne Carrierecppflags$(sm)  += -DNDEBUG
6799eee037SEtienne Carriereendif
68b0104773SPascal Brand
69dd22da8eSJens Wiklandercppflags$(sm)	+= -Ildelf/include
70b0104773SPascal Brandcppflags$(sm)	+= -Ilib/libutee/include
71b0104773SPascal Brand
728aeb6c94SJens Wiklanderifeq ($(filter y, $(CFG_CORE_DYN_SHM) $(CFG_CORE_RESERVED_SHM)),)
738aeb6c94SJens Wiklander$(error error: No shared memory configured)
748aeb6c94SJens Wiklanderendif
758aeb6c94SJens Wiklander
76fe52b1f5SJerome Forissier# Tell all libraries and sub-directories (included below) that we have a
77fe52b1f5SJerome Forissier# configuration file
78fe52b1f5SJerome Forissier
79b5569a68SPascal Brandconf-file := $(out-dir)/include/generated/conf.h
80b5569a68SPascal Brandconf-mk-file := $(out-dir)/conf.mk
81b924c494SJens Wiklanderconf-cmake-file := $(out-dir)/conf.cmake
82dde0e235Setienne carriere$(conf-file): $(conf-mk-file)
83dde0e235Setienne carriere
84fe52b1f5SJerome Forissiercleanfiles += $(conf-file)
85dde0e235Setienne carrierecleanfiles += $(conf-mk-file)
8640015a64SJerome Forissiercleanfiles += $(conf-cmake-file)
87fe52b1f5SJerome Forissier
88fe52b1f5SJerome Forissier$(conf-file): FORCE
89fe52b1f5SJerome Forissier	$(call check-conf-h)
90fe52b1f5SJerome Forissier
91dde0e235Setienne carriere$(conf-mk-file):  FORCE
923354f9b2SJerome Forissier	$(call check-conf-mk)
93dde0e235Setienne carriere
94b924c494SJens Wiklander$(conf-cmake-file):  FORCE
95b924c494SJens Wiklander	$(call check-conf-cmake)
96b924c494SJens Wiklander
97b0104773SPascal Brand#
98b0104773SPascal Brand# Do libraries
99b0104773SPascal Brand#
100b0104773SPascal Brand
101b0104773SPascal Brand# Set a prefix to avoid conflicts with user TAs that will use the same
102b0104773SPascal Brand# source but with different flags below
103b0104773SPascal Brandbase-prefix := $(sm)-
104b0104773SPascal Brandlibname = utils
105b0104773SPascal Brandlibdir = lib/libutils
106b0104773SPascal Brandinclude mk/lib.mk
107b0104773SPascal Brand
10818dd462bSJens Wiklander# CFG_CRYPTOLIB_NAME must not be changed beyond this line
10918dd462bSJens WiklanderCFG_CRYPTOLIB_NAME_$(CFG_CRYPTOLIB_NAME) := y
110e789ada3SJens Wiklander
111fcd21d9eSJens Wiklanderifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt)
112e789ada3SJens Wiklander# We're compiling mbedtls too, but with a limited configuration which only
113e789ada3SJens Wiklander# provides the MPI routines
114e789ada3SJens Wiklanderlibname = mbedtls
115e789ada3SJens Wiklanderlibdir = lib/libmbedtls
116e789ada3SJens Wiklanderinclude mk/lib.mk
117fcd21d9eSJens Wiklanderendif #tomcrypt
118e789ada3SJens Wiklander
11977327d7aSEdison Aiifeq ($(CFG_CRYPTOLIB_NAME),mbedtls)
12077327d7aSEdison Ai$(call force,CFG_CRYPTO_RSASSA_NA1,n,not supported by mbedtls)
121884462feSJens Wiklanderlibname = tomcrypt
122884462feSJens Wiklanderlibdir = core/lib/libtomcrypt
123884462feSJens Wiklanderbase-prefix :=
124884462feSJens Wiklanderinclude mk/lib.mk
125884462feSJens Wiklanderbase-prefix := $(sm)-
12677327d7aSEdison Aiendif
12777327d7aSEdison Ai
128fa788ef9SJens Wiklanderifeq ($(firstword $(subst /, ,$(CFG_CRYPTOLIB_DIR))),core)
129fa788ef9SJens Wiklander# If a library can be compiled for both core and user space a base-prefix
130fa788ef9SJens Wiklander# is needed in order to avoid conflicts in the output. However, if the
131fa788ef9SJens Wiklander# library resides under core then it can't be compiled to user space.
132b0104773SPascal Brandbase-prefix :=
133fa788ef9SJens Wiklanderendif
134b0104773SPascal Brand
135d2d2d58bSdeebee-v2libname = $(CFG_CRYPTOLIB_NAME)
136d2d2d58bSdeebee-v2libdir = $(CFG_CRYPTOLIB_DIR)
137b0104773SPascal Brandinclude mk/lib.mk
138b0104773SPascal Brand
139fa788ef9SJens Wiklanderbase-prefix :=
140fa788ef9SJens Wiklander
141b908c675SJens Wiklanderlibname = fdt
142b908c675SJens Wiklanderlibdir = core/lib/libfdt
143b908c675SJens Wiklanderinclude mk/lib.mk
144b908c675SJens Wiklander
145b3be2f66SJerome Forissierifeq ($(CFG_ZLIB),y)
146b3be2f66SJerome Forissierlibname = zlib
147b3be2f66SJerome Forissierlibdir = core/lib/zlib
148b3be2f66SJerome Forissierinclude mk/lib.mk
149b3be2f66SJerome Forissierendif
150b3be2f66SJerome Forissier
15102d307b7SJerome Forissierlibname = unw
15202d307b7SJerome Forissierlibdir = lib/libunw
15302d307b7SJerome Forissierinclude mk/lib.mk
15402d307b7SJerome Forissier
155b0104773SPascal Brand#
156b0104773SPascal Brand# Do main source
157b0104773SPascal Brand#
158bc420748SJens Wiklander
159b0104773SPascal Brandsubdirs = $(core-platform-subdirs) core
160b0104773SPascal Brandinclude mk/subdir.mk
161bc420748SJens Wiklander
162b0104773SPascal Brandinclude mk/compile.mk
163d5a887c8SJens Wiklander
16471315c30SAndrew F. Davisinclude $(if $(wildcard $(platform-dir)/link.mk), \
16571315c30SAndrew F. Davis		$(platform-dir)/link.mk, \
16671315c30SAndrew F. Davis		core/arch/$(ARCH)/kernel/link.mk)
167