xref: /optee_os/core/core.mk (revision 4c4212e9eef66fb249aa816ecba051be908dae4b)
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
20*4c4212e9SVincent Guittotifeq ($(CFG_SCMI_SCPFW),y)
21*4c4212e9SVincent Guittotinclude core/lib/scmi-server/conf.mk
22*4c4212e9SVincent Guittotendif
23*4c4212e9SVincent Guittot
2445082335SJens Wiklandercppflags$(sm)	+= -D__KERNEL__
2545082335SJens Wiklander
26a3911433SJerome Forissiercppflags$(sm)	+= -Icore/include
27b5569a68SPascal Brandcppflags$(sm)	+= -include $(conf-file)
2889fe7c3cSJerome Forissiercppflags$(sm)	+= -I$(out-dir)/core/include
29739804b5SJens Wiklandercppflags$(sm)	+= $(core-platform-cppflags)
30739804b5SJens Wiklandercflags$(sm)	+= $(core-platform-cflags)
3145507d10SKhoa Hoang
3245507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR) := -fstack-protector
3345507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_STRONG) := -fstack-protector-strong
3445507d10SKhoa Hoangcore-stackp-cflags-$(CFG_CORE_STACK_PROTECTOR_ALL) := -fstack-protector-all
3545507d10SKhoa Hoangcflags$(sm)	+= $(core-stackp-cflags-y)
3645507d10SKhoa Hoang
37be715239SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_UNDEFINED),y)
38be715239SJens Wiklandercflags$(sm)	+= -fsanitize=undefined
39be715239SJens Wiklanderendif
401d171f95SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_KADDRESS),y)
411d171f95SJens Wiklanderifeq ($(CFG_ASAN_SHADOW_OFFSET),)
421d171f95SJens Wiklander$(error error: CFG_CORE_SANITIZE_KADDRESS not supported by platform (flavor))
431d171f95SJens Wiklanderendif
4498d863a5SJerome Forissierifeq ($(COMPILER),clang)
4598d863a5SJerome Forissier$(error error: CFG_CORE_SANITIZE_KADDRESS not supported with Clang)
4698d863a5SJerome Forissierendif
471d171f95SJens Wiklandercflags_kasan	+= -fsanitize=kernel-address \
481d171f95SJens Wiklander		   -fasan-shadow-offset=$(CFG_ASAN_SHADOW_OFFSET)\
491d171f95SJens Wiklander		   --param asan-stack=1 --param asan-globals=1 \
501d171f95SJens Wiklander		   --param asan-instrumentation-with-call-threshold=0
511d171f95SJens Wiklandercflags$(sm)	+= $(cflags_kasan)
521d171f95SJens Wiklanderendif
53e2f03e07SJerome Forissierifeq ($(CFG_CORE_DEBUG_CHECK_STACKS),y)
54e2f03e07SJerome Forissierfinstrument-functions := $(call cc-option,-finstrument-functions)
55e2f03e07SJerome Forissierifeq (,$(finstrument-functions))
56e2f03e07SJerome Forissier$(error -finstrument-functions not supported)
57e2f03e07SJerome Forissierendif
58e2f03e07SJerome Forissiercflags$(sm) += $(finstrument-functions)
59e2f03e07SJerome Forissierendif
60099918f6SSumit Gargifeq ($(CFG_SYSCALL_FTRACE),y)
61099918f6SSumit Gargcflags$(sm)	+= -pg
62099918f6SSumit Gargendif
63739804b5SJens Wiklanderaflags$(sm)	+= $(core-platform-aflags)
64b0104773SPascal Brand
658a1e7b89SJerome Forissiercppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL)
66156fe685SPascal Brandifeq ($(CFG_TEE_CORE_MALLOC_DEBUG),y)
67156fe685SPascal Brandcppflags$(sm) += -DENABLE_MDBG=1
68156fe685SPascal Brandendif
6999eee037SEtienne Carriereifneq ($(CFG_TEE_CORE_DEBUG),y)
7099eee037SEtienne Carrierecppflags$(sm)  += -DNDEBUG
7199eee037SEtienne Carriereendif
72b0104773SPascal Brand
73dd22da8eSJens Wiklandercppflags$(sm)	+= -Ildelf/include
74b0104773SPascal Brandcppflags$(sm)	+= -Ilib/libutee/include
75b0104773SPascal Brand
768aeb6c94SJens Wiklanderifeq ($(filter y, $(CFG_CORE_DYN_SHM) $(CFG_CORE_RESERVED_SHM)),)
778aeb6c94SJens Wiklander$(error error: No shared memory configured)
788aeb6c94SJens Wiklanderendif
798aeb6c94SJens Wiklander
80fe52b1f5SJerome Forissier# Tell all libraries and sub-directories (included below) that we have a
81fe52b1f5SJerome Forissier# configuration file
82fe52b1f5SJerome Forissier
83b5569a68SPascal Brandconf-file := $(out-dir)/include/generated/conf.h
84b5569a68SPascal Brandconf-mk-file := $(out-dir)/conf.mk
85b924c494SJens Wiklanderconf-cmake-file := $(out-dir)/conf.cmake
86dde0e235Setienne carriere$(conf-file): $(conf-mk-file)
87dde0e235Setienne carriere
88fe52b1f5SJerome Forissiercleanfiles += $(conf-file)
89dde0e235Setienne carrierecleanfiles += $(conf-mk-file)
9040015a64SJerome Forissiercleanfiles += $(conf-cmake-file)
91fe52b1f5SJerome Forissier
92fe52b1f5SJerome Forissier$(conf-file): FORCE
93fe52b1f5SJerome Forissier	$(call check-conf-h)
94fe52b1f5SJerome Forissier
95dde0e235Setienne carriere$(conf-mk-file):  FORCE
963354f9b2SJerome Forissier	$(call check-conf-mk)
97dde0e235Setienne carriere
98b924c494SJens Wiklander$(conf-cmake-file):  FORCE
99b924c494SJens Wiklander	$(call check-conf-cmake)
100b924c494SJens Wiklander
101b0104773SPascal Brand#
102b0104773SPascal Brand# Do libraries
103b0104773SPascal Brand#
104b0104773SPascal Brand
105b0104773SPascal Brand# Set a prefix to avoid conflicts with user TAs that will use the same
106b0104773SPascal Brand# source but with different flags below
107b0104773SPascal Brandbase-prefix := $(sm)-
108b0104773SPascal Brandlibname = utils
109b0104773SPascal Brandlibdir = lib/libutils
110b0104773SPascal Brandinclude mk/lib.mk
111b0104773SPascal Brand
11218dd462bSJens Wiklander# CFG_CRYPTOLIB_NAME must not be changed beyond this line
11318dd462bSJens WiklanderCFG_CRYPTOLIB_NAME_$(CFG_CRYPTOLIB_NAME) := y
114e789ada3SJens Wiklander
115fcd21d9eSJens Wiklanderifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt)
116e789ada3SJens Wiklander# We're compiling mbedtls too, but with a limited configuration which only
117e789ada3SJens Wiklander# provides the MPI routines
118e789ada3SJens Wiklanderlibname = mbedtls
119e789ada3SJens Wiklanderlibdir = lib/libmbedtls
120e789ada3SJens Wiklanderinclude mk/lib.mk
121fcd21d9eSJens Wiklanderendif #tomcrypt
122e789ada3SJens Wiklander
12377327d7aSEdison Aiifeq ($(CFG_CRYPTOLIB_NAME),mbedtls)
12477327d7aSEdison Ai$(call force,CFG_CRYPTO_RSASSA_NA1,n,not supported by mbedtls)
125884462feSJens Wiklanderlibname = tomcrypt
126884462feSJens Wiklanderlibdir = core/lib/libtomcrypt
127884462feSJens Wiklanderbase-prefix :=
128884462feSJens Wiklanderinclude mk/lib.mk
129884462feSJens Wiklanderbase-prefix := $(sm)-
13077327d7aSEdison Aiendif
13177327d7aSEdison Ai
132fa788ef9SJens Wiklanderifeq ($(firstword $(subst /, ,$(CFG_CRYPTOLIB_DIR))),core)
133fa788ef9SJens Wiklander# If a library can be compiled for both core and user space a base-prefix
134fa788ef9SJens Wiklander# is needed in order to avoid conflicts in the output. However, if the
135fa788ef9SJens Wiklander# library resides under core then it can't be compiled to user space.
136b0104773SPascal Brandbase-prefix :=
137fa788ef9SJens Wiklanderendif
138b0104773SPascal Brand
139d2d2d58bSdeebee-v2libname = $(CFG_CRYPTOLIB_NAME)
140d2d2d58bSdeebee-v2libdir = $(CFG_CRYPTOLIB_DIR)
141b0104773SPascal Brandinclude mk/lib.mk
142b0104773SPascal Brand
143fa788ef9SJens Wiklanderbase-prefix :=
144fa788ef9SJens Wiklander
145b908c675SJens Wiklanderlibname = fdt
146b908c675SJens Wiklanderlibdir = core/lib/libfdt
147b908c675SJens Wiklanderinclude mk/lib.mk
148b908c675SJens Wiklander
149b3be2f66SJerome Forissierifeq ($(CFG_ZLIB),y)
150b3be2f66SJerome Forissierlibname = zlib
151b3be2f66SJerome Forissierlibdir = core/lib/zlib
152b3be2f66SJerome Forissierinclude mk/lib.mk
153b3be2f66SJerome Forissierendif
154b3be2f66SJerome Forissier
15502d307b7SJerome Forissierlibname = unw
15602d307b7SJerome Forissierlibdir = lib/libunw
15702d307b7SJerome Forissierinclude mk/lib.mk
15802d307b7SJerome Forissier
159*4c4212e9SVincent Guittotifeq ($(CFG_SCMI_SCPFW),y)
160*4c4212e9SVincent Guittotlibname = scmi-server
161*4c4212e9SVincent Guittotlibdir = core/lib/scmi-server
162*4c4212e9SVincent Guittotinclude mk/lib.mk
163*4c4212e9SVincent Guittotendif
164*4c4212e9SVincent Guittot
165b0104773SPascal Brand#
166b0104773SPascal Brand# Do main source
167b0104773SPascal Brand#
168bc420748SJens Wiklander
169b0104773SPascal Brandsubdirs = $(core-platform-subdirs) core
170b0104773SPascal Brandinclude mk/subdir.mk
171bc420748SJens Wiklander
172b0104773SPascal Brandinclude mk/compile.mk
173d5a887c8SJens Wiklander
17471315c30SAndrew F. Davisinclude $(if $(wildcard $(platform-dir)/link.mk), \
17571315c30SAndrew F. Davis		$(platform-dir)/link.mk, \
17671315c30SAndrew F. Davis		core/arch/$(ARCH)/kernel/link.mk)
177