xref: /optee_os/core/core.mk (revision 099918f6744c37ce693c38562f11466b19d573c9)
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
110de9a5fbSJens Wiklanderinclude core/arch/$(ARCH)/$(ARCH).mk
12b0104773SPascal Brand
139fc53171SJerome ForissierPLATFORM_$(PLATFORM) := y
149fc53171SJerome ForissierPLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y
159fc53171SJerome Forissier
166b385aafSJerome Forissier$(eval $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA))
173d3ad63dSJens Wiklanderinclude core/crypto.mk
18a884c935SJens Wiklander
191b4eb4f5SJens Wiklander# Setup compiler for this sub module
201b4eb4f5SJens WiklanderCOMPILER_$(sm)		?= $(COMPILER)
211b4eb4f5SJens Wiklanderinclude mk/$(COMPILER_$(sm)).mk
221b4eb4f5SJens Wiklander
2345082335SJens Wiklandercppflags$(sm)	+= -D__KERNEL__
2445082335SJens Wiklander
25a3911433SJerome Forissiercppflags$(sm)	+= -Icore/include
26b5569a68SPascal Brandcppflags$(sm)	+= -include $(conf-file)
2789fe7c3cSJerome Forissiercppflags$(sm)	+= -I$(out-dir)/core/include
28739804b5SJens Wiklandercppflags$(sm)	+= $(core-platform-cppflags)
29739804b5SJens Wiklandercflags$(sm)	+= $(core-platform-cflags)
30be715239SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_UNDEFINED),y)
31be715239SJens Wiklandercflags$(sm)	+= -fsanitize=undefined
32be715239SJens Wiklanderendif
331d171f95SJens Wiklanderifeq ($(CFG_CORE_SANITIZE_KADDRESS),y)
341d171f95SJens Wiklanderifeq ($(CFG_ASAN_SHADOW_OFFSET),)
351d171f95SJens Wiklander$(error error: CFG_CORE_SANITIZE_KADDRESS not supported by platform (flavor))
361d171f95SJens Wiklanderendif
3798d863a5SJerome Forissierifeq ($(COMPILER),clang)
3898d863a5SJerome Forissier$(error error: CFG_CORE_SANITIZE_KADDRESS not supported with Clang)
3998d863a5SJerome Forissierendif
401d171f95SJens Wiklandercflags_kasan	+= -fsanitize=kernel-address \
411d171f95SJens Wiklander		   -fasan-shadow-offset=$(CFG_ASAN_SHADOW_OFFSET)\
421d171f95SJens Wiklander		   --param asan-stack=1 --param asan-globals=1 \
431d171f95SJens Wiklander		   --param asan-instrumentation-with-call-threshold=0
441d171f95SJens Wiklandercflags$(sm)	+= $(cflags_kasan)
451d171f95SJens Wiklanderendif
46*099918f6SSumit Gargifeq ($(CFG_SYSCALL_FTRACE),y)
47*099918f6SSumit Gargcflags$(sm)	+= -pg
48*099918f6SSumit Gargendif
49739804b5SJens Wiklanderaflags$(sm)	+= $(core-platform-aflags)
50b0104773SPascal Brand
518a1e7b89SJerome Forissiercppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL)
52156fe685SPascal Brandifeq ($(CFG_TEE_CORE_MALLOC_DEBUG),y)
53156fe685SPascal Brandcppflags$(sm) += -DENABLE_MDBG=1
54156fe685SPascal Brandendif
5599eee037SEtienne Carriereifneq ($(CFG_TEE_CORE_DEBUG),y)
5699eee037SEtienne Carrierecppflags$(sm)  += -DNDEBUG
5799eee037SEtienne Carriereendif
58b0104773SPascal Brand
59dd22da8eSJens Wiklandercppflags$(sm)	+= -Ildelf/include
60b0104773SPascal Brandcppflags$(sm)	+= -Ilib/libutee/include
61b0104773SPascal Brand
628aeb6c94SJens Wiklanderifeq ($(filter y, $(CFG_CORE_DYN_SHM) $(CFG_CORE_RESERVED_SHM)),)
638aeb6c94SJens Wiklander$(error error: No shared memory configured)
648aeb6c94SJens Wiklanderendif
658aeb6c94SJens Wiklander
66fe52b1f5SJerome Forissier# Tell all libraries and sub-directories (included below) that we have a
67fe52b1f5SJerome Forissier# configuration file
68fe52b1f5SJerome Forissier
69b5569a68SPascal Brandconf-file := $(out-dir)/include/generated/conf.h
70b5569a68SPascal Brandconf-mk-file := $(out-dir)/conf.mk
71b924c494SJens Wiklanderconf-cmake-file := $(out-dir)/conf.cmake
72dde0e235Setienne carriere$(conf-file): $(conf-mk-file)
73dde0e235Setienne carriere
74fe52b1f5SJerome Forissiercleanfiles += $(conf-file)
75dde0e235Setienne carrierecleanfiles += $(conf-mk-file)
76fe52b1f5SJerome Forissier
77fe52b1f5SJerome Forissier$(conf-file): FORCE
78fe52b1f5SJerome Forissier	$(call check-conf-h)
79fe52b1f5SJerome Forissier
80dde0e235Setienne carriere$(conf-mk-file):  FORCE
813354f9b2SJerome Forissier	$(call check-conf-mk)
82dde0e235Setienne carriere
83b924c494SJens Wiklander$(conf-cmake-file):  FORCE
84b924c494SJens Wiklander	$(call check-conf-cmake)
85b924c494SJens Wiklander
86b0104773SPascal Brand#
87b0104773SPascal Brand# Do libraries
88b0104773SPascal Brand#
89b0104773SPascal Brand
90b0104773SPascal Brand# Set a prefix to avoid conflicts with user TAs that will use the same
91b0104773SPascal Brand# source but with different flags below
92b0104773SPascal Brandbase-prefix := $(sm)-
93b0104773SPascal Brandlibname = utils
94b0104773SPascal Brandlibdir = lib/libutils
95b0104773SPascal Brandinclude mk/lib.mk
96b0104773SPascal Brand
9718dd462bSJens Wiklander# CFG_CRYPTOLIB_NAME must not be changed beyond this line
9818dd462bSJens WiklanderCFG_CRYPTOLIB_NAME_$(CFG_CRYPTOLIB_NAME) := y
99e789ada3SJens Wiklander
100fcd21d9eSJens Wiklanderifeq ($(CFG_CRYPTOLIB_NAME),tomcrypt)
101fcd21d9eSJens Wiklanderifeq ($(CFG_CORE_MBEDTLS_MPI),y)
102e789ada3SJens Wiklander# We're compiling mbedtls too, but with a limited configuration which only
103e789ada3SJens Wiklander# provides the MPI routines
104e789ada3SJens Wiklanderlibname = mbedtls
105e789ada3SJens Wiklanderlibdir = lib/libmbedtls
106e789ada3SJens Wiklanderinclude mk/lib.mk
107e789ada3SJens Wiklanderelse
108b0104773SPascal Brandlibname = mpa
109b0104773SPascal Brandlibdir = lib/libmpa
110b0104773SPascal Brandinclude mk/lib.mk
111e789ada3SJens Wiklanderendif
112fcd21d9eSJens Wiklanderendif #tomcrypt
113e789ada3SJens Wiklander
11477327d7aSEdison Aiifeq ($(CFG_CRYPTOLIB_NAME),mbedtls)
11577327d7aSEdison Ai$(call force,CFG_CRYPTO_RSASSA_NA1,n,not supported by mbedtls)
116884462feSJens Wiklanderlibname = tomcrypt
117884462feSJens Wiklanderlibdir = core/lib/libtomcrypt
118884462feSJens Wiklanderbase-prefix :=
119884462feSJens Wiklanderinclude mk/lib.mk
120884462feSJens Wiklanderbase-prefix := $(sm)-
12177327d7aSEdison Aiendif
12277327d7aSEdison Ai
123fa788ef9SJens Wiklanderifeq ($(firstword $(subst /, ,$(CFG_CRYPTOLIB_DIR))),core)
124fa788ef9SJens Wiklander# If a library can be compiled for both core and user space a base-prefix
125fa788ef9SJens Wiklander# is needed in order to avoid conflicts in the output. However, if the
126fa788ef9SJens Wiklander# library resides under core then it can't be compiled to user space.
127b0104773SPascal Brandbase-prefix :=
128fa788ef9SJens Wiklanderendif
129b0104773SPascal Brand
130d2d2d58bSdeebee-v2libname = $(CFG_CRYPTOLIB_NAME)
131d2d2d58bSdeebee-v2libdir = $(CFG_CRYPTOLIB_DIR)
132b0104773SPascal Brandinclude mk/lib.mk
133b0104773SPascal Brand
134fa788ef9SJens Wiklanderbase-prefix :=
135fa788ef9SJens Wiklander
136b908c675SJens Wiklanderifeq ($(CFG_DT),y)
137b908c675SJens Wiklanderlibname = fdt
138b908c675SJens Wiklanderlibdir = core/lib/libfdt
139b908c675SJens Wiklanderinclude mk/lib.mk
140b908c675SJens Wiklanderendif
141b908c675SJens Wiklander
142b3be2f66SJerome Forissierifeq ($(CFG_ZLIB),y)
143b3be2f66SJerome Forissierlibname = zlib
144b3be2f66SJerome Forissierlibdir = core/lib/zlib
145b3be2f66SJerome Forissierinclude mk/lib.mk
146b3be2f66SJerome Forissierendif
147b3be2f66SJerome Forissier
148b0104773SPascal Brand#
149b0104773SPascal Brand# Do main source
150b0104773SPascal Brand#
151bc420748SJens Wiklander
152b0104773SPascal Brandsubdirs = $(core-platform-subdirs) core
153b0104773SPascal Brandinclude mk/subdir.mk
154bc420748SJens Wiklander
155b0104773SPascal Brandinclude mk/compile.mk
156d5a887c8SJens Wiklander
15771315c30SAndrew F. Davisinclude $(if $(wildcard $(platform-dir)/link.mk), \
15871315c30SAndrew F. Davis		$(platform-dir)/link.mk, \
15971315c30SAndrew F. Davis		core/arch/$(ARCH)/kernel/link.mk)
160