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