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