1include mk/cleanvars.mk 2 3# Set current submodule (used for module specific flags compile result etc) 4sm := user_ta 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 14cppflags$(sm) += $(platform-cppflags) $(user_ta-platform-cppflags) 15cflags$(sm) += $(platform-cflags) $(user_ta-platform-cflags) 16aflags$(sm) += $(platform-aflags) $(user_ta-platform-aflags) 17 18# Config flags from mk/config.mk 19cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) 20cppflags$(sm) += -DCFG_TEE_CORE_USER_MEM_DEBUG=$(CFG_TEE_CORE_USER_MEM_DEBUG) 21 22 23base-prefix := $(sm)- 24 25libname = utils 26libdir = lib/libutils 27include mk/lib.mk 28 29libname = mpa 30libdir = lib/libmpa 31include mk/lib.mk 32 33libname = utee 34libdir = lib/libutee 35include mk/lib.mk 36 37base-prefix := 38 39incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm))) 40incfiles-extra-host := lib/libutils/ext/include/compiler.h 41incfiles-extra-host += lib/libutils/ext/include/util.h 42incfiles-extra-host += $(out-dir)/core/include/generated/conf.h 43incfiles-extra-host += $(out-dir)/core/conf.mk 44incfiles-extra-host += core/include/tee/tee_fs_key_manager.h 45 46# 47# Copy lib files and exported headers from each lib 48# 49 50define copy-file 51$2/$$(notdir $1): $1 52 @set -e; \ 53 mkdir -p $$(dir $$@) ; \ 54 $(cmd-echo-silent) ' INSTALL $$@' ; \ 55 cp $$< $$@ 56 57cleanfiles += $2/$$(notdir $1) 58all: $2/$$(notdir $1) 59endef 60 61# Copy the .a files 62$(foreach f, $(libfiles), \ 63 $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/lib))) 64 65# Copy .mk files 66ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \ 67 $(wildcard core/arch/$(ARCH)/plat-$(PLATFORM)/platform_flags.mk) \ 68 $(wildcard ta/arch/$(ARCH)/link.mk) \ 69 ta/mk/ta_dev_kit.mk 70 71$(foreach f, $(ta-mkfiles), \ 72 $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/mk))) 73 74# Special treatment for ta/arch/$(ARCH)/$(ARCH).mk 75arch-arch-mk := $(out-dir)/export-user_ta/mk/arch.mk 76$(arch-arch-mk): ta/arch/$(ARCH)/$(ARCH).mk 77 @set -e; \ 78 mkdir -p $(dir $@) ; \ 79 $(cmd-echo-silent) ' INSTALL $@' ; \ 80 cp $< $@ 81 82cleanfiles += $(arch-arch-mk) 83all: $(arch-arch-mk) 84 85# Copy the .h files for TAs 86define copy-incdir 87sf := $(subst $1/, , $(shell find $1 -name "*.h")) 88$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \ 89 $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h))))))) 90endef 91$(foreach d, $(incdirs$(sm)), \ 92 $(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/include))) 93 94# Copy the .h files needed by host 95$(foreach d, $(incdirs-host), \ 96 $(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/host_include))) 97$(foreach f, $(incfiles-extra-host), \ 98 $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/host_include))) 99 100# Copy the src files 101ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \ 102 $(wildcard ta/arch/$(ARCH)/user_ta_elf_arm.lds) 103$(foreach f, $(ta-srcfiles), \ 104 $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/src))) 105 106# Copy keys 107ta-keys = keys/default_ta.pem 108$(foreach f, $(ta-keys), \ 109 $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/keys))) 110 111# Copy the scripts 112ta-scripts = $(wildcard scripts/sign.py) 113$(foreach f, $(ta-scripts), \ 114 $(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/scripts))) 115