xref: /optee_os/ta/ta.mk (revision b44708c1c842a9e1ebb63c7f6b43774795669c7a)
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
8COMPILER_$(sm)		?= $(COMPILER)
9include mk/$(COMPILER_$(sm)).mk
10
11# Expand platform flags here as $(sm) will change if we have several TA
12# targets. Platform flags should not change after inclusion of ta/ta.mk.
13cppflags$(sm)	:= $(platform-cppflags) $($(sm)-platform-cppflags)
14cflags$(sm)	:= $(platform-cflags) $($(sm)-platform-cflags)
15aflags$(sm)	:= $(platform-aflags) $($(sm)-platform-aflags)
16
17cppflags$(sm)	+= -include $(conf-file)
18
19# Config flags from mk/config.mk
20cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
21ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y)
22cppflags$(sm) += -DENABLE_MDBG=1
23endif
24
25base-prefix := $(sm)-
26
27libname = utils
28libdir = lib/libutils
29include mk/lib.mk
30
31libname = zlib
32libdir = lib/libzlib
33include mk/lib.mk
34
35libname = mpa
36libdir = lib/libmpa
37include mk/lib.mk
38
39libname = utee
40libdir = lib/libutee
41include mk/lib.mk
42
43base-prefix :=
44
45incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm)))
46incfiles-extra-host := lib/libutils/ext/include/compiler.h
47incfiles-extra-host += lib/libutils/ext/include/util.h
48incfiles-extra-host += lib/libutils/ext/include/types_ext.h
49incfiles-extra-host += $(conf-file)
50incfiles-extra-host += $(conf-mk-file)
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# 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-$(sm)/include)))
90
91# Copy the .h files needed by host
92$(foreach d, $(incdirs-host), \
93	$(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include)))
94$(foreach f, $(incfiles-extra-host), \
95	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include)))
96
97# Copy the src files
98ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \
99	$(wildcard ta/arch/$(ARCH)/ta.ld.S)
100$(foreach f, $(ta-srcfiles), \
101	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src)))
102
103# Copy keys
104ta-keys = keys/default_ta.pem
105$(foreach f, $(ta-keys), \
106	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys)))
107
108# Copy the scripts
109ta-scripts = $(wildcard scripts/sign.py)
110$(foreach f, $(ta-scripts), \
111	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts)))
112
113# Create config file
114conf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk
115sm-$(conf-mk-file-export) := $(sm)
116$(conf-mk-file-export): $(conf-mk-file)
117	@$(cmd-echo-silent) '  GEN    ' $@
118	$(q)echo sm := $(sm-$(@)) > $@
119	$(q)echo sm-$(sm-$(@)) := y >> $@
120	$(q)echo CFG_TA_FLOAT_SUPPORT := $(CFG_TA_FLOAT_SUPPORT) >> $@
121	$(q)($(foreach v, $(ta-mk-file-export-vars-$(sm-$(@))), \
122		echo $(v) := $($(v));)) >> $@
123	$(q)echo '$(ta-mk-file-export-add-$(sm-$(@)))' | sed 's/_nl_ */\n/g' >> $@
124
125cleanfiles := $(cleanfiles) $(conf-mk-file-export)
126all: $(conf-mk-file-export)
127