b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | include $(INCLUDE_DIR)/prereq.mk |
| 2 | |
| 3 | PKG_NAME ?= optee-os |
| 4 | |
| 5 | ifndef PKG_SOURCE_PROTO |
| 6 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz |
| 7 | PKG_SOURCE_URL_FILE:=$(PKG_VERSION).tar.gz |
| 8 | PKG_SOURCE_URL = https://github.com/OP-TEE/optee_os/archive/refs/tags/ |
| 9 | TAR_OPTIONS+= --transform 's/optee_os/$(PKG_NAME)/' |
| 10 | endif |
| 11 | |
| 12 | PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) |
| 13 | |
| 14 | PKG_TARGETS := bin |
| 15 | PKG_FLAGS:=nonshared |
| 16 | |
| 17 | PKG_LICENSE:=BSD 2-Clause |
| 18 | PKG_LICENSE_FILES:=LICENSE |
| 19 | |
| 20 | PKG_BUILD_PARALLEL ?= 1 |
| 21 | |
| 22 | $(eval $(call TestHostCommand,python3-cryptography, \ |
| 23 | Please install the Python3 cryptography module, \ |
| 24 | $(STAGING_DIR_HOST)/bin/python3 -c 'import cryptography')) |
| 25 | |
| 26 | $(eval $(call TestHostCommand,python3-pyelftools, \ |
| 27 | Please install the Python3 pyelftools module, \ |
| 28 | $(STAGING_DIR_HOST)/bin/python3 -c 'import elftools')) |
| 29 | |
| 30 | export GCC_HONOUR_COPTS=s |
| 31 | |
| 32 | define Package/optee-os/install/default |
| 33 | $(CP) $(patsubst %,$(PKG_BUILD_DIR)/out/arm-plat-$(PLAT)/core/%,$(OPTEE_IMAGE)) $(1)/ |
| 34 | endef |
| 35 | |
| 36 | Package/optee-os/install = $(Package/optee-os/install/default) |
| 37 | |
| 38 | define Optee-os/Init |
| 39 | BUILD_TARGET:= |
| 40 | BUILD_SUBTARGET:= |
| 41 | BUILD_DEVICES:= |
| 42 | NAME:= |
| 43 | DEPENDS:= |
| 44 | HIDDEN:= |
| 45 | DEFAULT:= |
| 46 | VARIANT:=$(1) |
| 47 | PLAT:=$(1) |
| 48 | PLAT_FLAVOR:= |
| 49 | OPTEE_IMAGE:=tee-header_v2.bin tee-pager_v2.bin tee-pageable_v2.bin |
| 50 | endef |
| 51 | |
| 52 | TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET)) |
| 53 | |
| 54 | define Build/Optee-os/Target |
| 55 | $(eval $(call Optee-os/Init,$(1))) |
| 56 | $(eval $(call Optee-os/Default,$(1))) |
| 57 | $(eval $(call Optee-os/$(1),$(1))) |
| 58 | |
| 59 | define Package/optee-os-$(1) |
| 60 | SECTION:=boot |
| 61 | CATEGORY:=Boot Loaders |
| 62 | TITLE:=OPTEE-OS for $(NAME) |
| 63 | VARIANT:=$(VARIANT) |
| 64 | DEPENDS:=@!IN_SDK $(DEPENDS) |
| 65 | HIDDEN:=$(HIDDEN) |
| 66 | ifneq ($(BUILD_TARGET),) |
| 67 | DEPENDS += @$(TARGET_DEP) |
| 68 | ifneq ($(BUILD_DEVICES),) |
| 69 | DEFAULT := y if ($(TARGET_DEP)_Default \ |
| 70 | $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \ |
| 71 | $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES))) |
| 72 | endif |
| 73 | endif |
| 74 | $(if $(DEFAULT),DEFAULT:=$(DEFAULT)) |
| 75 | URL:=https://optee.readthedocs.io |
| 76 | endef |
| 77 | |
| 78 | define Package/optee-os-$(1)/install |
| 79 | $$(Package/optee-os/install) |
| 80 | endef |
| 81 | endef |
| 82 | |
| 83 | define Build/Configure/Optee-os |
| 84 | endef |
| 85 | |
| 86 | define Build/Compile/Optee-os |
| 87 | +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ |
| 88 | PATH=$(LINUX_DIR)/scripts/dtc/:$(PATH) \ |
| 89 | CROSS_COMPILE=$(TARGET_CROSS) \ |
| 90 | CROSS_COMPILE_core="$(TARGET_CROSS)" \ |
| 91 | CROSS_COMPILE_ta_arm64="$(TARGET_CROSS)" \ |
| 92 | CROSS_COMPILE_ta_arm32="$(TARGET_CROSS)" \ |
| 93 | $(if $(CONFIG_ARCH_64BIT), CFG_ARM64_core=y CFG_USER_TA_TARGETS=ta_arm64, CFG_ARM32_core=y) \ |
| 94 | PLATFORM="$(PLAT)" \ |
| 95 | PLATFORM_FLAVOR="$(call qstrip,$(PLAT_FLAVOR))" \ |
| 96 | $(OPTEE_MAKE_FLAGS) |
| 97 | endef |
| 98 | |
| 99 | define BuildPackage/Optee-os/Defaults |
| 100 | Build/Configure/Default = $$$$(Build/Configure/Optee-os) |
| 101 | Build/Compile/Default = $$$$(Build/Compile/Optee-os) |
| 102 | endef |
| 103 | |
| 104 | define BuildPackage/Optee-os |
| 105 | $(eval $(call BuildPackage/Optee-os/Defaults)) |
| 106 | $(foreach type,$(if $(DUMP),$(OPTEE_TARGETS),$(BUILD_VARIANT)), \ |
| 107 | $(eval $(call Build/Optee-os/Target,$(type))) |
| 108 | ) |
| 109 | $(eval $(call Build/DefaultTargets)) |
| 110 | $(foreach type,$(if $(DUMP),$(OPTEE_TARGETS),$(BUILD_VARIANT)), \ |
| 111 | $(call BuildPackage,optee-os-$(type)) |
| 112 | ) |
| 113 | endef |