blob: 396d2406bfac925c8d35858e10bf7b60b00d1dfb [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001include $(INCLUDE_DIR)/prereq.mk
2
3PKG_NAME ?= optee-os
4
5ifndef PKG_SOURCE_PROTO
6PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
7PKG_SOURCE_URL_FILE:=$(PKG_VERSION).tar.gz
8PKG_SOURCE_URL = https://github.com/OP-TEE/optee_os/archive/refs/tags/
9TAR_OPTIONS+= --transform 's/optee_os/$(PKG_NAME)/'
10endif
11
12PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
13
14PKG_TARGETS := bin
15PKG_FLAGS:=nonshared
16
17PKG_LICENSE:=BSD 2-Clause
18PKG_LICENSE_FILES:=LICENSE
19
20PKG_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
30export GCC_HONOUR_COPTS=s
31
32define Package/optee-os/install/default
33 $(CP) $(patsubst %,$(PKG_BUILD_DIR)/out/arm-plat-$(PLAT)/core/%,$(OPTEE_IMAGE)) $(1)/
34endef
35
36Package/optee-os/install = $(Package/optee-os/install/default)
37
38define 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
50endef
51
52TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET))
53
54define 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
81endef
82
83define Build/Configure/Optee-os
84endef
85
86define 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)
97endef
98
99define BuildPackage/Optee-os/Defaults
100 Build/Configure/Default = $$$$(Build/Configure/Optee-os)
101 Build/Compile/Default = $$$$(Build/Compile/Optee-os)
102endef
103
104define 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 )
113endef