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