kernel: bump 5.15 to 5.15.148
[openwrt/staging/stintel.git] / include / u-boot.mk
1 include $(INCLUDE_DIR)/prereq.mk
2
3 PKG_NAME ?= u-boot
4
5 ifndef PKG_SOURCE_PROTO
6 PKG_SOURCE = $(PKG_NAME)-$(PKG_VERSION).tar.bz2
7 PKG_SOURCE_URL = \
8 https://mirror.cyberbits.eu/u-boot \
9 https://ftp.denx.de/pub/u-boot \
10 ftp://ftp.denx.de/pub/u-boot
11 endif
12
13 PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
14
15 PKG_TARGETS := bin
16 PKG_FLAGS:=nonshared
17
18 PKG_LICENSE:=GPL-2.0 GPL-2.0+
19 PKG_LICENSE_FILES:=Licenses/README
20
21 PKG_BUILD_PARALLEL ?= 1
22
23 ifdef UBOOT_USE_BINMAN
24 $(eval $(call TestHostCommand,python3-pyelftools, \
25 Please install the Python3 elftools module, \
26 $(STAGING_DIR_HOST)/bin/python3 -c 'import elftools'))
27 endif
28
29 ifdef UBOOT_USE_INTREE_DTC
30 $(eval $(call TestHostCommand,python3-dev, \
31 Please install the python3-dev package, \
32 python3.11-config --includes 2>&1 | grep 'python3', \
33 python3.10-config --includes 2>&1 | grep 'python3', \
34 python3.9-config --includes 2>&1 | grep 'python3', \
35 python3.8-config --includes 2>&1 | grep 'python3', \
36 python3.7-config --includes 2>&1 | grep 'python3', \
37 python3-config --includes 2>&1 | grep -E 'python3\.([7-9]|[0-9][0-9])\.?'))
38
39 $(eval $(call TestHostCommand,python3-setuptools, \
40 Please install the Python3 setuptools module, \
41 $(STAGING_DIR_HOST)/bin/python3 -c 'import setuptools'))
42
43 $(eval $(call TestHostCommand,swig, \
44 Please install the swig package, \
45 swig -version))
46 endif
47
48 export GCC_HONOUR_COPTS=s
49
50 define Package/u-boot/install/default
51 $(CP) $(patsubst %,$(PKG_BUILD_DIR)/%,$(UBOOT_IMAGE)) $(1)/
52 endef
53
54 Package/u-boot/install = $(Package/u-boot/install/default)
55
56 define U-Boot/Init
57 BUILD_TARGET:=
58 BUILD_SUBTARGET:=
59 BUILD_DEVICES:=
60 NAME:=
61 DEPENDS:=
62 HIDDEN:=
63 DEFAULT:=
64 VARIANT:=$(1)
65 UBOOT_CONFIG:=$(1)
66 UBOOT_IMAGE:=u-boot.bin
67 endef
68
69 TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET))
70
71 UBOOT_MAKE_FLAGS = \
72 HOSTCC="$(HOSTCC)" \
73 HOSTCFLAGS="$(HOST_CFLAGS) $(HOST_CPPFLAGS) -std=gnu11" \
74 HOSTLDFLAGS="$(HOST_LDFLAGS)" \
75 LOCALVERSION="-OpenWrt-$(REVISION)" \
76 STAGING_PREFIX="$(STAGING_DIR_HOST)" \
77 PKG_CONFIG_PATH="$(STAGING_DIR_HOST)/lib/pkgconfig" \
78 PKG_CONFIG_LIBDIR="$(STAGING_DIR_HOST)/lib/pkgconfig" \
79 PKG_CONFIG_EXTRAARGS="--static" \
80 $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
81
82 define Build/U-Boot/Target
83 $(eval $(call U-Boot/Init,$(1)))
84 $(eval $(call U-Boot/Default,$(1)))
85 $(eval $(call U-Boot/$(1),$(1)))
86
87 define Package/u-boot-$(1)
88 SECTION:=boot
89 CATEGORY:=Boot Loaders
90 TITLE:=U-Boot for $(NAME)
91 VARIANT:=$(VARIANT)
92 DEPENDS:=@!IN_SDK $(DEPENDS)
93 HIDDEN:=$(HIDDEN)
94 ifneq ($(BUILD_TARGET),)
95 DEPENDS += @$(TARGET_DEP)
96 ifneq ($(BUILD_DEVICES),)
97 DEFAULT := y if ($(TARGET_DEP)_Default \
98 $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \
99 $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES)))
100 endif
101 endif
102 $(if $(DEFAULT),DEFAULT:=$(DEFAULT))
103 URL:=http://www.denx.de/wiki/U-Boot
104 endef
105
106 define Package/u-boot-$(1)/install
107 $$(Package/u-boot/install)
108 endef
109 endef
110
111 define Build/Configure/U-Boot
112 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) $(UBOOT_CONFIG)_config
113 $(if $(strip $(UBOOT_CUSTOMIZE_CONFIG)),
114 $(PKG_BUILD_DIR)/scripts/config --file $(PKG_BUILD_DIR)/.config $(UBOOT_CUSTOMIZE_CONFIG)
115 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(UBOOT_CONFIGURE_VARS) oldconfig)
116 endef
117
118 ifndef UBOOT_USE_INTREE_DTC
119 DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc)
120 endif
121
122 define Build/Compile/U-Boot
123 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
124 CROSS_COMPILE=$(TARGET_CROSS) \
125 $(if $(DTC),DTC="$(DTC)") \
126 $(UBOOT_MAKE_FLAGS)
127 endef
128
129 define BuildPackage/U-Boot/Defaults
130 Build/Configure/Default = $$$$(Build/Configure/U-Boot)
131 Build/Compile/Default = $$$$(Build/Compile/U-Boot)
132 endef
133
134 define BuildPackage/U-Boot
135 $(eval $(call BuildPackage/U-Boot/Defaults))
136 $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
137 $(eval $(call Build/U-Boot/Target,$(type)))
138 )
139 $(eval $(call Build/DefaultTargets))
140 $(foreach type,$(if $(DUMP),$(UBOOT_TARGETS),$(BUILD_VARIANT)), \
141 $(call BuildPackage,u-boot-$(type))
142 )
143 endef