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