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 | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 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) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 16 | |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 17 | cppflags$(sm) += -include $(conf-file) |
| 18 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 19 | # Config flags from mk/config.mk |
Jerome Forissier | 8a1e7b8 | 2015-03-31 00:44:06 +0200 | [diff] [blame] | 20 | cppflags$(sm) += -DTRACE_LEVEL=$(CFG_TEE_TA_LOG_LEVEL) |
Pascal Brand | 156fe68 | 2015-12-03 10:27:35 +0100 | [diff] [blame] | 21 | ifeq ($(CFG_TEE_TA_MALLOC_DEBUG),y) |
| 22 | cppflags$(sm) += -DENABLE_MDBG=1 |
| 23 | endif |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 24 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 25 | base-prefix := $(sm)- |
| 26 | |
| 27 | libname = utils |
| 28 | libdir = lib/libutils |
| 29 | include mk/lib.mk |
| 30 | |
| 31 | libname = mpa |
| 32 | libdir = lib/libmpa |
| 33 | include mk/lib.mk |
| 34 | |
| 35 | libname = utee |
| 36 | libdir = lib/libutee |
| 37 | include mk/lib.mk |
| 38 | |
| 39 | base-prefix := |
| 40 | |
| 41 | incdirs-host := $(filter-out lib/libutils%, $(incdirs$(sm))) |
Jens Wiklander | fecbba7 | 2015-01-26 09:53:56 +0100 | [diff] [blame] | 42 | incfiles-extra-host := lib/libutils/ext/include/compiler.h |
Jens Wiklander | 3c73419 | 2015-01-26 16:39:07 +0100 | [diff] [blame] | 43 | incfiles-extra-host += lib/libutils/ext/include/util.h |
Jens Wiklander | 09d93d2 | 2016-04-09 00:21:32 +0200 | [diff] [blame^] | 44 | incfiles-extra-host += lib/libutils/ext/include/types_ext.h |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 45 | incfiles-extra-host += $(conf-file) |
| 46 | incfiles-extra-host += $(conf-mk-file) |
SY Chiu | 9470783 | 2015-09-09 17:17:49 +0800 | [diff] [blame] | 47 | incfiles-extra-host += core/include/tee/tee_fs_key_manager.h |
Jens Wiklander | 92ea286 | 2015-10-26 13:37:30 +0100 | [diff] [blame] | 48 | incfiles-extra-host += core/include/signed_hdr.h |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 49 | |
| 50 | # |
| 51 | # Copy lib files and exported headers from each lib |
| 52 | # |
| 53 | |
| 54 | define copy-file |
| 55 | $2/$$(notdir $1): $1 |
Jerome Forissier | 0047cb6 | 2014-09-01 13:41:48 +0200 | [diff] [blame] | 56 | @set -e; \ |
| 57 | mkdir -p $$(dir $$@) ; \ |
Jens Wiklander | 6242863 | 2015-04-29 15:05:19 +0200 | [diff] [blame] | 58 | $(cmd-echo-silent) ' INSTALL $$@' ; \ |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 59 | cp $$< $$@ |
| 60 | |
| 61 | cleanfiles += $2/$$(notdir $1) |
| 62 | all: $2/$$(notdir $1) |
| 63 | endef |
| 64 | |
| 65 | # Copy the .a files |
| 66 | $(foreach f, $(libfiles), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 67 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/lib))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 68 | |
| 69 | # Copy .mk files |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 70 | ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk \ |
Jerome Forissier | 3bce5ba | 2014-12-16 19:23:24 +0100 | [diff] [blame] | 71 | $(wildcard core/arch/$(ARCH)/plat-$(PLATFORM)/platform_flags.mk) \ |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 72 | $(wildcard ta/arch/$(ARCH)/link.mk) \ |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 73 | ta/mk/ta_dev_kit.mk |
Jerome Forissier | 3bce5ba | 2014-12-16 19:23:24 +0100 | [diff] [blame] | 74 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 75 | $(foreach f, $(ta-mkfiles), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 76 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/mk))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 77 | |
| 78 | # Copy the .h files for TAs |
| 79 | define copy-incdir |
| 80 | sf := $(subst $1/, , $(shell find $1 -name "*.h")) |
| 81 | $$(foreach h, $$(sf), $$(eval $$(call copy-file, $1/$$(h), \ |
Jerome Forissier | 0047cb6 | 2014-09-01 13:41:48 +0200 | [diff] [blame] | 82 | $$(patsubst %/,%,$$(subst /./,/,$2/$$(dir $$(h))))))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 83 | endef |
| 84 | $(foreach d, $(incdirs$(sm)), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 85 | $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/include))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 86 | |
| 87 | # Copy the .h files needed by host |
| 88 | $(foreach d, $(incdirs-host), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 89 | $(eval $(call copy-incdir, $(d), $(out-dir)/export-$(sm)/host_include))) |
Jens Wiklander | fecbba7 | 2015-01-26 09:53:56 +0100 | [diff] [blame] | 90 | $(foreach f, $(incfiles-extra-host), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 91 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/host_include))) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 92 | |
| 93 | # Copy the src files |
| 94 | ta-srcfiles = ta/arch/$(ARCH)/user_ta_header.c \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 95 | $(wildcard ta/arch/$(ARCH)/ta.ld.S) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 96 | $(foreach f, $(ta-srcfiles), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 97 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/src))) |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 98 | |
Jens Wiklander | bc42074 | 2015-05-05 14:59:15 +0200 | [diff] [blame] | 99 | # Copy keys |
| 100 | ta-keys = keys/default_ta.pem |
| 101 | $(foreach f, $(ta-keys), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 102 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/keys))) |
Jens Wiklander | bc42074 | 2015-05-05 14:59:15 +0200 | [diff] [blame] | 103 | |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 104 | # Copy the scripts |
Jens Wiklander | bc42074 | 2015-05-05 14:59:15 +0200 | [diff] [blame] | 105 | ta-scripts = $(wildcard scripts/sign.py) |
Jens Wiklander | 2cb1e0d | 2014-08-15 11:35:17 +0200 | [diff] [blame] | 106 | $(foreach f, $(ta-scripts), \ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 107 | $(eval $(call copy-file, $(f), $(out-dir)/export-$(sm)/scripts))) |
| 108 | |
| 109 | # Create config file |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 110 | conf-mk-file-export := $(out-dir)/export-$(sm)/mk/conf.mk |
| 111 | sm-$(conf-mk-file-export) := $(sm) |
| 112 | $(conf-mk-file-export): $(conf-mk-file) |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 113 | @$(cmd-echo-silent) ' GEN ' $@ |
| 114 | $(q)echo sm := $(sm-$(@)) > $@ |
| 115 | $(q)echo sm-$(sm-$(@)) := y >> $@ |
Jens Wiklander | 3e27ab4 | 2015-12-11 12:48:45 +0100 | [diff] [blame] | 116 | $(q)echo CFG_TA_FLOAT_SUPPORT := $(CFG_TA_FLOAT_SUPPORT) >> $@ |
Jens Wiklander | 739804b | 2015-12-11 16:08:09 +0100 | [diff] [blame] | 117 | $(q)($(foreach v, $(ta-mk-file-export-vars-$(sm-$(@))), \ |
| 118 | echo $(v) := $($(v));)) >> $@ |
Jerome Forissier | c042fbe | 2016-02-05 10:48:36 +0100 | [diff] [blame] | 119 | $(q)echo '$(ta-mk-file-export-add-$(sm-$(@)))' | sed 's/_nl_ */\n/g' >> $@ |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 120 | |
Pascal Brand | b5569a6 | 2016-01-08 15:14:30 +0100 | [diff] [blame] | 121 | cleanfiles := $(cleanfiles) $(conf-mk-file-export) |
| 122 | all: $(conf-mk-file-export) |