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