xref: /optee_os/ta/ta.mk (revision 50ce590549d64eee684c0c1239014746fcdc5237)
1b0104773SPascal Brandinclude mk/cleanvars.mk
2b0104773SPascal Brand
3b0104773SPascal Brand# Set current submodule (used for module specific flags compile result etc)
4bc33bbd9SJens Wiklandersm := $(ta-target)
5b0104773SPascal Brandsm-$(sm) := y
6b0104773SPascal Brand
71b4eb4f5SJens Wiklander# Setup compiler for this sub module
81b4eb4f5SJens WiklanderCOMPILER_$(sm)		?= $(COMPILER)
91b4eb4f5SJens Wiklanderinclude mk/$(COMPILER_$(sm)).mk
101b4eb4f5SJens Wiklander
11bc33bbd9SJens Wiklander# Expand platform flags here as $(sm) will change if we have several TA
12bc33bbd9SJens Wiklander# targets. Platform flags should not change after inclusion of ta/ta.mk.
13bc33bbd9SJens Wiklandercppflags$(sm)	:= $(platform-cppflags) $($(sm)-platform-cppflags)
14bc33bbd9SJens Wiklandercflags$(sm)	:= $(platform-cflags) $($(sm)-platform-cflags)
15bc33bbd9SJens Wiklanderaflags$(sm)	:= $(platform-aflags) $($(sm)-platform-aflags)
16b0104773SPascal Brand
17b5569a68SPascal Brandcppflags$(sm)	+= -include $(conf-file)
18b5569a68SPascal Brand
19b0104773SPascal Brand# Config flags from mk/config.mk
208a1e7b89SJerome Forissiercppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
21156fe685SPascal Brandifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y)
22156fe685SPascal Brandcppflags$(sm) += -DENABLE_MDBG=1
23156fe685SPascal Brandendif
24b0104773SPascal Brand
25b0104773SPascal Brandbase-prefix := $(sm)-
26b0104773SPascal Brand
27b0104773SPascal Brandlibname = utils
28b0104773SPascal Brandlibdir = lib/libutils
29b0104773SPascal Brandinclude mk/lib.mk
30b0104773SPascal Brand
31ca3a3582SJens Wiklanderlibname = zlib
32ca3a3582SJens Wiklanderlibdir = lib/libzlib
33ca3a3582SJens Wiklanderinclude mk/lib.mk
34ca3a3582SJens Wiklander
35fdf35d01SJens Wiklanderlibname = png
36fdf35d01SJens Wiklanderlibdir = lib/libpng
37fdf35d01SJens Wiklanderinclude mk/lib.mk
38fdf35d01SJens Wiklander
39b0104773SPascal Brandlibname = mpa
40b0104773SPascal Brandlibdir = lib/libmpa
41b0104773SPascal Brandinclude mk/lib.mk
42b0104773SPascal Brand
43b0104773SPascal Brandlibname = utee
44b0104773SPascal Brandlibdir = lib/libutee
45b0104773SPascal Brandinclude mk/lib.mk
46b0104773SPascal Brand
47b0104773SPascal Brandbase-prefix :=
48b0104773SPascal Brand
49b0104773SPascal Brandincdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm)))
50fecbba79SJens Wiklanderincfiles-extra-host := lib/libutils/ext/include/compiler.h
513c73419cSJens Wiklanderincfiles-extra-host += lib/libutils/ext/include/util.h
5209d93d24SJens Wiklanderincfiles-extra-host += lib/libutils/ext/include/types_ext.h
53b5569a68SPascal Brandincfiles-extra-host += $(conf-file)
54b5569a68SPascal Brandincfiles-extra-host += $(conf-mk-file)
559470783fSSY Chiuincfiles-extra-host += core/include/tee/tee_fs_key_manager.h
5692ea2867SJens Wiklanderincfiles-extra-host += core/include/signed_hdr.h
57b0104773SPascal Brand
58b0104773SPascal Brand#
59b0104773SPascal Brand# Copy lib files and exported headers from each lib
60b0104773SPascal Brand#
61b0104773SPascal Brand
62b0104773SPascal Branddefine copy-file
63b0104773SPascal Brand$2/$$(notdir $1): $1
640047cb63SJerome Forissier	@set -e; \
650047cb63SJerome Forissier	mkdir -p $$(dir $$@) ; \
6662428631SJens Wiklander	$(cmd-echo-silent) '  INSTALL $$@' ; \
67b0104773SPascal Brand	cp $$< $$@
68b0104773SPascal Brand
69b0104773SPascal Brandcleanfiles += $2/$$(notdir $1)
70b0104773SPascal Brandall: $2/$$(notdir $1)
71b0104773SPascal Brandendef
72b0104773SPascal Brand
73b0104773SPascal Brand# Copy the .a files
74b0104773SPascal Brand$(foreach f, $(libfiles), \
75bc33bbd9SJens Wiklander	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib)))
76b0104773SPascal Brand
77b0104773SPascal Brand# Copy .mk files
789ac870c9SJerome Forissierta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/cleandirs.mk \
792cb1e0d0SJens Wiklander	$(wildcard ta/arch/$(ARCH)/link.mk) \
80b0104773SPascal Brand	ta/mk/ta_dev_kit.mk
813bce5ba1SJerome Forissier
82b0104773SPascal Brand$(foreach f, $(ta-mkfiles), \
83bc33bbd9SJens Wiklander	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk)))
84b0104773SPascal Brand
85b0104773SPascal Brand# Copy the .h files for TAs
86b0104773SPascal Branddefine copy-incdir
87b0104773SPascal Brandsf := $(subst $1/, , $(shell find $1 -name "*.h"))
88b0104773SPascal Brand$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \
890047cb63SJerome Forissier	$$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))))))
90b0104773SPascal Brandendef
91b0104773SPascal Brand$(foreach d, $(incdirs$(sm)), \
92bc33bbd9SJens Wiklander	$(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/include)))
93b0104773SPascal Brand
94b0104773SPascal Brand# Copy the .h files needed by host
95b0104773SPascal Brand$(foreach d, $(incdirs-host), \
96bc33bbd9SJens Wiklander	$(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include)))
97fecbba79SJens Wiklander$(foreach f, $(incfiles-extra-host), \
98bc33bbd9SJens Wiklander	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include)))
99b0104773SPascal Brand
100b0104773SPascal Brand# Copy the src files
101b0104773SPascal Brandta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \
102bc33bbd9SJens Wiklander	$(wildcard ta/arch/$(ARCH)/ta.ld.S)
103b0104773SPascal Brand$(foreach f, $(ta-srcfiles), \
104bc33bbd9SJens Wiklander	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src)))
1052cb1e0d0SJens Wiklander
106bc420748SJens Wiklander# Copy keys
107bc420748SJens Wiklanderta-keys = keys/default_ta.pem
108bc420748SJens Wiklander$(foreach f, $(ta-keys), \
109bc33bbd9SJens Wiklander	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys)))
110bc420748SJens Wiklander
1112cb1e0d0SJens Wiklander# Copy the scripts
112bc420748SJens Wiklanderta-scripts = $(wildcard scripts/sign.py)
1132cb1e0d0SJens Wiklander$(foreach f, $(ta-scripts), \
114bc33bbd9SJens Wiklander	$(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts)))
115bc33bbd9SJens Wiklander
116bc33bbd9SJens Wiklander# Create config file
117b5569a68SPascal Brandconf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk
118b5569a68SPascal Brandsm-$(conf-mk-file-export) := $(sm)
119*50ce5905SJerome Forissierdefine mk-file-export
120b5569a68SPascal Brand$(conf-mk-file-export): $(conf-mk-file)
121*50ce5905SJerome Forissier	@$$(cmd-echo-silent) '  GEN    ' $$@
122*50ce5905SJerome Forissier	$(q)echo sm := $$(sm-$(conf-mk-file-export)) > $$@
123*50ce5905SJerome Forissier	$(q)echo sm-$$(sm-$(conf-mk-file-export)) := y >> $$@
124*50ce5905SJerome Forissier	$(q)echo CFG_TA_FLOAT_SUPPORT := $$(CFG_TA_FLOAT_SUPPORT) >> $$@
125*50ce5905SJerome Forissier	$(q)($$(foreach v, $$(ta-mk-file-export-vars-$$(sm-$(conf-mk-file-export))), \
126*50ce5905SJerome Forissier		echo $$(v) := $$($$(v));)) >> $$@
127*50ce5905SJerome Forissier	$(q)echo '$$(ta-mk-file-export-add-$$(sm-$(conf-mk-file-export)))' | sed 's/_nl_ */\n/g' >> $$@
128*50ce5905SJerome Forissierendef
129*50ce5905SJerome Forissier$(eval $(mk-file-export))
130bc33bbd9SJens Wiklander
131b5569a68SPascal Brandcleanfiles := $(cleanfiles) $(conf-mk-file-export)
132b5569a68SPascal Brandall: $(conf-mk-file-export)
133