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