xref: /optee_os/ta/ta.mk (revision a10e3a91e70d4d04aeb63c1e3c0668839c82ae39)
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 += core/include/tee/tee_fs_key_manager.h
43
44#
45# Copy lib files and exported headers from each lib
46#
47
48define copy-file
49$2/$$(notdir $1): $1
50	@set -e; \
51	mkdir -p $$(dir $$@) ; \
52	$(cmd-echo-silent) '  INSTALL $$@' ; \
53	cp $$< $$@
54
55cleanfiles += $2/$$(notdir $1)
56all: $2/$$(notdir $1)
57endef
58
59# Copy the .a files
60$(foreach f, $(libfiles), \
61	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/lib)))
62
63# Copy .mk files
64ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \
65	$(wildcard core/arch/$(ARCH)/plat-$(PLATFORM)/platform_flags.mk) \
66	$(wildcard ta/arch/$(ARCH)/link.mk) \
67	ta/mk/ta_dev_kit.mk
68
69$(foreach f, $(ta-mkfiles), \
70	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/mk)))
71
72# Special treatment for ta/arch/$(ARCH)/$(ARCH).mk
73arch-arch-mk := $(out-dir)/export-user_ta/mk/arch.mk
74$(arch-arch-mk): ta/arch/$(ARCH)/$(ARCH).mk
75	@set -e; \
76	mkdir -p $(dir $@) ; \
77	$(cmd-echo-silent) '  INSTALL $@' ; \
78	cp $< $@
79
80cleanfiles += $(arch-arch-mk)
81all: $(arch-arch-mk)
82
83# Copy the .h files for TAs
84define copy-incdir
85sf := $(subst $1/, , $(shell find $1 -name "*.h"))
86$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \
87	$$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))))))
88endef
89$(foreach d, $(incdirs$(sm)), \
90	$(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/include)))
91
92# Copy the .h files needed by host
93$(foreach d, $(incdirs-host), \
94	$(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/host_include)))
95$(foreach f, $(incfiles-extra-host), \
96	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/host_include)))
97
98# Copy the src files
99ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \
100	$(wildcard ta/arch/$(ARCH)/user_ta_elf_arm.lds)
101$(foreach f, $(ta-srcfiles), \
102	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/src)))
103
104# Copy keys
105ta-keys = keys/default_ta.pem
106$(foreach f, $(ta-keys), \
107	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/keys)))
108
109# Copy the scripts
110ta-scripts = $(wildcard scripts/sign.py)
111$(foreach f, $(ta-scripts), \
112	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/scripts)))
113