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