Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 1 | include mk/cleanvars.mk |
| 2 | |
| 3 | # Set current submodule (used for module specific flags compile result etc) |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 4 | sm := $(ta-target) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 5 | sm-$(sm) := y |
| 6 | |
Jens Wiklander | 1b4eb4f | 2015-02-02 09:19:18 +0100 | [diff] [blame] | 7 | # Setup compiler for this sub module |
Jens Wiklander | 1b4eb4f | 2015-02-02 09:19:18 +0100 | [diff] [blame] | 8 | COMPILER_$(sm) ?= $(COMPILER) |
| 9 | include mk/$(COMPILER_$(sm)).mk |
| 10 | |
Jens Wiklander | 137eb24 | 2018-04-19 17:30:53 +0200 | [diff] [blame] | 11 | # |
| 12 | # Config flags from mk/config.mk |
| 13 | # |
| 14 | |
Jens Wiklander | a97bc4a | 2018-05-18 15:49:22 +0200 | [diff] [blame] | 15 | ifeq ($(CFG_TA_MBEDTLS_SELF_TEST),y) |
| 16 | $(sm)-platform-cppflags += -DMBEDTLS_SELF_TEST |
| 17 | endif |
| 18 | |
Jens Wiklander | 137eb24 | 2018-04-19 17:30:53 +0200 | [diff] [blame] | 19 | ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y) |
| 20 | # Build malloc debug code into libutils: (mdbg_malloc(), mdbg_free(), |
| 21 | # mdbg_check(), etc.). |
| 22 | $(sm)-platform-cppflags += -DENABLE_MDBG=1 |
| 23 | endif |
| 24 | |
Jens Wiklander | d1911a8 | 2019-05-23 17:42:11 +0200 | [diff] [blame] | 25 | # Keep CFG_TA_DYNLINK for backwards compatibility |
| 26 | $(call force,CFG_TA_DYNLINK,y) |
| 27 | |
Jens Wiklander | c21bf05 | 2018-04-20 12:44:36 +0200 | [diff] [blame] | 28 | # Config variables to be explicitly exported to the dev kit conf.mk |
Jens Wiklander | 28a6ae1 | 2018-04-19 17:32:30 +0200 | [diff] [blame] | 29 | ta-mk-file-export-vars-$(sm) += CFG_TA_FLOAT_SUPPORT |
Jens Wiklander | c21bf05 | 2018-04-20 12:44:36 +0200 | [diff] [blame] | 30 | ta-mk-file-export-vars-$(sm) += CFG_CACHE_API |
| 31 | ta-mk-file-export-vars-$(sm) += CFG_SECURE_DATA_PATH |
Jens Wiklander | a97bc4a | 2018-05-18 15:49:22 +0200 | [diff] [blame] | 32 | ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS_SELF_TEST |
| 33 | ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS |
Jens Wiklander | 062e3d0 | 2018-11-13 09:37:22 +0100 | [diff] [blame] | 34 | ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS_MPI |
Igor Opaniuk | 4bca302 | 2018-05-22 16:29:49 +0300 | [diff] [blame] | 35 | ta-mk-file-export-vars-$(sm) += CFG_SYSTEM_PTA |
Jerome Forissier | 0095d8b | 2018-05-31 09:53:45 +0200 | [diff] [blame] | 36 | ta-mk-file-export-vars-$(sm) += CFG_TA_DYNLINK |
Jens Wiklander | 412dcda | 2018-11-29 11:52:13 +0100 | [diff] [blame] | 37 | ta-mk-file-export-vars-$(sm) += CFG_TEE_TA_LOG_LEVEL |
Sumit Garg | b02ae38 | 2019-05-22 14:41:59 +0530 | [diff] [blame] | 38 | ta-mk-file-export-vars-$(sm) += CFG_TA_FTRACE_SUPPORT |
Jerome Forissier | e0e762f | 2019-06-14 08:25:50 +0200 | [diff] [blame] | 39 | ta-mk-file-export-vars-$(sm) += CFG_UNWIND |
Jens Wiklander | 8f8d7cd | 2019-06-17 22:42:01 +0200 | [diff] [blame] | 40 | ta-mk-file-export-vars-$(sm) += CFG_TA_MCOUNT |
Jens Wiklander | 28a6ae1 | 2018-04-19 17:32:30 +0200 | [diff] [blame] | 41 | |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 42 | # Expand platform flags here as $(sm) will change if we have several TA |
| 43 | # targets. Platform flags should not change after inclusion of ta/ta.mk. |
| 44 | cppflags$(sm) := $(platform-cppflags) $($(sm)-platform-cppflags) |
| 45 | cflags$(sm) := $(platform-cflags) $($(sm)-platform-cflags) |
| 46 | aflags$(sm) := $(platform-aflags) $($(sm)-platform-aflags) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 47 | |
Jens Wiklander | 137eb24 | 2018-04-19 17:30:53 +0200 | [diff] [blame] | 48 | # Changes to cppflags$(sm) will only affect how TA dev kit libraries are |
| 49 | # compiled, these flags are not propagated to the TA |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 50 | cppflags$(sm) += -include $(conf-file) |
Jerome Forissier | 8a1e7b8 | 2015-03-31 00:44:06 +0200 | [diff] [blame] | 51 | cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 52 | |
Sumit Garg | 4486d58 | 2019-07-04 12:41:52 +0530 | [diff] [blame] | 53 | ifeq ($(ta-target),ta_arm32) |
| 54 | arm32-user-sysreg-txt = lib/libutee/arch/arm/arm32_user_sysreg.txt |
| 55 | arm32-user-sysregs-$(arm32-user-sysreg-txt)-h := arm32_user_sysreg.h |
| 56 | arm32-user-sysregs += $(arm32-user-sysreg-txt) |
| 57 | |
| 58 | arm32-user-sysregs-out := $(out-dir)/include/generated |
| 59 | |
| 60 | define process-arm32-user-sysreg |
| 61 | FORCE-GENSRC$(sm): $$(arm32-user-sysregs-out)/$$(arm32-user-sysregs-$(1)-h) |
| 62 | cleanfiles := $$(cleanfiles) \ |
| 63 | $$(arm32-user-sysregs-out)/$$(arm32-user-sysregs-$(1)-h) |
| 64 | |
| 65 | $$(arm32-user-sysregs-out)/$$(arm32-user-sysregs-$(1)-h): \ |
| 66 | $(1) scripts/arm32_sysreg.py |
| 67 | @$(cmd-echo-silent) ' GEN $$@' |
| 68 | $(q)mkdir -p $$(dir $$@) |
| 69 | $(q)scripts/arm32_sysreg.py --guard __$$(arm32-user-sysregs-$(1)-h) \ |
| 70 | < $$< > $$@ |
| 71 | |
| 72 | endef #process-arm32-user-sysreg |
| 73 | |
| 74 | $(foreach sr, $(arm32-user-sysregs), \ |
| 75 | $(eval $(call process-arm32-user-sysreg,$(sr)))) |
| 76 | |
| 77 | cppflags$(sm) += -I$(arm32-user-sysregs-out) |
| 78 | endif |
| 79 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 80 | base-prefix := $(sm)- |
| 81 | |
| 82 | libname = utils |
| 83 | libdir = lib/libutils |
Jerome Forissier | 64718c9 | 2018-05-29 18:03:11 +0200 | [diff] [blame] | 84 | libuuid = 71855bba-6055-4293-a63f-b0963a737360 |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 85 | include mk/lib.mk |
| 86 | |
Jens Wiklander | 062e3d0 | 2018-11-13 09:37:22 +0100 | [diff] [blame] | 87 | CFG_TA_MBEDTLS_MPI ?= y |
| 88 | ifeq ($(CFG_TA_MBEDTLS_MPI),y) |
Jerome Forissier | 64718c9 | 2018-05-29 18:03:11 +0200 | [diff] [blame] | 89 | mplib-for-utee = mbedtls |
Jens Wiklander | 062e3d0 | 2018-11-13 09:37:22 +0100 | [diff] [blame] | 90 | $(call force,CFG_TA_MBEDTLS,y) |
| 91 | else |
Jerome Forissier | 64718c9 | 2018-05-29 18:03:11 +0200 | [diff] [blame] | 92 | mplib-for-utee = mpa |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 93 | libname = mpa |
| 94 | libdir = lib/libmpa |
Jerome Forissier | 64718c9 | 2018-05-29 18:03:11 +0200 | [diff] [blame] | 95 | libuuid = 39b498d9-1e1f-4ae0-a9e1-6d1caf8ec731 |
| 96 | libl = utils |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 97 | include mk/lib.mk |
Jens Wiklander | 062e3d0 | 2018-11-13 09:37:22 +0100 | [diff] [blame] | 98 | endif |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 99 | |
Jens Wiklander | a97bc4a | 2018-05-18 15:49:22 +0200 | [diff] [blame] | 100 | ifeq ($(CFG_TA_MBEDTLS),y) |
| 101 | libname = mbedtls |
| 102 | libdir = lib/libmbedtls |
Jerome Forissier | 64718c9 | 2018-05-29 18:03:11 +0200 | [diff] [blame] | 103 | libuuid = 87bb6ae8-4b1d-49fe-9986-2b966132c309 |
| 104 | libl = utils |
Jens Wiklander | a97bc4a | 2018-05-18 15:49:22 +0200 | [diff] [blame] | 105 | include mk/lib.mk |
| 106 | ta-mk-file-export-vars-$(sm) += CFG_TA_MBEDTLS |
| 107 | endif |
| 108 | |
Jerome Forissier | 64718c9 | 2018-05-29 18:03:11 +0200 | [diff] [blame] | 109 | libname = utee |
| 110 | libdir = lib/libutee |
| 111 | libuuid = 527f1a47-b92c-4a74-95bd-72f19f4a6f74 |
| 112 | libl = $(mplib-for-utee) utils |
| 113 | include mk/lib.mk |
| 114 | |
Jerome Forissier | c96bced | 2019-08-01 18:00:07 +0200 | [diff] [blame^] | 115 | libname = dl |
| 116 | libdir = lib/libdl |
| 117 | libuuid = be807bbd-81e1-4dc4-bd99-3d363f240ece |
| 118 | libl = utee utils |
| 119 | include mk/lib.mk |
| 120 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 121 | base-prefix := |
| 122 | |
| 123 | incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm))) |
Jens Wiklander | fecbba7 | 2015-01-26 09:53:56 +0100 | [diff] [blame] | 124 | incfiles-extra-host := lib/libutils/ext/include/compiler.h |
Jens Wiklander | 3c73419 | 2015-01-26 16:39:07 +0100 | [diff] [blame] | 125 | incfiles-extra-host += lib/libutils/ext/include/util.h |
Jens Wiklander | 09d93d2 | 2016-04-09 00:21:32 +0200 | [diff] [blame] | 126 | incfiles-extra-host += lib/libutils/ext/include/types_ext.h |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 127 | incfiles-extra-host += $(conf-file) |
| 128 | incfiles-extra-host += $(conf-mk-file) |
Jens Wiklander | b924c49 | 2018-02-08 14:50:07 +0100 | [diff] [blame] | 129 | incfiles-extra-host += $(conf-cmake-file) |
SY Chiu | 9470783 | 2015-09-09 17:17:49 +0800 | [diff] [blame] | 130 | incfiles-extra-host += core/include/tee/tee_fs_key_manager.h |
Jens Wiklander | 50a8149 | 2017-02-15 15:26:35 +0100 | [diff] [blame] | 131 | incfiles-extra-host += core/include/tee/fs_htree.h |
Jens Wiklander | 92ea286 | 2015-10-26 13:37:30 +0100 | [diff] [blame] | 132 | incfiles-extra-host += core/include/signed_hdr.h |
Sumit Garg | 4486d58 | 2019-07-04 12:41:52 +0530 | [diff] [blame] | 133 | ifeq ($(ta-target),ta_arm32) |
| 134 | incfiles-extra-host += $(out-dir)/include/generated/arm32_user_sysreg.h |
| 135 | endif |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 136 | |
| 137 | # |
| 138 | # Copy lib files and exported headers from each lib |
| 139 | # |
| 140 | |
| 141 | define copy-file |
| 142 | $2/$$(notdir $1): $1 |
Jerome Forissier | 0047cb6 | 2014-09-01 13:41:48 +0200 | [diff] [blame] | 143 | @set -e; \ |
| 144 | mkdir -p $$(dir $$@) ; \ |
Jens Wiklander | 6242863 | 2015-04-29 15:05:19 +0200 | [diff] [blame] | 145 | $(cmd-echo-silent) ' INSTALL $$@' ; \ |
Jerome Forissier | 64718c9 | 2018-05-29 18:03:11 +0200 | [diff] [blame] | 146 | cp -P $$< $$@ |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 147 | |
| 148 | cleanfiles += $2/$$(notdir $1) |
Jerome Forissier | 4746a22 | 2017-08-16 18:11:55 +0200 | [diff] [blame] | 149 | ta_dev_kit: $2/$$(notdir $1) |
Jerome Forissier | 8452bf4 | 2018-08-13 15:19:23 +0200 | [diff] [blame] | 150 | ta_dev_kit-files += $2/$$(notdir $1) |
Jerome Forissier | 0265f1e | 2019-08-01 14:54:09 +0200 | [diff] [blame] | 151 | ta_dev_kit-files-$3 += $2/$$(notdir $1) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 152 | endef |
| 153 | |
| 154 | # Copy the .a files |
| 155 | $(foreach f, $(libfiles), \ |
Jerome Forissier | 0265f1e | 2019-08-01 14:54:09 +0200 | [diff] [blame] | 156 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib,lib))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 157 | |
| 158 | # Copy .mk files |
Jerome Forissier | 9ac870c | 2017-01-06 09:33:29 +0100 | [diff] [blame] | 159 | ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/cleandirs.mk \ |
Jerome Forissier | f8896d1 | 2018-02-06 16:25:53 +0100 | [diff] [blame] | 160 | ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \ |
| 161 | ta/mk/ta_dev_kit.mk |
Jerome Forissier | 3bce5ba | 2014-12-16 19:23:24 +0100 | [diff] [blame] | 162 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 163 | $(foreach f, $(ta-mkfiles), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 164 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 165 | |
| 166 | # Copy the .h files for TAs |
| 167 | define copy-incdir |
Jerome Forissier | c806189 | 2019-07-03 17:47:50 +0200 | [diff] [blame] | 168 | sf := $(subst $1/, , $(shell find $1 -name "*.[hS]")) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 169 | $$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \ |
Jerome Forissier | 0265f1e | 2019-08-01 14:54:09 +0200 | [diff] [blame] | 170 | $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h)))),$3))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 171 | endef |
| 172 | $(foreach d, $(incdirs$(sm)), \ |
Jerome Forissier | 0265f1e | 2019-08-01 14:54:09 +0200 | [diff] [blame] | 173 | $(eval $(call copy-incdir,$(d),$(out-dir)/export-$(sm)/include,include))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 174 | |
| 175 | # Copy the .h files needed by host |
| 176 | $(foreach d, $(incdirs-host), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 177 | $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include))) |
Jens Wiklander | fecbba7 | 2015-01-26 09:53:56 +0100 | [diff] [blame] | 178 | $(foreach f, $(incfiles-extra-host), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 179 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 180 | |
| 181 | # Copy the src files |
Jerome Forissier | 0ac9c8c | 2017-08-17 13:06:09 +0200 | [diff] [blame] | 182 | ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c ta/arch/$(ARCH)/ta.ld.S |
Jerome Forissier | c806189 | 2019-07-03 17:47:50 +0200 | [diff] [blame] | 183 | ifeq ($(ta-target),ta_arm32) |
| 184 | ta-srcfiles += ta/arch/$(ARCH)/ta_entry_a32.S |
| 185 | endif |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 186 | $(foreach f, $(ta-srcfiles), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 187 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src))) |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 188 | |
Jens Wiklander | bc42074 | 2015-05-05 14:59:15 +0200 | [diff] [blame] | 189 | # Copy keys |
| 190 | ta-keys = keys/default_ta.pem |
| 191 | $(foreach f, $(ta-keys), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 192 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys))) |
Jens Wiklander | bc42074 | 2015-05-05 14:59:15 +0200 | [diff] [blame] | 193 | |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 194 | # Copy the scripts |
Jerome Forissier | 910c575 | 2017-08-17 13:09:39 +0200 | [diff] [blame] | 195 | ta-scripts = scripts/sign.py scripts/symbolize.py |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 196 | $(foreach f, $(ta-scripts), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 197 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts))) |
| 198 | |
| 199 | # Create config file |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 200 | conf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk |
| 201 | sm-$(conf-mk-file-export) := $(sm) |
Jerome Forissier | 50ce590 | 2017-01-06 15:28:52 +0100 | [diff] [blame] | 202 | define mk-file-export |
Jens Wiklander | a42a05a | 2018-04-19 17:01:06 +0200 | [diff] [blame] | 203 | .PHONY: $(conf-mk-file-export) |
| 204 | $(conf-mk-file-export): |
| 205 | @$$(cmd-echo-silent) ' CHK ' $$@ |
| 206 | $(q)echo sm := $$(sm-$(conf-mk-file-export)) > $$@.tmp |
| 207 | $(q)echo sm-$$(sm-$(conf-mk-file-export)) := y >> $$@.tmp |
Jerome Forissier | 50ce590 | 2017-01-06 15:28:52 +0100 | [diff] [blame] | 208 | $(q)($$(foreach v, $$(ta-mk-file-export-vars-$$(sm-$(conf-mk-file-export))), \ |
Jens Wiklander | 1308459 | 2018-04-20 16:07:30 +0200 | [diff] [blame] | 209 | $$(if $$($$(v)),echo $$(v) := $$($$(v));,))) >> $$@.tmp |
Jens Wiklander | a42a05a | 2018-04-19 17:01:06 +0200 | [diff] [blame] | 210 | $(q)echo '$$(ta-mk-file-export-add-$$(sm-$(conf-mk-file-export)))' | sed 's/_nl_ */\n/g' >> $$@.tmp |
| 211 | $(q)$(call mv-if-changed,$$@.tmp,$$@) |
Jerome Forissier | 50ce590 | 2017-01-06 15:28:52 +0100 | [diff] [blame] | 212 | endef |
| 213 | $(eval $(mk-file-export)) |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 214 | |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 215 | cleanfiles := $(cleanfiles) $(conf-mk-file-export) |
Jerome Forissier | 4746a22 | 2017-08-16 18:11:55 +0200 | [diff] [blame] | 216 | ta_dev_kit: $(conf-mk-file-export) |
| 217 | |
| 218 | all: ta_dev_kit |