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