1# Normally this makefile shouldn't be called directly and we expect the output
2# path to be on a certain location to fit together with the other OP-TEE
3# gits and helper scripts.
4
5include ../scripts/common.mk
6out-dir := $(call strip-trailing-slashes-and-dots,$(O))
7ifeq ($(out-dir),)
8$(error invalid output directory (O=$(O)))
9endif
10
11include $(TA_DEV_KIT_DIR)/mk/conf.mk
12
13# Prevent use of LDFLAGS from the environment. For example, yocto exports
14# LDFLAGS that are suitable for the client applications, not for TAs
15LDFLAGS=
16
17TA_DIRS := create_fail_test \
18	   crypt \
19	   os_test_lib \
20	   os_test_lib_dl \
21	   os_test \
22	   rpc_test \
23	   sims \
24	   miss \
25	   sims_keepalive \
26	   storage \
27	   storage2 \
28	   concurrent \
29	   concurrent_large \
30	   storage_benchmark \
31	   crypto_perf \
32	   socket \
33	   supp_plugin \
34	   large \
35	   subkey1 \
36	   subkey2
37
38ifeq ($(CFG_SECURE_DATA_PATH),y)
39TA_DIRS += sdp_basic
40endif
41
42ifeq ($(CFG_TA_BTI),y)
43TA_DIRS += bti_test
44endif
45
46.PHONY: all
47all: ta
48
49.PHONY: ta
50ta:
51
52define add-ta-target
53.PHONY: ta-$(1)
54ta-$(1):
55	$(MAKE) -C $(1) O=$(out-dir)/ta/$(1)
56
57ta: ta-$(1)
58
59endef
60
61$(eval $(foreach dir,$(TA_DIRS),$(call add-ta-target,$(dir))))
62
63ta-os_test: ta-os_test_lib ta-os_test_lib_dl
64
65ifneq (,$(GP_PACKAGE))
66define add-gp-ta-target
67.PHONY: gp-ta-$(1)
68gp-ta-$(1):
69	$(MAKE) -C $(1)
70
71ta: gp-ta-$(1)
72
73endef
74
75$(eval $(foreach f,$(dir $(wildcard ../host/xtest/gp-suite/TTAs_Internal_API_1_1_1/*/*/code_files/Makefile \
76	../host/xtest/gp-suite/TTAs_Internal_API_1_1_1/*/*/*/code_files/Makefile)),$(call add-gp-ta-target,$(f))))
77endif
78
79# remove build directories including ta/<ta-name>/ directories.
80# Note: $(out-dir) may be a relative path.
81RMDIR := rmdir --ignore-fail-on-non-empty
82define rm-build-subdir
83echo `[ -d $1 ] && { cd $1; $(RMDIR) $(out-dir)/ta $(out-dir) 2> /dev/null; true; }` > /dev/null
84endef
85
86.PHONY: clean
87clean:
88	$(q)$(foreach dir,$(TA_DIRS), [ ! -d $(dir) ] || $(MAKE) -C $(dir) O=$(out-dir)/ta/$(dir) $@ &&) true
89	$(q)$(foreach dir,$(TA_DIRS), $(call rm-build-subdir,$(dir));)
90