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_FTRACE_SUPPORT 39ta-mk-file-export-vars-$(sm) += CFG_UNWIND 40ta-mk-file-export-vars-$(sm) += CFG_TA_MCOUNT 41ta-mk-file-export-vars-$(sm) += CFG_CORE_TPM_EVENT_LOG 42 43# Expand platform flags here as $(sm) will change if we have several TA 44# targets. Platform flags should not change after inclusion of ta/ta.mk. 45cppflags$(sm) := $(platform-cppflags) $($(sm)-platform-cppflags) 46cflags$(sm) := $(platform-cflags) $($(sm)-platform-cflags) 47aflags$(sm) := $(platform-aflags) $($(sm)-platform-aflags) 48 49# Changes to cppflags$(sm) will only affect how TA dev kit libraries are 50# compiled, these flags are not propagated to the TA 51cppflags$(sm) += -include $(conf-file) 52cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) 53 54ifeq ($(ta-target),ta_arm32) 55arm32-user-sysreg-txt = lib/libutee/arch/arm/arm32_user_sysreg.txt 56arm32-user-sysregs-$(arm32-user-sysreg-txt)-h := arm32_user_sysreg.h 57arm32-user-sysregs += $(arm32-user-sysreg-txt) 58 59arm32-user-sysregs-out := $(out-dir)/include/generated 60 61define process-arm32-user-sysreg 62FORCE-GENSRC$(sm): $$(arm32-user-sysregs-out)/$$(arm32-user-sysregs-$(1)-h) 63cleanfiles := $$(cleanfiles) \ 64 $$(arm32-user-sysregs-out)/$$(arm32-user-sysregs-$(1)-h) 65 66$$(arm32-user-sysregs-out)/$$(arm32-user-sysregs-$(1)-h): \ 67 $(1) scripts/arm32_sysreg.py 68 @$(cmd-echo-silent) ' GEN $$@' 69 $(q)mkdir -p $$(dir $$@) 70 $(q)scripts/arm32_sysreg.py --guard __$$(arm32-user-sysregs-$(1)-h) \ 71 < $$< > $$@ 72 73endef #process-arm32-user-sysreg 74 75$(foreach sr, $(arm32-user-sysregs), \ 76 $(eval $(call process-arm32-user-sysreg,$(sr)))) 77 78cppflags$(sm) += -I$(arm32-user-sysregs-out) 79endif 80 81base-prefix := $(sm)- 82 83libname = utils 84libdir = lib/libutils 85libuuid = 71855bba-6055-4293-a63f-b0963a737360 86include mk/lib.mk 87 88libname = mbedtls 89libdir = lib/libmbedtls 90libuuid = 87bb6ae8-4b1d-49fe-9986-2b966132c309 91libl = utils 92include mk/lib.mk 93ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS 94 95libname = utee 96libdir = lib/libutee 97libuuid = 527f1a47-b92c-4a74-95bd-72f19f4a6f74 98libl = mbedtls utils 99include mk/lib.mk 100 101libname = dl 102libdir = lib/libdl 103libuuid = be807bbd-81e1-4dc4-bd99-3d363f240ece 104libl = utee utils 105include mk/lib.mk 106 107base-prefix := 108 109incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm))) 110incfiles-extra-host := lib/libutils/ext/include/compiler.h 111incfiles-extra-host += lib/libutils/ext/include/util.h 112incfiles-extra-host += lib/libutils/ext/include/types_ext.h 113incfiles-extra-host += $(conf-file) 114incfiles-extra-host += $(conf-mk-file) 115incfiles-extra-host += $(conf-cmake-file) 116incfiles-extra-host += core/include/tee/tee_fs_key_manager.h 117incfiles-extra-host += core/include/tee/fs_htree.h 118incfiles-extra-host += core/include/signed_hdr.h 119ifeq ($(ta-target),ta_arm32) 120incfiles-extra-host += $(out-dir)/include/generated/arm32_user_sysreg.h 121endif 122 123# 124# Copy lib files and exported headers from each lib 125# 126 127define copy-file 128$2/$$(notdir $1): $1 129 @set -e; \ 130 mkdir -p $$(dir $$@) ; \ 131 $(cmd-echo-silent) ' INSTALL $$@' ; \ 132 cp -P $$< $$@ 133 134cleanfiles += $2/$$(notdir $1) 135ta_dev_kit: $2/$$(notdir $1) 136ta_dev_kit-files += $2/$$(notdir $1) 137ta_dev_kit-files-$3 += $2/$$(notdir $1) 138endef 139 140# Copy the .a files 141$(foreach f, $(libfiles), \ 142 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib,lib))) 143 144# Copy .mk files 145ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/clang.mk mk/cleandirs.mk \ 146 ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \ 147 ta/mk/ta_dev_kit.mk 148 149$(foreach f, $(ta-mkfiles), \ 150 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk))) 151 152# Copy the .h files for TAs 153define copy-incdir 154sf := $(subst $1/, , $(shell find $1 -name "*.[hS]")) 155$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \ 156 $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))),$3))) 157endef 158$(foreach d, $(incdirs$(sm)), \ 159 $(eval $(call copy-incdir,$(d),$(out-dir)/export-$(sm)/include,include))) 160 161# Copy the .h files needed by host 162$(foreach d, $(incdirs-host), \ 163 $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include))) 164$(foreach f, $(incfiles-extra-host), \ 165 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include))) 166 167# Copy the src files 168ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c ta/arch/$(ARCH)/ta.ld.S 169ifeq ($(ta-target),ta_arm32) 170ta-srcfiles += ta/arch/$(ARCH)/ta_entry_a32.S 171endif 172$(foreach f, $(ta-srcfiles), \ 173 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src))) 174 175# Copy keys 176ta-keys = keys/default_ta.pem 177$(foreach f, $(ta-keys), \ 178 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys))) 179 180# Copy the scripts 181ta-scripts = scripts/sign_encrypt.py scripts/symbolize.py 182$(foreach f, $(ta-scripts), \ 183 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts))) 184 185# Create config file 186conf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk 187sm-$(conf-mk-file-export) := $(sm) 188define mk-file-export 189.PHONY: $(conf-mk-file-export) 190$(conf-mk-file-export): 191 @$$(cmd-echo-silent) ' CHK ' $$@ 192 $(q)echo sm := $$(sm-$(conf-mk-file-export)) > $$@.tmp 193 $(q)echo sm-$$(sm-$(conf-mk-file-export)) := y >> $$@.tmp 194 $(q)($$(foreach v, $$(ta-mk-file-export-vars-$$(sm-$(conf-mk-file-export))), \ 195 $$(if $$($$(v)),echo $$(v) := $$($$(v));,))) >> $$@.tmp 196 $(q)echo '$$(ta-mk-file-export-add-$$(sm-$(conf-mk-file-export)))' | sed 's/_nl_ */\n/g' >> $$@.tmp 197 $(q)$(call mv-if-changed,$$@.tmp,$$@) 198endef 199$(eval $(mk-file-export)) 200 201cleanfiles := $(cleanfiles) $(conf-mk-file-export) 202ta_dev_kit: $(conf-mk-file-export) 203 204all: ta_dev_kit 205