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