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