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