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