xref: /optee_os/ta/ta.mk (revision 8b4ed803d3df96ae3ba8e5f79ecaa59d8e504f14)
1include mk/cleanvars.mk
2
3# Set current submodule (used for module specific flags compile result etc)
4sm := $(ta-target)
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
14# Expand platform flags here as $(sm) will change if we have several TA
15# targets. Platform flags should not change after inclusion of ta/ta.mk.
16cppflags$(sm)	:= $(platform-cppflags) $($(sm)-platform-cppflags)
17cflags$(sm)	:= $(platform-cflags) $($(sm)-platform-cflags)
18aflags$(sm)	:= $(platform-aflags) $($(sm)-platform-aflags)
19
20# Config flags from mk/config.mk
21cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
22cppflags$(sm) += -DCFG_TEE_CORE_USER_MEM_DEBUG=$(CFG_TEE_CORE_USER_MEM_DEBUG)
23ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y)
24cppflags$(sm) += -DENABLE_MDBG=1
25endif
26ifeq ($(CFG_TEE_PANIC_DEBUG),y)
27cppflags$(sm) += -DCFG_TEE_PANIC_DEBUG=1
28endif
29
30base-prefix := $(sm)-
31
32libname = utils
33libdir = lib/libutils
34include mk/lib.mk
35
36libname = mpa
37libdir = lib/libmpa
38include mk/lib.mk
39
40libname = utee
41libdir = lib/libutee
42include mk/lib.mk
43
44base-prefix :=
45
46incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm)))
47incfiles-extra-host := lib/libutils/ext/include/compiler.h
48incfiles-extra-host += lib/libutils/ext/include/util.h
49incfiles-extra-host += $(out-dir)/core/include/generated/conf.h
50incfiles-extra-host += $(out-dir)/core/conf.mk
51incfiles-extra-host += core/include/tee/tee_fs_key_manager.h
52incfiles-extra-host += core/include/signed_hdr.h
53
54#
55# Copy lib files and exported headers from each lib
56#
57
58define copy-file
59$2/$$(notdir $1): $1
60	@set -e; \
61	mkdir -p $$(dir $$@) ; \
62	$(cmd-echo-silent) '  INSTALL $$@' ; \
63	cp $$< $$@
64
65cleanfiles += $2/$$(notdir $1)
66all: $2/$$(notdir $1)
67endef
68
69# Copy the .a files
70$(foreach f, $(libfiles), \
71	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib)))
72
73# Copy .mk files
74ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \
75	$(wildcard core/arch/$(ARCH)/plat-$(PLATFORM)/platform_flags.mk) \
76	$(wildcard ta/arch/$(ARCH)/link.mk) \
77	ta/mk/ta_dev_kit.mk
78
79$(foreach f, $(ta-mkfiles), \
80	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk)))
81
82# Special treatment for ta/arch/$(ARCH)/$(ARCH).mk
83arch-arch-mk := $(out-dir)/export-$(sm)/mk/arch.mk
84$(arch-arch-mk): ta/arch/$(ARCH)/$(ARCH).mk
85	@set -e; \
86	mkdir -p $(dir $@) ; \
87	$(cmd-echo-silent) '  INSTALL $@' ; \
88	cp $< $@
89
90cleanfiles += $(arch-arch-mk)
91all: $(arch-arch-mk)
92
93# Copy the .h files for TAs
94define copy-incdir
95sf := $(subst $1/, , $(shell find $1 -name "*.h"))
96$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \
97	$$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))))))
98endef
99$(foreach d, $(incdirs$(sm)), \
100	$(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/include)))
101
102# Copy the .h files needed by host
103$(foreach d, $(incdirs-host), \
104	$(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include)))
105$(foreach f, $(incfiles-extra-host), \
106	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include)))
107
108# Copy the src files
109ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \
110	$(wildcard ta/arch/$(ARCH)/ta.ld.S)
111$(foreach f, $(ta-srcfiles), \
112	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src)))
113
114# Copy keys
115ta-keys = keys/default_ta.pem
116$(foreach f, $(ta-keys), \
117	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys)))
118
119# Copy the scripts
120ta-scripts = $(wildcard scripts/sign.py)
121$(foreach f, $(ta-scripts), \
122	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts)))
123
124# Create config file
125conf-file := $(out-dir)/export-$(sm)/mk/conf.mk
126sm-$(conf-file) := $(sm)
127$(conf-file): $(conf-mk-file)
128	@$(cmd-echo-silent) '  GEN    ' $@
129	$(q)echo sm := $(sm-$(@)) > $@
130	$(q)echo sm-$(sm-$(@)) := y >> $@
131	$(q)echo CFG_ARM32_$(sm-$(@)) := $(CFG_ARM32_$(sm-$(@))) >> $@
132	$(q)echo CFG_ARM64_$(sm-$(@)) := $(CFG_ARM64_$(sm-$(@))) >> $@
133	$(q)echo CFG_TA_FLOAT_SUPPORT := $(CFG_TA_FLOAT_SUPPORT) >> $@
134
135cleanfiles := $(cleanfiles) $(conf-file)
136all: $(conf-file)
137