Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 1 | # |
| 2 | # Common definition to all platforms |
| 3 | # |
| 4 | |
Jens Wiklander | 650f298 | 2017-04-05 10:08:59 +0200 | [diff] [blame] | 5 | SHELL := bash |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 6 | BASH ?= bash |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 7 | ROOT ?= $(shell pwd)/.. |
| 8 | |
Philip Attfield | 3f9250f | 2016-09-14 07:43:32 +0200 | [diff] [blame] | 9 | BUILD_PATH ?= $(ROOT)/build |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 10 | LINUX_PATH ?= $(ROOT)/linux |
Victor Chong | 9f0d120 | 2016-04-23 16:28:31 +0100 | [diff] [blame] | 11 | OPTEE_GENDRV_MODULE ?= $(LINUX_PATH)/drivers/tee/optee/optee.ko |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 12 | GEN_ROOTFS_PATH ?= $(ROOT)/gen_rootfs |
| 13 | GEN_ROOTFS_FILELIST ?= $(GEN_ROOTFS_PATH)/filelist-tee.txt |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 14 | OPTEE_OS_PATH ?= $(ROOT)/optee_os |
| 15 | OPTEE_CLIENT_PATH ?= $(ROOT)/optee_client |
| 16 | OPTEE_CLIENT_EXPORT ?= $(OPTEE_CLIENT_PATH)/out/export |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 17 | OPTEE_TEST_PATH ?= $(ROOT)/optee_test |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 18 | OPTEE_TEST_OUT_PATH ?= $(ROOT)/optee_test/out |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 19 | OPTEE_EXAMPLES_PATH ?= $(ROOT)/optee_examples |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 20 | BENCHMARK_APP_PATH ?= $(ROOT)/optee_benchmark |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 21 | |
Etienne Carriere | cc23f6b | 2016-10-21 10:16:00 +0200 | [diff] [blame] | 22 | # default high verbosity. slow uarts shall specify lower if prefered |
Pascal Brand | 23ef205 | 2016-03-09 15:25:01 +0100 | [diff] [blame] | 23 | CFG_TEE_CORE_LOG_LEVEL ?= 3 |
| 24 | |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 25 | # default disable latency benchmarks (over all OP-TEE layers) |
| 26 | CFG_TEE_BENCHMARK ?= n |
| 27 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 28 | CCACHE ?= $(shell which ccache) # Don't remove this comment (space is needed) |
| 29 | |
Igor Opaniuk | 97d0529 | 2016-10-26 14:46:14 +0300 | [diff] [blame] | 30 | # Accessing a shared folder on the host from QEMU: |
| 31 | # # Set QEMU_VIRTFS_ENABLE to 'y' and adjust QEMU_VIRTFS_HOST_DIR |
| 32 | # # Then in QEMU, run: |
| 33 | # # $ mount -t 9p -o trans=virtio host <mount_point> |
| 34 | QEMU_VIRTFS_ENABLE ?= n |
| 35 | QEMU_VIRTFS_HOST_DIR ?= $(ROOT) |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 36 | |
Igor Opaniuk | 0aea4ef | 2017-01-13 12:52:00 +0200 | [diff] [blame] | 37 | # Enable SLiRP user networking |
| 38 | QEMU_USERNET_ENABLE ?= n |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 39 | ################################################################################ |
| 40 | # Check coherency of compilation mode |
| 41 | ################################################################################ |
| 42 | |
| 43 | ifneq ($(COMPILE_NS_USER),) |
| 44 | ifeq ($(COMPILE_NS_KERNEL),) |
| 45 | $(error COMPILE_NS_KERNEL must be defined as COMPILE_NS_USER=$(COMPILE_NS_USER) is defined) |
| 46 | endif |
| 47 | ifeq (,$(filter $(COMPILE_NS_USER),32 64)) |
| 48 | $(error COMPILE_NS_USER=$(COMPILE_NS_USER) - Should be 32 or 64) |
| 49 | endif |
| 50 | endif |
| 51 | |
| 52 | ifneq ($(COMPILE_NS_KERNEL),) |
| 53 | ifeq ($(COMPILE_NS_USER),) |
| 54 | $(error COMPILE_NS_USER must be defined as COMPILE_NS_KERNEL=$(COMPILE_NS_KERNEL) is defined) |
| 55 | endif |
| 56 | ifeq (,$(filter $(COMPILE_NS_KERNEL),32 64)) |
| 57 | $(error COMPILE_NS_KERNEL=$(COMPILE_NS_KERNEL) - Should be 32 or 64) |
| 58 | endif |
| 59 | endif |
| 60 | |
| 61 | ifeq ($(COMPILE_NS_KERNEL),32) |
| 62 | ifneq ($(COMPILE_NS_USER),32) |
| 63 | $(error COMPILE_NS_USER=$(COMPILE_NS_USER) - Should be 32 as COMPILE_NS_KERNEL=$(COMPILE_NS_KERNEL)) |
| 64 | endif |
| 65 | endif |
| 66 | |
| 67 | ifneq ($(COMPILE_S_USER),) |
| 68 | ifeq ($(COMPILE_S_KERNEL),) |
| 69 | $(error COMPILE_S_KERNEL must be defined as COMPILE_S_USER=$(COMPILE_S_USER) is defined) |
| 70 | endif |
| 71 | ifeq (,$(filter $(COMPILE_S_USER),32 64)) |
| 72 | $(error COMPILE_S_USER=$(COMPILE_S_USER) - Should be 32 or 64) |
| 73 | endif |
| 74 | endif |
| 75 | |
| 76 | ifneq ($(COMPILE_S_KERNEL),) |
| 77 | OPTEE_OS_COMMON_EXTRA_FLAGS ?= O=out/arm |
| 78 | OPTEE_OS_BIN ?= $(OPTEE_OS_PATH)/out/arm/core/tee.bin |
| 79 | ifeq ($(COMPILE_S_USER),) |
| 80 | $(error COMPILE_S_USER must be defined as COMPILE_S_KERNEL=$(COMPILE_S_KERNEL) is defined) |
| 81 | endif |
| 82 | ifeq (,$(filter $(COMPILE_S_KERNEL),32 64)) |
| 83 | $(error COMPILE_S_KERNEL=$(COMPILE_S_KERNEL) - Should be 32 or 64) |
| 84 | endif |
| 85 | endif |
| 86 | |
| 87 | ifeq ($(COMPILE_S_KERNEL),32) |
| 88 | ifneq ($(COMPILE_S_USER),32) |
| 89 | $(error COMPILE_S_USER=$(COMPILE_S_USER) - Should be 32 as COMPILE_S_KERNEL=$(COMPILE_S_KERNEL)) |
| 90 | endif |
| 91 | endif |
| 92 | |
| 93 | |
| 94 | ################################################################################ |
| 95 | # set the compiler when COMPILE_xxx are defined |
| 96 | ################################################################################ |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 97 | CROSS_COMPILE_NS_USER ?= "$(CCACHE)$(AARCH$(COMPILE_NS_USER)_CROSS_COMPILE)" |
| 98 | CROSS_COMPILE_NS_KERNEL ?= "$(CCACHE)$(AARCH$(COMPILE_NS_KERNEL)_CROSS_COMPILE)" |
| 99 | CROSS_COMPILE_S_USER ?= "$(CCACHE)$(AARCH$(COMPILE_S_USER)_CROSS_COMPILE)" |
| 100 | CROSS_COMPILE_S_KERNEL ?= "$(CCACHE)$(AARCH$(COMPILE_S_KERNEL)_CROSS_COMPILE)" |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 101 | |
| 102 | ifeq ($(COMPILE_S_USER),32) |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 103 | OPTEE_OS_TA_DEV_KIT_DIR ?= $(OPTEE_OS_PATH)/out/arm/export-ta_arm32 |
| 104 | endif |
| 105 | ifeq ($(COMPILE_S_USER),64) |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 106 | OPTEE_OS_TA_DEV_KIT_DIR ?= $(OPTEE_OS_PATH)/out/arm/export-ta_arm64 |
| 107 | endif |
| 108 | |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 109 | ifeq ($(COMPILE_S_KERNEL),64) |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 110 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_ARM64_core=y |
| 111 | endif |
| 112 | |
| 113 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 114 | ################################################################################ |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 115 | # defines, macros, configuration etc |
| 116 | ################################################################################ |
| 117 | define KERNEL_VERSION |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 118 | $(shell cd $(LINUX_PATH) && $(MAKE) --no-print-directory kernelversion) |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 119 | endef |
Victor Chong | 3bcef44 | 2017-08-07 10:57:55 +0100 | [diff] [blame] | 120 | |
| 121 | # Read stdin, expand ${VAR} environment variables, output to stdout |
| 122 | # http://superuser.com/a/302847 |
| 123 | define expand-env-var |
| 124 | awk '{while(match($$0,"[$$]{[^}]*}")) {var=substr($$0,RSTART+2,RLENGTH -3);gsub("[$$]{"var"}",ENVIRON[var])}}1' |
| 125 | endef |
| 126 | |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 127 | DEBUG ?= 0 |
| 128 | |
| 129 | ################################################################################ |
Pascal Brand | cb45260 | 2015-10-13 10:46:33 +0200 | [diff] [blame] | 130 | # default target is all |
| 131 | ################################################################################ |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 132 | .PHONY: all |
Pascal Brand | cb45260 | 2015-10-13 10:46:33 +0200 | [diff] [blame] | 133 | all: |
| 134 | |
| 135 | ################################################################################ |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 136 | # Busybox |
| 137 | ################################################################################ |
| 138 | BUSYBOX_COMMON_TARGET ?= TOBEDEFINED |
| 139 | BUSYBOX_CLEAN_COMMON_TARGET ?= TOBEDEFINED |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 140 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 141 | .PHONY: busybox-common |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 142 | busybox-common: linux |
| 143 | cd $(GEN_ROOTFS_PATH) && \ |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 144 | CROSS_COMPILE=$(CROSS_COMPILE_NS_USER) \ |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 145 | PATH=${PATH}:$(LINUX_PATH)/usr \ |
| 146 | $(GEN_ROOTFS_PATH)/generate-cpio-rootfs.sh \ |
| 147 | $(BUSYBOX_COMMON_TARGET) |
| 148 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 149 | .PHONY: busybox-clean-common |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 150 | busybox-clean-common: |
| 151 | cd $(GEN_ROOTFS_PATH) && \ |
| 152 | $(GEN_ROOTFS_PATH)/generate-cpio-rootfs.sh \ |
| 153 | $(BUSYBOX_CLEAN_COMMON_TARGET) |
| 154 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 155 | .PHONY: busybox-cleaner-common |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 156 | busybox-cleaner-common: |
| 157 | rm -rf $(GEN_ROOTFS_PATH)/build |
| 158 | rm -rf $(GEN_ROOTFS_PATH)/filelist-final.txt |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 159 | |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 160 | ################################################################################ |
| 161 | # Linux |
| 162 | ################################################################################ |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 163 | ifeq ($(CFG_TEE_BENCHMARK),y) |
| 164 | LINUX_DEFCONFIG_BENCH ?= $(CURDIR)/kconfigs/tee_bench.conf |
| 165 | endif |
| 166 | |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 167 | LINUX_COMMON_FLAGS ?= LOCALVERSION= CROSS_COMPILE=$(CROSS_COMPILE_NS_KERNEL) |
| 168 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 169 | .PHONY: linux-common |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 170 | linux-common: linux-defconfig |
| 171 | $(MAKE) -C $(LINUX_PATH) $(LINUX_COMMON_FLAGS) |
| 172 | |
Jerome Forissier | e100238 | 2015-11-26 11:36:00 +0100 | [diff] [blame] | 173 | $(LINUX_PATH)/.config: $(LINUX_DEFCONFIG_COMMON_FILES) |
| 174 | cd $(LINUX_PATH) && \ |
| 175 | ARCH=$(LINUX_DEFCONFIG_COMMON_ARCH) \ |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 176 | scripts/kconfig/merge_config.sh $(LINUX_DEFCONFIG_COMMON_FILES) \ |
| 177 | $(LINUX_DEFCONFIG_BENCH) |
Jerome Forissier | e100238 | 2015-11-26 11:36:00 +0100 | [diff] [blame] | 178 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 179 | .PHONY: linux-defconfig-clean-common |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 180 | linux-defconfig-clean-common: |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 181 | rm -f $(LINUX_PATH)/.config |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 182 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 183 | # LINUX_CLEAN_COMMON_FLAGS should be defined in specific makefiles (hikey.mk,...) |
| 184 | .PHONY: linux-clean-common |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 185 | linux-clean-common: linux-defconfig-clean |
| 186 | $(MAKE) -C $(LINUX_PATH) $(LINUX_CLEAN_COMMON_FLAGS) clean |
| 187 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 188 | # LINUX_CLEANER_COMMON_FLAGS should be defined in specific makefiles (hikey.mk,...) |
| 189 | .PHONY: linux-cleaner-common |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 190 | linux-cleaner-common: linux-defconfig-clean |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 191 | $(MAKE) -C $(LINUX_PATH) $(LINUX_CLEANER_COMMON_FLAGS) distclean |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 192 | |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 193 | ################################################################################ |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 194 | # EDK2 / Tianocore |
| 195 | ################################################################################ |
| 196 | # Make sure edksetup.sh only will be called once and that we don't rebuild |
| 197 | # BaseTools again and again. |
| 198 | $(EDK2_PATH)/Conf/target.txt: |
Jens Wiklander | 650f298 | 2017-04-05 10:08:59 +0200 | [diff] [blame] | 199 | set -e && cd $(EDK2_PATH) && source edksetup.sh && \ |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 200 | $(MAKE) -j1 -C $(EDK2_PATH)/BaseTools |
| 201 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 202 | .PHONY: edk2-common |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 203 | edk2-common: $(EDK2_PATH)/Conf/target.txt |
Jens Wiklander | 650f298 | 2017-04-05 10:08:59 +0200 | [diff] [blame] | 204 | set -e && cd $(EDK2_PATH) && source edksetup.sh && \ |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 205 | $(call edk2-call) |
| 206 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 207 | .PHONY: edk2-clean-common |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 208 | edk2-clean-common: |
Jens Wiklander | 650f298 | 2017-04-05 10:08:59 +0200 | [diff] [blame] | 209 | set -e && cd $(EDK2_PATH) && source edksetup.sh && \ |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 210 | $(call edk2-call) clean && \ |
Victor Chong | 2c429d7 | 2017-06-06 15:10:07 +0100 | [diff] [blame] | 211 | $(MAKE) -j1 -C $(EDK2_PATH)/BaseTools clean |
| 212 | rm -rf $(EDK2_PATH)/Build |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 213 | rm -rf $(EDK2_PATH)/Conf/.cache |
Victor Chong | 2c429d7 | 2017-06-06 15:10:07 +0100 | [diff] [blame] | 214 | rm -f $(EDK2_PATH)/Conf/build_rule.txt |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 215 | rm -f $(EDK2_PATH)/Conf/target.txt |
Victor Chong | 2c429d7 | 2017-06-06 15:10:07 +0100 | [diff] [blame] | 216 | rm -f $(EDK2_PATH)/Conf/tools_def.txt |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 217 | |
Igor Opaniuk | 97d0529 | 2016-10-26 14:46:14 +0300 | [diff] [blame] | 218 | ################################################################################ |
| 219 | # QEMU / QEMUv8 |
| 220 | ################################################################################ |
| 221 | QEMU_CONFIGURE_PARAMS_COMMON = --cc="$(CCACHE)gcc" --extra-cflags="-Wno-error" |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 222 | |
Igor Opaniuk | 97d0529 | 2016-10-26 14:46:14 +0300 | [diff] [blame] | 223 | ifeq ($(QEMU_VIRTFS_ENABLE),y) |
Jerome Forissier | 23b4131 | 2016-11-12 16:02:01 +0100 | [diff] [blame] | 224 | QEMU_CONFIGURE_PARAMS_COMMON += --enable-virtfs |
Igor Opaniuk | 97d0529 | 2016-10-26 14:46:14 +0300 | [diff] [blame] | 225 | QEMU_EXTRA_ARGS +=\ |
| 226 | -fsdev local,id=fsdev0,path=$(QEMU_VIRTFS_HOST_DIR),security_model=none \ |
| 227 | -device virtio-9p-device,fsdev=fsdev0,mount_tag=host |
| 228 | endif |
Igor Opaniuk | 0aea4ef | 2017-01-13 12:52:00 +0200 | [diff] [blame] | 229 | |
| 230 | ifeq ($(QEMU_USERNET_ENABLE),y) |
| 231 | QEMU_EXTRA_ARGS +=\ |
| 232 | -netdev user,id=vmnic -device virtio-net-device,netdev=vmnic |
| 233 | endif |
Jerome Forissier | efd5629 | 2017-01-31 17:46:10 +0100 | [diff] [blame] | 234 | |
| 235 | define run-help |
| 236 | @echo |
| 237 | @echo \* QEMU is now waiting to start the execution |
| 238 | @echo \* Start execution with either a \'c\' followed by \<enter\> in the QEMU console or |
| 239 | @echo \* attach a debugger and continue from there. |
| 240 | @echo \* |
| 241 | @echo \* To run OP-TEE tests, use the xtest command in the \'Normal World\' terminal |
| 242 | @echo \* Enter \'xtest -h\' for help. |
| 243 | @echo |
| 244 | endef |
| 245 | |
Jerome Forissier | 5b58525 | 2017-08-03 13:22:21 +0200 | [diff] [blame] | 246 | ifneq (, $(LAUNCH_TERMINAL)) |
Alex Bennée | 0758060 | 2017-07-07 14:26:51 +0100 | [diff] [blame] | 247 | define launch-terminal |
| 248 | @nc -z 127.0.0.1 $(1) || \ |
| 249 | $(LAUNCH_TERMINAL) $(SOC_TERM_PATH)/soc_term $(1) & |
| 250 | endef |
| 251 | else |
Jerome Forissier | efd5629 | 2017-01-31 17:46:10 +0100 | [diff] [blame] | 252 | gnome-terminal := $(shell command -v gnome-terminal 2>/dev/null) |
| 253 | xterm := $(shell command -v xterm 2>/dev/null) |
| 254 | ifdef gnome-terminal |
| 255 | # Note: the title option (-t) is ignored with gnome-terminal versions |
| 256 | # >= 3.14 and < 3.20 |
| 257 | define launch-terminal |
| 258 | @nc -z 127.0.0.1 $(1) || \ |
| 259 | $(gnome-terminal) -t "$(2)" -x $(SOC_TERM_PATH)/soc_term $(1) & |
| 260 | endef |
| 261 | else |
| 262 | ifdef xterm |
| 263 | define launch-terminal |
| 264 | @nc -z 127.0.0.1 $(1) || \ |
| 265 | $(xterm) -title $(2) -e $(BASH) -c "$(SOC_TERM_PATH)/soc_term $(1)" & |
| 266 | endef |
| 267 | else |
| 268 | check-terminal := @echo "Error: could not find gnome-terminal nor xterm" ; false |
| 269 | endif |
| 270 | endif |
Alex Bennée | 0758060 | 2017-07-07 14:26:51 +0100 | [diff] [blame] | 271 | endif |
Jerome Forissier | efd5629 | 2017-01-31 17:46:10 +0100 | [diff] [blame] | 272 | |
| 273 | define wait-for-ports |
| 274 | @while ! nc -z 127.0.0.1 $(1) || ! nc -z 127.0.0.1 $(2); do sleep 1; done |
| 275 | endef |
| 276 | |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 277 | ################################################################################ |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 278 | # OP-TEE |
| 279 | ################################################################################ |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 280 | OPTEE_OS_COMMON_FLAGS ?= \ |
| 281 | $(OPTEE_OS_COMMON_EXTRA_FLAGS) \ |
| 282 | CROSS_COMPILE=$(CROSS_COMPILE_S_USER) \ |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 283 | CROSS_COMPILE_core=$(CROSS_COMPILE_S_KERNEL) \ |
Victor Chong | badc792 | 2015-12-08 17:23:20 +0000 | [diff] [blame] | 284 | CROSS_COMPILE_ta_arm64=$(AARCH64_CROSS_COMPILE) \ |
| 285 | CROSS_COMPILE_ta_arm32=$(AARCH32_CROSS_COMPILE) \ |
Pascal Brand | 23ef205 | 2016-03-09 15:25:01 +0100 | [diff] [blame] | 286 | CFG_TEE_CORE_LOG_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL) \ |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 287 | DEBUG=$(DEBUG) \ |
| 288 | CFG_TEE_BENCHMARK=$(CFG_TEE_BENCHMARK) |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 289 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 290 | .PHONY: optee-os-common |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 291 | optee-os-common: |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 292 | $(MAKE) -C $(OPTEE_OS_PATH) $(OPTEE_OS_COMMON_FLAGS) |
| 293 | |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 294 | OPTEE_OS_CLEAN_COMMON_FLAGS ?= $(OPTEE_OS_COMMON_EXTRA_FLAGS) |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 295 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 296 | .PHONY: optee-os-clean-common |
Igor Opaniuk | 4f667cd | 2017-05-31 14:11:56 +0300 | [diff] [blame] | 297 | ifeq ($(CFG_TEE_BENCHMARK),y) |
| 298 | optee-os-clean-common: benchmark-app-clean-common |
| 299 | endif |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 300 | optee-os-clean-common: xtest-clean optee-examples-clean |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 301 | $(MAKE) -C $(OPTEE_OS_PATH) $(OPTEE_OS_CLEAN_COMMON_FLAGS) clean |
| 302 | |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 303 | OPTEE_CLIENT_COMMON_FLAGS ?= CROSS_COMPILE=$(CROSS_COMPILE_NS_USER) \ |
| 304 | CFG_TEE_BENCHMARK=$(CFG_TEE_BENCHMARK) \ |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 305 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 306 | .PHONY: optee-client-common |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 307 | optee-client-common: |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 308 | $(MAKE) -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_COMMON_FLAGS) |
| 309 | |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 310 | # OPTEE_CLIENT_CLEAN_COMMON_FLAGS can be defined in specific makefiles |
| 311 | # (hikey.mk,...) if necessary |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 312 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 313 | .PHONY: optee-client-clean-common |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 314 | optee-client-clean-common: |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 315 | $(MAKE) -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_CLEAN_COMMON_FLAGS) \ |
| 316 | clean |
| 317 | |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 318 | ################################################################################ |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 319 | # xtest / optee_test |
| 320 | ################################################################################ |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 321 | XTEST_COMMON_FLAGS ?= CROSS_COMPILE_HOST=$(CROSS_COMPILE_NS_USER)\ |
| 322 | CROSS_COMPILE_TA=$(CROSS_COMPILE_S_USER) \ |
| 323 | TA_DEV_KIT_DIR=$(OPTEE_OS_TA_DEV_KIT_DIR) \ |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 324 | OPTEE_CLIENT_EXPORT=$(OPTEE_CLIENT_EXPORT) \ |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 325 | COMPILE_NS_USER=$(COMPILE_NS_USER) \ |
Igor Opaniuk | 4f667cd | 2017-05-31 14:11:56 +0300 | [diff] [blame] | 326 | O=$(OPTEE_TEST_OUT_PATH) |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 327 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 328 | .PHONY: xtest-common |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 329 | xtest-common: optee-os optee-client |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 330 | $(MAKE) -C $(OPTEE_TEST_PATH) $(XTEST_COMMON_FLAGS) |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 331 | |
Etienne Carriere | 965db7b | 2017-01-10 17:50:21 +0100 | [diff] [blame] | 332 | XTEST_CLEAN_COMMON_FLAGS ?= O=$(OPTEE_TEST_OUT_PATH) \ |
| 333 | TA_DEV_KIT_DIR=$(OPTEE_OS_TA_DEV_KIT_DIR) \ |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 334 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 335 | .PHONY: xtest-clean-common |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 336 | xtest-clean-common: |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 337 | $(MAKE) -C $(OPTEE_TEST_PATH) $(XTEST_CLEAN_COMMON_FLAGS) clean |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 338 | |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 339 | XTEST_PATCH_COMMON_FLAGS ?= $(XTEST_COMMON_FLAGS) |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 340 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 341 | .PHONY: xtest-patch-common |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 342 | xtest-patch-common: |
| 343 | $(MAKE) -C $(OPTEE_TEST_PATH) $(XTEST_PATCH_COMMON_FLAGS) patch |
Victor Chong | 8519bcf | 2016-07-15 08:43:03 +0100 | [diff] [blame] | 344 | |
| 345 | ################################################################################ |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 346 | # sample applications / optee_examples |
Victor Chong | 8519bcf | 2016-07-15 08:43:03 +0100 | [diff] [blame] | 347 | ################################################################################ |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 348 | OPTEE_EXAMPLES_COMMON_FLAGS ?= HOST_CROSS_COMPILE=$(CROSS_COMPILE_NS_USER)\ |
Victor Chong | 8519bcf | 2016-07-15 08:43:03 +0100 | [diff] [blame] | 349 | TA_CROSS_COMPILE=$(CROSS_COMPILE_S_USER) \ |
| 350 | TA_DEV_KIT_DIR=$(OPTEE_OS_TA_DEV_KIT_DIR) \ |
| 351 | TEEC_EXPORT=$(OPTEE_CLIENT_EXPORT) |
| 352 | |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 353 | .PHONY: optee-examples-common |
| 354 | optee-examples-common: optee-os optee-client |
| 355 | $(MAKE) -C $(OPTEE_EXAMPLES_PATH) $(OPTEE_EXAMPLES_COMMON_FLAGS) |
Victor Chong | 8519bcf | 2016-07-15 08:43:03 +0100 | [diff] [blame] | 356 | |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 357 | OPTEE_EXAMPLES_CLEAN_COMMON_FLAGS ?= TA_DEV_KIT_DIR=$(OPTEE_OS_TA_DEV_KIT_DIR) |
Victor Chong | 8519bcf | 2016-07-15 08:43:03 +0100 | [diff] [blame] | 358 | |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 359 | .PHONY: optee-examples-clean-common |
| 360 | optee-examples-clean-common: |
| 361 | $(MAKE) -C $(OPTEE_EXAMPLES_PATH) \ |
| 362 | $(OPTEE_EXAMPLES_CLEAN_COMMON_FLAGS) clean |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 363 | |
| 364 | ################################################################################ |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 365 | # benchmark_app |
| 366 | ################################################################################ |
Yves Lefloch | 221154a | 2017-08-02 17:36:58 +0200 | [diff] [blame] | 367 | BENCHMARK_APP_COMMON_FLAGS ?= CROSS_COMPILE=$(CROSS_COMPILE_NS_USER) \ |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 368 | TEEC_EXPORT=$(OPTEE_CLIENT_EXPORT) \ |
| 369 | TEEC_INTERNAL_INCLUDES=$(OPTEE_CLIENT_PATH)/libteec |
| 370 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 371 | .PHONY: benchmark-app-common |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 372 | benchmark-app-common: optee-os optee-client |
| 373 | $(MAKE) -C $(BENCHMARK_APP_PATH) $(BENCHMARK_APP_COMMON_FLAGS) |
| 374 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 375 | .PHONY: benchmark-app-clean-common |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 376 | benchmark-app-clean-common: |
| 377 | $(MAKE) -C $(BENCHMARK_APP_PATH) clean |
| 378 | |
| 379 | ################################################################################ |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 380 | # rootfs |
| 381 | ################################################################################ |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 382 | .PHONY: update_rootfs-common |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 383 | update_rootfs-common: busybox filelist-tee |
| 384 | cat $(GEN_ROOTFS_PATH)/filelist-final.txt > $(GEN_ROOTFS_PATH)/filelist.tmp |
| 385 | cat $(GEN_ROOTFS_FILELIST) >> $(GEN_ROOTFS_PATH)/filelist.tmp |
| 386 | cd $(GEN_ROOTFS_PATH) && \ |
| 387 | $(LINUX_PATH)/usr/gen_init_cpio $(GEN_ROOTFS_PATH)/filelist.tmp | \ |
| 388 | gzip > $(GEN_ROOTFS_PATH)/filesystem.cpio.gz |
| 389 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 390 | .PHONY: update_rootfs-clean-common |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 391 | update_rootfs-clean-common: |
| 392 | rm -f $(GEN_ROOTFS_PATH)/filesystem.cpio.gz |
| 393 | rm -f $(GEN_ROOTFS_PATH)/filelist-all.txt |
| 394 | rm -f $(GEN_ROOTFS_PATH)/filelist-tmp.txt |
| 395 | rm -f $(GEN_ROOTFS_FILELIST) |
| 396 | |
Victor Chong | 46f8585 | 2017-08-09 08:26:41 +0100 | [diff] [blame] | 397 | .PHONY: filelist-tee-common |
Igor Opaniuk | 4f667cd | 2017-05-31 14:11:56 +0300 | [diff] [blame] | 398 | ifeq ($(CFG_TEE_BENCHMARK),y) |
| 399 | filelist-tee-common: benchmark-app |
| 400 | endif |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 401 | filelist-tee-common: fl:=$(GEN_ROOTFS_FILELIST) |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 402 | filelist-tee-common: optee-client xtest optee-examples |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 403 | @echo "# filelist-tee-common /start" > $(fl) |
| 404 | @echo "dir /lib/optee_armtz 755 0 0" >> $(fl) |
Igor Opaniuk | 584efe5 | 2017-08-07 01:41:48 +0300 | [diff] [blame] | 405 | @if [ -e $(OPTEE_EXAMPLES_PATH)/out/ca ]; then \ |
| 406 | for file in $(OPTEE_EXAMPLES_PATH)/out/ca/*; do \ |
| 407 | echo "file /usr/bin/$$(basename $$file)" \ |
| 408 | "$$file 755 0 0" >> $(fl); \ |
| 409 | done; \ |
| 410 | fi |
| 411 | @if [ -e $(OPTEE_EXAMPLES_PATH)/out/ta ]; then \ |
| 412 | for file in $(OPTEE_EXAMPLES_PATH)/out/ta/*; do \ |
| 413 | echo "file /lib/optee_armtz/$$(basename $$file)" \ |
| 414 | "$$example 755 0 0" >> $(fl); \ |
| 415 | done; \ |
| 416 | fi |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 417 | @echo "# xtest / optee_test" >> $(fl) |
| 418 | @find $(OPTEE_TEST_OUT_PATH) -type f -name "xtest" | \ |
| 419 | sed 's/\(.*\)/file \/bin\/xtest \1 755 0 0/g' >> $(fl) |
| 420 | @find $(OPTEE_TEST_OUT_PATH) -name "*.ta" | \ |
| 421 | sed 's/\(.*\)\/\(.*\)/file \/lib\/optee_armtz\/\2 \1\/\2 444 0 0/g' \ |
| 422 | >> $(fl) |
Igor Opaniuk | 27edfc7 | 2016-10-25 18:33:54 +0300 | [diff] [blame] | 423 | @if [ -e $(BENCHMARK_APP_PATH)/benchmark ]; then \ |
| 424 | echo "file /bin/benchmark" \ |
| 425 | "$(BENCHMARK_APP_PATH)/benchmark 755 0 0" >> $(fl); \ |
| 426 | fi |
Igor Opaniuk | 0aea4ef | 2017-01-13 12:52:00 +0200 | [diff] [blame] | 427 | @if [ "$(QEMU_USERNET_ENABLE)" = "y" ]; then \ |
| 428 | echo "slink /etc/rc.d/S02_udhcp_networking /etc/init.d/udhcpc 755 0 0" \ |
| 429 | >> $(fl); \ |
| 430 | fi |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 431 | @echo "# Secure storage dir" >> $(fl) |
| 432 | @echo "dir /data 755 0 0" >> $(fl) |
| 433 | @echo "dir /data/tee 755 0 0" >> $(fl) |
| 434 | @if [ -e $(OPTEE_GENDRV_MODULE) ]; then \ |
| 435 | echo "# OP-TEE device" >> $(fl); \ |
| 436 | echo "dir /lib/modules 755 0 0" >> $(fl); \ |
| 437 | echo "dir /lib/modules/$(call KERNEL_VERSION) 755 0 0" \ |
| 438 | >> $(fl); \ |
| 439 | echo "file /lib/modules/$(call KERNEL_VERSION)/optee.ko" \ |
| 440 | "$(OPTEE_GENDRV_MODULE) 755 0 0" \ |
| 441 | >> $(fl); \ |
| 442 | fi |
| 443 | @echo "# OP-TEE Client" >> $(fl) |
| 444 | @echo "file /bin/tee-supplicant $(OPTEE_CLIENT_EXPORT)/bin/tee-supplicant 755 0 0" \ |
| 445 | >> $(fl) |
| 446 | @echo "file /lib/libteec.so.1.0 $(OPTEE_CLIENT_EXPORT)/lib/libteec.so.1.0 755 0 0" \ |
| 447 | >> $(fl) |
| 448 | @echo "slink /lib/libteec.so.1 libteec.so.1.0 755 0 0" >> $(fl) |
| 449 | @echo "slink /lib/libteec.so libteec.so.1 755 0 0" >> $(fl) |
| 450 | @if [ -e $(OPTEE_CLIENT_EXPORT)/lib/libsqlfs.so.1.0 ]; then \ |
| 451 | echo "file /lib/libsqlfs.so.1.0" \ |
| 452 | "$(OPTEE_CLIENT_EXPORT)/lib/libsqlfs.so.1.0 755 0 0" \ |
| 453 | >> $(fl); \ |
| 454 | echo "slink /lib/libsqlfs.so.1 libsqlfs.so.1.0 755 0 0" >> $(fl); \ |
| 455 | echo "slink /lib/libsqlfs.so libsqlfs.so.1 755 0 0" >> $(fl); \ |
| 456 | fi |
Jerome Forissier | 1333db4 | 2017-01-18 10:20:51 +0100 | [diff] [blame] | 457 | @echo "file /etc/init.d/optee $(BUILD_PATH)/init.d.optee 755 0 0" >> $(fl) |
| 458 | @echo "slink /etc/rc.d/S09_optee /etc/init.d/optee 755 0 0" >> $(fl) |
Etienne Carriere | 5e11351 | 2016-10-21 10:13:57 +0200 | [diff] [blame] | 459 | @echo "# filelist-tee-common /end" >> $(fl) |