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