Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 1 | # |
| 2 | # Common definition to all platforms |
| 3 | # |
| 4 | |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 5 | BASH ?= bash |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 6 | ROOT ?= $(shell pwd)/.. |
| 7 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 8 | LINUX_PATH ?= $(ROOT)/linux |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 9 | GEN_ROOTFS_PATH ?= $(ROOT)/gen_rootfs |
| 10 | GEN_ROOTFS_FILELIST ?= $(GEN_ROOTFS_PATH)/filelist-tee.txt |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 11 | OPTEE_OS_PATH ?= $(ROOT)/optee_os |
| 12 | OPTEE_CLIENT_PATH ?= $(ROOT)/optee_client |
| 13 | OPTEE_CLIENT_EXPORT ?= $(OPTEE_CLIENT_PATH)/out/export |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 14 | OPTEE_TEST_PATH ?= $(ROOT)/optee_test |
| 15 | OPTEE_TEST_OUT_PATH ?= $(ROOT)/optee_test/out |
| 16 | |
Pascal Brand | 23ef205 | 2016-03-09 15:25:01 +0100 | [diff] [blame] | 17 | CFG_TEE_CORE_LOG_LEVEL ?= 3 |
| 18 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 19 | CCACHE ?= $(shell which ccache) # Don't remove this comment (space is needed) |
| 20 | |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 21 | |
| 22 | ################################################################################ |
| 23 | # Check coherency of compilation mode |
| 24 | ################################################################################ |
| 25 | |
| 26 | ifneq ($(COMPILE_NS_USER),) |
| 27 | ifeq ($(COMPILE_NS_KERNEL),) |
| 28 | $(error COMPILE_NS_KERNEL must be defined as COMPILE_NS_USER=$(COMPILE_NS_USER) is defined) |
| 29 | endif |
| 30 | ifeq (,$(filter $(COMPILE_NS_USER),32 64)) |
| 31 | $(error COMPILE_NS_USER=$(COMPILE_NS_USER) - Should be 32 or 64) |
| 32 | endif |
| 33 | endif |
| 34 | |
| 35 | ifneq ($(COMPILE_NS_KERNEL),) |
| 36 | ifeq ($(COMPILE_NS_USER),) |
| 37 | $(error COMPILE_NS_USER must be defined as COMPILE_NS_KERNEL=$(COMPILE_NS_KERNEL) is defined) |
| 38 | endif |
| 39 | ifeq (,$(filter $(COMPILE_NS_KERNEL),32 64)) |
| 40 | $(error COMPILE_NS_KERNEL=$(COMPILE_NS_KERNEL) - Should be 32 or 64) |
| 41 | endif |
| 42 | endif |
| 43 | |
| 44 | ifeq ($(COMPILE_NS_KERNEL),32) |
| 45 | ifneq ($(COMPILE_NS_USER),32) |
| 46 | $(error COMPILE_NS_USER=$(COMPILE_NS_USER) - Should be 32 as COMPILE_NS_KERNEL=$(COMPILE_NS_KERNEL)) |
| 47 | endif |
| 48 | endif |
| 49 | |
| 50 | ifneq ($(COMPILE_S_USER),) |
| 51 | ifeq ($(COMPILE_S_KERNEL),) |
| 52 | $(error COMPILE_S_KERNEL must be defined as COMPILE_S_USER=$(COMPILE_S_USER) is defined) |
| 53 | endif |
| 54 | ifeq (,$(filter $(COMPILE_S_USER),32 64)) |
| 55 | $(error COMPILE_S_USER=$(COMPILE_S_USER) - Should be 32 or 64) |
| 56 | endif |
| 57 | endif |
| 58 | |
| 59 | ifneq ($(COMPILE_S_KERNEL),) |
| 60 | OPTEE_OS_COMMON_EXTRA_FLAGS ?= O=out/arm |
| 61 | OPTEE_OS_BIN ?= $(OPTEE_OS_PATH)/out/arm/core/tee.bin |
| 62 | ifeq ($(COMPILE_S_USER),) |
| 63 | $(error COMPILE_S_USER must be defined as COMPILE_S_KERNEL=$(COMPILE_S_KERNEL) is defined) |
| 64 | endif |
| 65 | ifeq (,$(filter $(COMPILE_S_KERNEL),32 64)) |
| 66 | $(error COMPILE_S_KERNEL=$(COMPILE_S_KERNEL) - Should be 32 or 64) |
| 67 | endif |
| 68 | endif |
| 69 | |
| 70 | ifeq ($(COMPILE_S_KERNEL),32) |
| 71 | ifneq ($(COMPILE_S_USER),32) |
| 72 | $(error COMPILE_S_USER=$(COMPILE_S_USER) - Should be 32 as COMPILE_S_KERNEL=$(COMPILE_S_KERNEL)) |
| 73 | endif |
| 74 | endif |
| 75 | |
| 76 | |
| 77 | ################################################################################ |
| 78 | # set the compiler when COMPILE_xxx are defined |
| 79 | ################################################################################ |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 80 | CROSS_COMPILE_NS_USER ?= "$(CCACHE)$(AARCH$(COMPILE_NS_USER)_CROSS_COMPILE)" |
| 81 | CROSS_COMPILE_NS_KERNEL ?= "$(CCACHE)$(AARCH$(COMPILE_NS_KERNEL)_CROSS_COMPILE)" |
| 82 | CROSS_COMPILE_S_USER ?= "$(CCACHE)$(AARCH$(COMPILE_S_USER)_CROSS_COMPILE)" |
| 83 | CROSS_COMPILE_S_KERNEL ?= "$(CCACHE)$(AARCH$(COMPILE_S_KERNEL)_CROSS_COMPILE)" |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 84 | |
| 85 | ifeq ($(COMPILE_S_USER),32) |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 86 | OPTEE_OS_TA_DEV_KIT_DIR ?= $(OPTEE_OS_PATH)/out/arm/export-ta_arm32 |
| 87 | endif |
| 88 | ifeq ($(COMPILE_S_USER),64) |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 89 | OPTEE_OS_TA_DEV_KIT_DIR ?= $(OPTEE_OS_PATH)/out/arm/export-ta_arm64 |
| 90 | endif |
| 91 | |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 92 | ifeq ($(COMPILE_S_KERNEL),64) |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 93 | OPTEE_OS_COMMON_EXTRA_FLAGS += CFG_ARM64_core=y |
| 94 | endif |
| 95 | |
| 96 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 97 | ################################################################################ |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 98 | # defines, macros, configuration etc |
| 99 | ################################################################################ |
| 100 | define KERNEL_VERSION |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 101 | $(shell cd $(LINUX_PATH) && $(MAKE) --no-print-directory kernelversion) |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 102 | endef |
| 103 | DEBUG ?= 0 |
| 104 | |
| 105 | ################################################################################ |
Pascal Brand | cb45260 | 2015-10-13 10:46:33 +0200 | [diff] [blame] | 106 | # default target is all |
| 107 | ################################################################################ |
| 108 | all: |
| 109 | |
| 110 | ################################################################################ |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 111 | # Busybox |
| 112 | ################################################################################ |
| 113 | BUSYBOX_COMMON_TARGET ?= TOBEDEFINED |
| 114 | BUSYBOX_CLEAN_COMMON_TARGET ?= TOBEDEFINED |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 115 | |
| 116 | busybox-common: linux |
| 117 | cd $(GEN_ROOTFS_PATH) && \ |
Pascal Brand | efe5659 | 2016-03-03 10:46:52 +0100 | [diff] [blame] | 118 | CROSS_COMPILE=$(CROSS_COMPILE_NS_USER) \ |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 119 | PATH=${PATH}:$(LINUX_PATH)/usr \ |
| 120 | $(GEN_ROOTFS_PATH)/generate-cpio-rootfs.sh \ |
| 121 | $(BUSYBOX_COMMON_TARGET) |
| 122 | |
| 123 | busybox-clean-common: |
| 124 | cd $(GEN_ROOTFS_PATH) && \ |
| 125 | $(GEN_ROOTFS_PATH)/generate-cpio-rootfs.sh \ |
| 126 | $(BUSYBOX_CLEAN_COMMON_TARGET) |
| 127 | |
| 128 | busybox-cleaner-common: |
| 129 | rm -rf $(GEN_ROOTFS_PATH)/build |
| 130 | rm -rf $(GEN_ROOTFS_PATH)/filelist-final.txt |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 131 | |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 132 | ################################################################################ |
| 133 | # Linux |
| 134 | ################################################################################ |
| 135 | LINUX_COMMON_FLAGS ?= LOCALVERSION= CROSS_COMPILE=$(CROSS_COMPILE_NS_KERNEL) |
| 136 | |
| 137 | linux-common: linux-defconfig |
| 138 | $(MAKE) -C $(LINUX_PATH) $(LINUX_COMMON_FLAGS) |
| 139 | |
Jerome Forissier | e100238 | 2015-11-26 11:36:00 +0100 | [diff] [blame] | 140 | $(LINUX_PATH)/.config: $(LINUX_DEFCONFIG_COMMON_FILES) |
| 141 | cd $(LINUX_PATH) && \ |
| 142 | ARCH=$(LINUX_DEFCONFIG_COMMON_ARCH) \ |
| 143 | scripts/kconfig/merge_config.sh $(LINUX_DEFCONFIG_COMMON_FILES) |
| 144 | |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 145 | linux-defconfig-clean-common: |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 146 | rm -f $(LINUX_PATH)/.config |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 147 | |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 148 | # LINUX_CLEAN_COMMON_FLAGS can be defined in specific makefiles (hikey.mk,...) |
| 149 | # if necessary |
| 150 | |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 151 | linux-clean-common: linux-defconfig-clean |
| 152 | $(MAKE) -C $(LINUX_PATH) $(LINUX_CLEAN_COMMON_FLAGS) clean |
| 153 | |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 154 | # LINUX_CLEANER_COMMON_FLAGS can be defined in specific makefiles (hikey.mk,...) |
| 155 | # if necessary |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 156 | |
| 157 | linux-cleaner-common: linux-defconfig-clean |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 158 | $(MAKE) -C $(LINUX_PATH) $(LINUX_CLEANER_COMMON_FLAGS) distclean |
Pascal Brand | e3d8598 | 2015-09-10 17:20:42 +0200 | [diff] [blame] | 159 | |
Pascal Brand | 440ef9c | 2015-09-08 16:01:58 +0200 | [diff] [blame] | 160 | ################################################################################ |
Pascal Brand | 9a0f50f | 2015-09-08 15:34:17 +0200 | [diff] [blame] | 161 | # EDK2 / Tianocore |
| 162 | ################################################################################ |
| 163 | # Make sure edksetup.sh only will be called once and that we don't rebuild |
| 164 | # BaseTools again and again. |
| 165 | $(EDK2_PATH)/Conf/target.txt: |
| 166 | set -e && cd $(EDK2_PATH) && $(BASH) edksetup.sh && \ |
| 167 | $(MAKE) -j1 -C $(EDK2_PATH)/BaseTools |
| 168 | |
| 169 | edk2-common: $(EDK2_PATH)/Conf/target.txt |
| 170 | set -e && cd $(EDK2_PATH) && $(BASH) edksetup.sh && \ |
| 171 | $(call edk2-call) |
| 172 | |
| 173 | edk2-clean-common: |
| 174 | set -e && cd $(EDK2_PATH) && $(BASH) edksetup.sh && \ |
| 175 | $(call edk2-call) clean && \ |
| 176 | $(MAKE) -j1 -C $(EDK2_PATH)/BaseTools clean && \ |
| 177 | rm -f $(EDK2_PATH)/Conf/target.txt |
| 178 | |
| 179 | ################################################################################ |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 180 | # OP-TEE |
| 181 | ################################################################################ |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 182 | OPTEE_OS_COMMON_FLAGS ?= \ |
| 183 | $(OPTEE_OS_COMMON_EXTRA_FLAGS) \ |
| 184 | CROSS_COMPILE=$(CROSS_COMPILE_S_USER) \ |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 185 | CROSS_COMPILE_core=$(CROSS_COMPILE_S_KERNEL) \ |
Victor Chong | badc792 | 2015-12-08 17:23:20 +0000 | [diff] [blame] | 186 | CROSS_COMPILE_ta_arm64=$(AARCH64_CROSS_COMPILE) \ |
| 187 | CROSS_COMPILE_ta_arm32=$(AARCH32_CROSS_COMPILE) \ |
Pascal Brand | 23ef205 | 2016-03-09 15:25:01 +0100 | [diff] [blame] | 188 | CFG_TEE_CORE_LOG_LEVEL=$(CFG_TEE_CORE_LOG_LEVEL) \ |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 189 | DEBUG=$(DEBUG) |
| 190 | |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 191 | optee-os-common: |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 192 | $(MAKE) -C $(OPTEE_OS_PATH) $(OPTEE_OS_COMMON_FLAGS) |
| 193 | |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 194 | OPTEE_OS_CLEAN_COMMON_FLAGS ?= $(OPTEE_OS_COMMON_EXTRA_FLAGS) |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 195 | |
Pascal Brand | b130ea2 | 2015-10-13 13:18:36 +0200 | [diff] [blame] | 196 | optee-os-clean-common: xtest-clean |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 197 | $(MAKE) -C $(OPTEE_OS_PATH) $(OPTEE_OS_CLEAN_COMMON_FLAGS) clean |
| 198 | |
| 199 | OPTEE_CLIENT_COMMON_FLAGS ?= CROSS_COMPILE=$(CROSS_COMPILE_NS_USER) |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 200 | |
| 201 | optee-client-common: |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 202 | $(MAKE) -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_COMMON_FLAGS) |
| 203 | |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 204 | # OPTEE_CLIENT_CLEAN_COMMON_FLAGS can be defined in specific makefiles |
| 205 | # (hikey.mk,...) if necessary |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 206 | |
| 207 | optee-client-clean-common: |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 208 | $(MAKE) -C $(OPTEE_CLIENT_PATH) $(OPTEE_CLIENT_CLEAN_COMMON_FLAGS) \ |
| 209 | clean |
| 210 | |
Pascal Brand | 070d955 | 2015-09-01 15:33:22 +0200 | [diff] [blame] | 211 | ################################################################################ |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 212 | # xtest / optee_test |
| 213 | ################################################################################ |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 214 | XTEST_COMMON_FLAGS ?= CROSS_COMPILE_HOST=$(CROSS_COMPILE_NS_USER)\ |
| 215 | CROSS_COMPILE_TA=$(CROSS_COMPILE_S_USER) \ |
| 216 | TA_DEV_KIT_DIR=$(OPTEE_OS_TA_DEV_KIT_DIR) \ |
| 217 | CFG_DEV_PATH=$(ROOT) \ |
Pascal Brand | 6044eb5 | 2016-02-23 15:48:31 +0100 | [diff] [blame] | 218 | COMPILE_NS_USER=$(COMPILE_NS_USER) \ |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 219 | O=$(OPTEE_TEST_OUT_PATH) |
| 220 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 221 | xtest-common: optee-os optee-client |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 222 | $(MAKE) -C $(OPTEE_TEST_PATH) $(XTEST_COMMON_FLAGS) |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 223 | |
Victor Chong | 87f5fcf | 2015-11-26 10:52:52 +0900 | [diff] [blame] | 224 | XTEST_CLEAN_COMMON_FLAGS ?= TA_DEV_KIT_DIR=$(OPTEE_OS_TA_DEV_KIT_DIR) |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 225 | |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 226 | xtest-clean-common: |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 227 | $(MAKE) -C $(OPTEE_TEST_PATH) $(XTEST_CLEAN_COMMON_FLAGS) clean |
Pascal Brand | d6536da | 2015-09-01 10:38:43 +0200 | [diff] [blame] | 228 | |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 229 | XTEST_PATCH_COMMON_FLAGS ?= $(XTEST_COMMON_FLAGS) |
Jerome Forissier | ae45fbf | 2015-09-04 09:40:17 +0200 | [diff] [blame] | 230 | |
Pascal Brand | dc83b9a | 2015-09-24 02:43:25 +0200 | [diff] [blame] | 231 | xtest-patch-common: |
| 232 | $(MAKE) -C $(OPTEE_TEST_PATH) $(XTEST_PATCH_COMMON_FLAGS) patch |