xref: /optee_os/ta/ta.mk (revision b8976a602e75d1f1fbdff47f9de2c6cd774c7c12)
1include mk/cleanvars.mk
2
3# Set current submodule (used for module specific flags compile result etc)
4sm := user_ta
5sm-$(sm) := y
6
7cppflags$(sm)	+= $(platform-cppflags) $(user_ta-platform-cppflags)
8cflags$(sm)	+= $(platform-cflags) $(user_ta-platform-cflags)
9aflags$(sm)	+= $(platform-aflags) $(user_ta-platform-aflags)
10
11# Config flags from mk/config.mk
12cppflags$(sm) += -DCFG_TEE_TA_LOG_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
13cppflags$(sm) += -DCFG_TEE_CORE_USER_MEM_DEBUG=$(CFG_TEE_CORE_USER_MEM_DEBUG)
14
15
16base-prefix := $(sm)-
17
18libname = utils
19libdir = lib/libutils
20include mk/lib.mk
21
22libname = mpa
23libdir = lib/libmpa
24include mk/lib.mk
25
26libname = utee
27libdir = lib/libutee
28include mk/lib.mk
29
30base-prefix :=
31
32incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm)))
33
34#
35# Copy lib files and exported headers from each lib
36#
37
38define copy-file
39$2/$$(notdir $1): $1
40	@set -e; \
41	mkdir -p $$(dir $$@) ; \
42	echo '  INSTALL $$@' ; \
43	cp $$< $$@
44
45cleanfiles += $2/$$(notdir $1)
46all: $2/$$(notdir $1)
47endef
48
49# Copy the .a files
50$(foreach f, $(libfiles), \
51	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/lib)))
52
53# Copy .mk files
54ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \
55	$(wildcard ta/arch/$(ARCH)/link.mk) \
56	ta/mk/ta_dev_kit.mk
57$(foreach f, $(ta-mkfiles), \
58	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/mk)))
59
60# Copy the .h files for TAs
61define copy-incdir
62sf := $(subst $1/, , $(shell find $1 -name "*.h"))
63$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \
64	$$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))))))
65endef
66$(foreach d, $(incdirs$(sm)), \
67	$(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/include)))
68
69# Copy the .h files needed by host
70$(foreach d, $(incdirs-host), \
71	$(eval $(call copy-incdir, $(d), $(out-dir)/export-user_ta/host_include)))
72
73# Copy the src files
74ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \
75	$(wildcard ta/arch/$(ARCH)/user_ta_elf_arm.lds)
76$(foreach f, $(ta-srcfiles), \
77	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/src)))
78
79# Copy the scripts
80ta-scripts = $(wildcard ta/arch/$(ARCH)/fix_ta_binary)
81$(foreach f, $(ta-scripts), \
82	$(eval $(call copy-file, $(f), $(out-dir)/export-user_ta/scripts)))
83