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 20# Config flags from mk/config.mk 21cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) 22cppflags$(sm) += -DCFG_TEE_CORE_USER_MEM_DEBUG=$(CFG_TEE_CORE_USER_MEM_DEBUG) 23cppflags$(sm) += -DENABLE_MDBG=$(CFG_TEE_TA_MALLOC_DEBUG) 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 += $(out-dir)/core/include/generated/conf.h 45incfiles-extra-host += $(out-dir)/core/conf.mk 46incfiles-extra-host += core/include/tee/tee_fs_key_manager.h 47incfiles-extra-host += core/include/signed_hdr.h 48 49# 50# Copy lib files and exported headers from each lib 51# 52 53define copy-file 54$2/$$(notdir $1): $1 55 @set -e; \ 56 mkdir -p $$(dir $$@) ; \ 57 $(cmd-echo-silent) ' INSTALL $$@' ; \ 58 cp $$< $$@ 59 60cleanfiles += $2/$$(notdir $1) 61all: $2/$$(notdir $1) 62endef 63 64# Copy the .a files 65$(foreach f, $(libfiles), \ 66 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib))) 67 68# Copy .mk files 69ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \ 70 $(wildcard core/arch/$(ARCH)/plat-$(PLATFORM)/platform_flags.mk) \ 71 $(wildcard ta/arch/$(ARCH)/link.mk) \ 72 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# Special treatment for ta/arch/$(ARCH)/$(ARCH).mk 78arch-arch-mk := $(out-dir)/export-$(sm)/mk/arch.mk 79$(arch-arch-mk): ta/arch/$(ARCH)/$(ARCH).mk 80 @set -e; \ 81 mkdir -p $(dir $@) ; \ 82 $(cmd-echo-silent) ' INSTALL $@' ; \ 83 cp $< $@ 84 85cleanfiles += $(arch-arch-mk) 86all: $(arch-arch-mk) 87 88# Copy the .h files for TAs 89define copy-incdir 90sf := $(subst $1/, , $(shell find $1 -name "*.h")) 91$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \ 92 $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h))))))) 93endef 94$(foreach d, $(incdirs$(sm)), \ 95 $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/include))) 96 97# Copy the .h files needed by host 98$(foreach d, $(incdirs-host), \ 99 $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include))) 100$(foreach f, $(incfiles-extra-host), \ 101 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include))) 102 103# Copy the src files 104ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \ 105 $(wildcard ta/arch/$(ARCH)/ta.ld.S) 106$(foreach f, $(ta-srcfiles), \ 107 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src))) 108 109# Copy keys 110ta-keys = keys/default_ta.pem 111$(foreach f, $(ta-keys), \ 112 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys))) 113 114# Copy the scripts 115ta-scripts = $(wildcard scripts/sign.py) 116$(foreach f, $(ta-scripts), \ 117 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts))) 118 119# Create config file 120conf-file := $(out-dir)/export-$(sm)/mk/conf.mk 121sm-$(conf-file) := $(sm) 122# The file is only created if it doesn't exist, this is currently OK as the 123# content of the file is static for a given TA dev kit. 124$(conf-file): 125 @$(cmd-echo-silent) ' GEN ' $@ 126 $(q)echo sm := $(sm-$(@)) > $@ 127 $(q)echo sm-$(sm-$(@)) := y >> $@ 128 $(q)echo CFG_ARM32_$(sm-$(@)) := $(CFG_ARM32_$(sm-$(@))) >> $@ 129 $(q)echo CFG_ARM64_$(sm-$(@)) := $(CFG_ARM64_$(sm-$(@))) >> $@ 130 131cleanfiles := $(cleanfiles) $(conf-file) 132all: $(conf-file) 133