Update from upstream to 2.4.0 version
[platform/core/security/tef-optee_os.git] / ta / ta.mk
1 include mk/cleanvars.mk
2
3 # Set current submodule (used for module specific flags compile result etc)
4 sm := $(ta-target)
5 sm-$(sm) := y
6
7 # Setup compiler for this sub module
8 COMPILER_$(sm)          ?= $(COMPILER)
9 include 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.
13 cppflags$(sm)   := $(platform-cppflags) $($(sm)-platform-cppflags)
14 cflags$(sm)     := $(platform-cflags) $($(sm)-platform-cflags)
15 aflags$(sm)     := $(platform-aflags) $($(sm)-platform-aflags)
16
17 cppflags$(sm)   += -include $(conf-file)
18
19 # Config flags from mk/config.mk
20 cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
21 ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y)
22 cppflags$(sm) += -DENABLE_MDBG=1
23 endif
24
25 base-prefix := $(sm)-
26
27 libname = utils
28 libdir = lib/libutils
29 include mk/lib.mk
30
31 libname = zlib
32 libdir = lib/libzlib
33 include mk/lib.mk
34
35 libname = png
36 libdir = lib/libpng
37 include mk/lib.mk
38
39 libname = mpa
40 libdir = lib/libmpa
41 include mk/lib.mk
42
43 libname = utee
44 libdir = lib/libutee
45 include mk/lib.mk
46
47 base-prefix :=
48
49 incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm)))
50 incfiles-extra-host := lib/libutils/ext/include/compiler.h
51 incfiles-extra-host += lib/libutils/ext/include/util.h
52 incfiles-extra-host += lib/libutils/ext/include/types_ext.h
53 incfiles-extra-host += $(conf-file)
54 incfiles-extra-host += $(conf-mk-file)
55 incfiles-extra-host += core/include/tee/tee_fs_key_manager.h
56 incfiles-extra-host += core/include/tee/fs_htree.h
57 incfiles-extra-host += core/include/signed_hdr.h
58
59 #
60 # Copy lib files and exported headers from each lib
61 #
62
63 define copy-file
64 $2/$$(notdir $1): $1
65         @set -e; \
66         mkdir -p $$(dir $$@) ; \
67         $(cmd-echo-silent) '  INSTALL $$@' ; \
68         cp $$< $$@
69
70 cleanfiles += $2/$$(notdir $1)
71 all: $2/$$(notdir $1)
72 endef
73
74 # Copy the .a files
75 $(foreach f, $(libfiles), \
76         $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib)))
77
78 # Copy .mk files
79 ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/cleandirs.mk \
80         $(wildcard ta/arch/$(ARCH)/link.mk) \
81         ta/mk/ta_dev_kit.mk
82
83 $(foreach f, $(ta-mkfiles), \
84         $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk)))
85
86 # Copy the .h files for TAs
87 define copy-incdir
88 sf := $(subst $1/, , $(shell find $1 -name "*.h"))
89 $$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \
90         $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))))))
91 endef
92 $(foreach d, $(incdirs$(sm)), \
93         $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/include)))
94
95 # Copy the .h files needed by host
96 $(foreach d, $(incdirs-host), \
97         $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include)))
98 $(foreach f, $(incfiles-extra-host), \
99         $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include)))
100
101 # Copy the src files
102 ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \
103         $(wildcard ta/arch/$(ARCH)/ta.ld.S)
104 $(foreach f, $(ta-srcfiles), \
105         $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src)))
106
107 # Copy keys
108 ta-keys = keys/default_ta.pem
109 $(foreach f, $(ta-keys), \
110         $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys)))
111
112 # Copy the scripts
113 ta-scripts = $(wildcard scripts/sign.py)
114 $(foreach f, $(ta-scripts), \
115         $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts)))
116
117 # Create config file
118 conf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk
119 sm-$(conf-mk-file-export) := $(sm)
120 define mk-file-export
121 $(conf-mk-file-export): $(conf-mk-file)
122         @$$(cmd-echo-silent) '  GEN    ' $$@
123         $(q)echo sm := $$(sm-$(conf-mk-file-export)) > $$@
124         $(q)echo sm-$$(sm-$(conf-mk-file-export)) := y >> $$@
125         $(q)echo CFG_TA_FLOAT_SUPPORT := $$(CFG_TA_FLOAT_SUPPORT) >> $$@
126         $(q)($$(foreach v, $$(ta-mk-file-export-vars-$$(sm-$(conf-mk-file-export))), \
127                 echo $$(v) := $$($$(v));)) >> $$@
128         $(q)echo '$$(ta-mk-file-export-add-$$(sm-$(conf-mk-file-export)))' | sed 's/_nl_ */\n/g' >> $$@
129 endef
130 $(eval $(mk-file-export))
131
132 cleanfiles := $(cleanfiles) $(conf-mk-file-export)
133 all: $(conf-mk-file-export)