1include mk/cleanvars.mk 2 3# Set current submodule (used for module specific flags compile result etc) 4sm := $(ta-target) 5sm-$(sm) := y 6 7# Setup compiler for this sub module 8COMPILER_$(sm) ?= $(COMPILER) 9include mk/$(COMPILER_$(sm)).mk 10 11# 12# Config flags from mk/config.mk 13# 14 15ifeq ($(CFG_TA_MBEDTLS_SELF_TEST),y) 16$(sm)-platform-cppflags += -DMBEDTLS_SELF_TEST 17endif 18 19ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y) 20# Build malloc debug code into libutils: (mdbg_malloc(), mdbg_free(), 21# mdbg_check(), etc.). 22$(sm)-platform-cppflags += -DENABLE_MDBG=1 23endif 24 25# Keep CFG_TA_DYNLINK for backwards compatibility 26$(call force,CFG_TA_DYNLINK,y) 27 28# Config variables to be explicitly exported to the dev kit conf.mk 29ta-mk-file-export-vars-$(sm) += CFG_TA_FLOAT_SUPPORT 30ta-mk-file-export-vars-$(sm) += CFG_CACHE_API 31ta-mk-file-export-vars-$(sm) += CFG_SECURE_DATA_PATH 32ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS_SELF_TEST 33ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS 34ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS_MPI 35ta-mk-file-export-vars-$(sm) += CFG_SYSTEM_PTA 36ta-mk-file-export-vars-$(sm) += CFG_TA_DYNLINK 37ta-mk-file-export-vars-$(sm) += CFG_TEE_TA_LOG_LEVEL 38ta-mk-file-export-vars-$(sm) += CFG_TA_FTRACE_SUPPORT 39ta-mk-file-export-vars-$(sm) += CFG_UNWIND 40ta-mk-file-export-vars-$(sm) += CFG_TA_MCOUNT 41 42# Expand platform flags here as $(sm) will change if we have several TA 43# targets. Platform flags should not change after inclusion of ta/ta.mk. 44cppflags$(sm) := $(platform-cppflags) $($(sm)-platform-cppflags) 45cflags$(sm) := $(platform-cflags) $($(sm)-platform-cflags) 46aflags$(sm) := $(platform-aflags) $($(sm)-platform-aflags) 47 48# Changes to cppflags$(sm) will only affect how TA dev kit libraries are 49# compiled, these flags are not propagated to the TA 50cppflags$(sm) += -include $(conf-file) 51cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) 52 53base-prefix := $(sm)- 54 55libname = utils 56libdir = lib/libutils 57libuuid = 71855bba-6055-4293-a63f-b0963a737360 58include mk/lib.mk 59 60CFG_TA_MBEDTLS_MPI ?= y 61ifeq ($(CFG_TA_MBEDTLS_MPI),y) 62mplib-for-utee = mbedtls 63$(call force,CFG_TA_MBEDTLS,y) 64else 65mplib-for-utee = mpa 66libname = mpa 67libdir = lib/libmpa 68libuuid = 39b498d9-1e1f-4ae0-a9e1-6d1caf8ec731 69libl = utils 70include mk/lib.mk 71endif 72 73ifeq ($(CFG_TA_MBEDTLS),y) 74libname = mbedtls 75libdir = lib/libmbedtls 76libuuid = 87bb6ae8-4b1d-49fe-9986-2b966132c309 77libl = utils 78include mk/lib.mk 79ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS 80endif 81 82libname = utee 83libdir = lib/libutee 84libuuid = 527f1a47-b92c-4a74-95bd-72f19f4a6f74 85libl = $(mplib-for-utee) utils 86include mk/lib.mk 87 88base-prefix := 89 90incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm))) 91incfiles-extra-host := lib/libutils/ext/include/compiler.h 92incfiles-extra-host += lib/libutils/ext/include/util.h 93incfiles-extra-host += lib/libutils/ext/include/types_ext.h 94incfiles-extra-host += $(conf-file) 95incfiles-extra-host += $(conf-mk-file) 96incfiles-extra-host += $(conf-cmake-file) 97incfiles-extra-host += core/include/tee/tee_fs_key_manager.h 98incfiles-extra-host += core/include/tee/fs_htree.h 99incfiles-extra-host += core/include/signed_hdr.h 100 101# 102# Copy lib files and exported headers from each lib 103# 104 105define copy-file 106$2/$$(notdir $1): $1 107 @set -e; \ 108 mkdir -p $$(dir $$@) ; \ 109 $(cmd-echo-silent) ' INSTALL $$@' ; \ 110 cp -P $$< $$@ 111 112cleanfiles += $2/$$(notdir $1) 113ta_dev_kit: $2/$$(notdir $1) 114ta_dev_kit-files += $2/$$(notdir $1) 115ta_dev_kit-files-$3 += $2/$$(notdir $1) 116endef 117 118# Copy the .a files 119$(foreach f, $(libfiles), \ 120 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib,lib))) 121 122# Copy .mk files 123ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/cleandirs.mk \ 124 ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \ 125 ta/mk/ta_dev_kit.mk 126 127$(foreach f, $(ta-mkfiles), \ 128 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk))) 129 130# Copy the .h files for TAs 131define copy-incdir 132sf := $(subst $1/, , $(shell find $1 -name "*.[hS]")) 133$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \ 134 $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))),$3))) 135endef 136$(foreach d, $(incdirs$(sm)), \ 137 $(eval $(call copy-incdir,$(d),$(out-dir)/export-$(sm)/include,include))) 138 139# Copy the .h files needed by host 140$(foreach d, $(incdirs-host), \ 141 $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include))) 142$(foreach f, $(incfiles-extra-host), \ 143 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include))) 144 145# Copy the src files 146ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c ta/arch/$(ARCH)/ta.ld.S 147ifeq ($(ta-target),ta_arm32) 148ta-srcfiles += ta/arch/$(ARCH)/ta_entry_a32.S 149endif 150$(foreach f, $(ta-srcfiles), \ 151 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src))) 152 153# Copy keys 154ta-keys = keys/default_ta.pem 155$(foreach f, $(ta-keys), \ 156 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys))) 157 158# Copy the scripts 159ta-scripts = scripts/sign.py scripts/symbolize.py 160$(foreach f, $(ta-scripts), \ 161 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts))) 162 163# Create config file 164conf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk 165sm-$(conf-mk-file-export) := $(sm) 166define mk-file-export 167.PHONY: $(conf-mk-file-export) 168$(conf-mk-file-export): 169 @$$(cmd-echo-silent) ' CHK ' $$@ 170 $(q)echo sm := $$(sm-$(conf-mk-file-export)) > $$@.tmp 171 $(q)echo sm-$$(sm-$(conf-mk-file-export)) := y >> $$@.tmp 172 $(q)($$(foreach v, $$(ta-mk-file-export-vars-$$(sm-$(conf-mk-file-export))), \ 173 $$(if $$($$(v)),echo $$(v) := $$($$(v));,))) >> $$@.tmp 174 $(q)echo '$$(ta-mk-file-export-add-$$(sm-$(conf-mk-file-export)))' | sed 's/_nl_ */\n/g' >> $$@.tmp 175 $(q)$(call mv-if-changed,$$@.tmp,$$@) 176endef 177$(eval $(mk-file-export)) 178 179cleanfiles := $(cleanfiles) $(conf-mk-file-export) 180ta_dev_kit: $(conf-mk-file-export) 181 182all: ta_dev_kit 183