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