blob: a66bd62a8ed5cc7c633e845460c7018369a9750a [file] [log] [blame]
Pascal Brandb0104772014-06-12 15:56:20 +02001include mk/cleanvars.mk
2
3# Set current submodule (used for module specific flags compile result etc)
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +01004sm := $(ta-target)
Pascal Brandb0104772014-06-12 15:56:20 +02005sm-$(sm) := y
6
Jens Wiklander1b4eb4f2015-02-02 09:19:18 +01007# Setup compiler for this sub module
Jens Wiklander1b4eb4f2015-02-02 09:19:18 +01008COMPILER_$(sm) ?= $(COMPILER)
9include mk/$(COMPILER_$(sm)).mk
10
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010011# 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)
Pascal Brandb0104772014-06-12 15:56:20 +020016
Pascal Brandb5569a62016-01-08 15:14:30 +010017cppflags$(sm) += -include $(conf-file)
18
Pascal Brandb0104772014-06-12 15:56:20 +020019# Config flags from mk/config.mk
Jerome Forissier8a1e7b82015-03-31 00:44:06 +020020cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL)
Pascal Brand156fe682015-12-03 10:27:35 +010021ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y)
22cppflags$(sm) += -DENABLE_MDBG=1
23endif
Pascal Brandb0104772014-06-12 15:56:20 +020024
Pascal Brandb0104772014-06-12 15:56:20 +020025base-prefix := $(sm)-
26
27libname = utils
28libdir = lib/libutils
29include mk/lib.mk
30
31libname = mpa
32libdir = lib/libmpa
33include mk/lib.mk
34
35libname = utee
36libdir = lib/libutee
37include mk/lib.mk
38
39base-prefix :=
40
41incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm)))
Jens Wiklanderfecbba72015-01-26 09:53:56 +010042incfiles-extra-host := lib/libutils/ext/include/compiler.h
Jens Wiklander3c734192015-01-26 16:39:07 +010043incfiles-extra-host += lib/libutils/ext/include/util.h
Jens Wiklander09d93d22016-04-09 00:21:32 +020044incfiles-extra-host += lib/libutils/ext/include/types_ext.h
Pascal Brandb5569a62016-01-08 15:14:30 +010045incfiles-extra-host += $(conf-file)
46incfiles-extra-host += $(conf-mk-file)
SY Chiu94707832015-09-09 17:17:49 +080047incfiles-extra-host += core/include/tee/tee_fs_key_manager.h
Jens Wiklander92ea2862015-10-26 13:37:30 +010048incfiles-extra-host += core/include/signed_hdr.h
Pascal Brandb0104772014-06-12 15:56:20 +020049
50#
51# Copy lib files and exported headers from each lib
52#
53
54define copy-file
55$2/$$(notdir $1): $1
Jerome Forissier0047cb62014-09-01 13:41:48 +020056 @set -e; \
57 mkdir -p $$(dir $$@) ; \
Jens Wiklander62428632015-04-29 15:05:19 +020058 $(cmd-echo-silent) ' INSTALL $$@' ; \
Pascal Brandb0104772014-06-12 15:56:20 +020059 cp $$< $$@
60
61cleanfiles += $2/$$(notdir $1)
62all: $2/$$(notdir $1)
63endef
64
65# Copy the .a files
66$(foreach f, $(libfiles), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010067 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib)))
Pascal Brandb0104772014-06-12 15:56:20 +020068
69# Copy .mk files
Jens Wiklander2cb1e0d2014-08-15 11:35:17 +020070ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \
Jerome Forissier3bce5ba2014-12-16 19:23:24 +010071 $(wildcard core/arch/$(ARCH)/plat-$(PLATFORM)/platform_flags.mk) \
Jens Wiklander2cb1e0d2014-08-15 11:35:17 +020072 $(wildcard ta/arch/$(ARCH)/link.mk) \
Pascal Brandb0104772014-06-12 15:56:20 +020073 ta/mk/ta_dev_kit.mk
Jerome Forissier3bce5ba2014-12-16 19:23:24 +010074
Pascal Brandb0104772014-06-12 15:56:20 +020075$(foreach f, $(ta-mkfiles), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010076 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk)))
Pascal Brandb0104772014-06-12 15:56:20 +020077
78# Copy the .h files for TAs
79define copy-incdir
80sf := $(subst $1/, , $(shell find $1 -name "*.h"))
81$$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \
Jerome Forissier0047cb62014-09-01 13:41:48 +020082 $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))))))
Pascal Brandb0104772014-06-12 15:56:20 +020083endef
84$(foreach d, $(incdirs$(sm)), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010085 $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/include)))
Pascal Brandb0104772014-06-12 15:56:20 +020086
87# Copy the .h files needed by host
88$(foreach d, $(incdirs-host), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010089 $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include)))
Jens Wiklanderfecbba72015-01-26 09:53:56 +010090$(foreach f, $(incfiles-extra-host), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010091 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include)))
Pascal Brandb0104772014-06-12 15:56:20 +020092
93# Copy the src files
94ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010095 $(wildcard ta/arch/$(ARCH)/ta.ld.S)
Pascal Brandb0104772014-06-12 15:56:20 +020096$(foreach f, $(ta-srcfiles), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010097 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src)))
Jens Wiklander2cb1e0d2014-08-15 11:35:17 +020098
Jens Wiklanderbc420742015-05-05 14:59:15 +020099# Copy keys
100ta-keys = keys/default_ta.pem
101$(foreach f, $(ta-keys), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +0100102 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys)))
Jens Wiklanderbc420742015-05-05 14:59:15 +0200103
Jens Wiklander2cb1e0d2014-08-15 11:35:17 +0200104# Copy the scripts
Jens Wiklanderbc420742015-05-05 14:59:15 +0200105ta-scripts = $(wildcard scripts/sign.py)
Jens Wiklander2cb1e0d2014-08-15 11:35:17 +0200106$(foreach f, $(ta-scripts), \
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +0100107 $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts)))
108
109# Create config file
Pascal Brandb5569a62016-01-08 15:14:30 +0100110conf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk
111sm-$(conf-mk-file-export) := $(sm)
112$(conf-mk-file-export): $(conf-mk-file)
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +0100113 @$(cmd-echo-silent) ' GEN ' $@
114 $(q)echo sm := $(sm-$(@)) > $@
115 $(q)echo sm-$(sm-$(@)) := y >> $@
Jens Wiklander3e27ab42015-12-11 12:48:45 +0100116 $(q)echo CFG_TA_FLOAT_SUPPORT := $(CFG_TA_FLOAT_SUPPORT) >> $@
Jens Wiklander739804b2015-12-11 16:08:09 +0100117 $(q)($(foreach v, $(ta-mk-file-export-vars-$(sm-$(@))), \
118 echo $(v) := $($(v));)) >> $@
Jerome Forissierc042fbe2016-02-05 10:48:36 +0100119 $(q)echo '$(ta-mk-file-export-add-$(sm-$(@)))' | sed 's/_nl_ */\n/g' >> $@
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +0100120
Pascal Brandb5569a62016-01-08 15:14:30 +0100121cleanfiles := $(cleanfiles) $(conf-mk-file-export)
122all: $(conf-mk-file-export)