1include mk/cleanvars.mk
2
3# Set $(sm) as the name of the in tree TA being built, for instance "avb" or "pkcs11"
4sm := $(lastword $(subst /, ,$(dir $(ta-mk-file))))
5sm-$(sm) := y
6
7# Select TA target (aka TA dev kit, when delivered)
8ta-target := $(strip $(if $(CFG_USER_TA_TARGET_$(sm)), \
9		$(filter $(CFG_USER_TA_TARGET_$(sm)), $(ta-targets)), \
10		$(default-user-ta-target)))
11
12ifeq ($(ta-target),ta_arm32)
13arch-bits-$(sm) := 32
14endif
15ifeq ($(ta-target),ta_arm64)
16arch-bits-$(sm) := 64
17endif
18
19ta-dev-kit-dir$(sm) := $(out-dir)/export-$(ta-target)
20link-out-dir$(sm) := $(out-dir)/$(patsubst %/,%, $(dir $(ta-mk-file)))
21
22# Default if ta-mk-file defines none
23user-ta-version := 0
24
25include $(ta-mk-file)
26ifeq ($(user-ta-uuid),)
27$(error user-ta-uuid missing in $(ta-mk-file))
28endif
29
30# Inherit compiler and flags from TA target
31CROSS_COMPILE_$(sm)	:= $(CROSS_COMPILE_$(ta-target))
32COMPILER_$(sm)		:= $(COMPILER_$(ta-target))
33include mk/$(COMPILER_$(sm)).mk
34
35cppflags$(sm)	:= $(cppflags$(ta-target)) $(CPPFLAGS_$(ta-target)) \
36			-I$(ta-dev-kit-dir$(sm))/include
37ifeq ($(CFG_TA_OPTEE_CORE_API_COMPAT_1_1),y)
38cppflags$(sm)	+= -D__OPTEE_CORE_API_COMPAT_1_1=1
39endif
40cflags$(sm)	:= $(cflags$(ta-target)) $(CFLAGS_$(ta-target))
41aflags$(sm)	:= $(aflags$(ta-target))
42
43ifeq ($(CFG_ULIBS_SHARED),y)
44# For now, do not link in-tree TAs against shared libraries
45link-ldflags$(sm) := -static
46endif
47
48libdirs  = $(ta-dev-kit-dir$(sm))/lib
49libnames = utils utee
50ifeq ($(CFG_TA_MBEDTLS),y)
51libnames += mbedtls
52endif
53libdeps = $(addsuffix .a, $(addprefix $(libdirs)/lib, $(libnames)))
54
55subdirs = $(patsubst %/,%,$(dir $(ta-mk-file)))
56include mk/subdir.mk
57
58spec-out-dir := $(link-out-dir$(sm))
59spec-srcs += $(ta-dev-kit-dir$(sm))/src/user_ta_header.c
60ifeq ($(ta-target),ta_arm32)
61spec-srcs += $(ta-dev-kit-dir$(sm))/src/ta_entry_a32.S
62endif
63
64# Install TA headers before in-tree TAs can be compiled
65additional-compile-deps := $(ta_dev_kit-files-include)
66include mk/compile.mk
67# Install TA libraries before in-tree TAs can be linked
68additional-link-deps := $(ta_dev_kit-files-lib)
69include  ta/arch/$(ARCH)/link.mk
70
71ta_dev_kit: $(out-dir)/export-$(ta-target)/ta/$(user-ta-uuid).ta
72
73$(out-dir)/export-$(ta-target)/ta/$(user-ta-uuid).ta: $(link-out-dir$(sm))/$(user-ta-uuid).ta
74	$(q)mkdir -p $(dir $@)
75	@$(cmd-echo-silent) '  INSTALL $@'
76	$(q)cp -P $< $@
77
78cleanfiles += $(out-dir)/export-$(ta-target)/ta/$(user-ta-uuid).ta
79