package/{mesa3d, mesa3d-headers}: bump version to 17.0.0
[buildroot-gz.git] / boot / uboot / uboot.mk
blob6b9d5445462219bb99632d7c8dfcf3cfdc7f8e22
1 ################################################################################
3 # uboot
5 ################################################################################
7 UBOOT_VERSION = $(call qstrip,$(BR2_TARGET_UBOOT_VERSION))
8 UBOOT_BOARD_NAME = $(call qstrip,$(BR2_TARGET_UBOOT_BOARDNAME))
10 UBOOT_LICENSE = GPLv2+
11 UBOOT_LICENSE_FILES = Licenses/gpl-2.0.txt
13 UBOOT_INSTALL_IMAGES = YES
15 ifeq ($(UBOOT_VERSION),custom)
16 # Handle custom U-Boot tarballs as specified by the configuration
17 UBOOT_TARBALL = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION))
18 UBOOT_SITE = $(patsubst %/,%,$(dir $(UBOOT_TARBALL)))
19 UBOOT_SOURCE = $(notdir $(UBOOT_TARBALL))
20 BR_NO_CHECK_HASH_FOR += $(UBOOT_SOURCE)
21 else ifeq ($(BR2_TARGET_UBOOT_CUSTOM_GIT),y)
22 UBOOT_SITE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL))
23 UBOOT_SITE_METHOD = git
24 else ifeq ($(BR2_TARGET_UBOOT_CUSTOM_HG),y)
25 UBOOT_SITE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL))
26 UBOOT_SITE_METHOD = hg
27 else ifeq ($(BR2_TARGET_UBOOT_CUSTOM_SVN),y)
28 UBOOT_SITE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL))
29 UBOOT_SITE_METHOD = svn
30 else
31 # Handle stable official U-Boot versions
32 UBOOT_SITE = ftp://ftp.denx.de/pub/u-boot
33 UBOOT_SOURCE = u-boot-$(UBOOT_VERSION).tar.bz2
34 ifeq ($(BR2_TARGET_UBOOT_CUSTOM_VERSION),y)
35 BR_NO_CHECK_HASH_FOR += $(UBOOT_SOURCE)
36 endif
37 endif
39 ifeq ($(BR2_TARGET_UBOOT_FORMAT_BIN),y)
40 UBOOT_BINS += u-boot.bin
41 endif
43 ifeq ($(BR2_TARGET_UBOOT_FORMAT_ELF),y)
44 UBOOT_BINS += u-boot
45 # To make elf usable for debuging on ARC use special target
46 ifeq ($(BR2_arc),y)
47 UBOOT_MAKE_TARGET += mdbtrick
48 endif
49 endif
51 # Call 'make all' unconditionally
52 UBOOT_MAKE_TARGET += all
54 ifeq ($(BR2_TARGET_UBOOT_FORMAT_KWB),y)
55 UBOOT_BINS += u-boot.kwb
56 UBOOT_MAKE_TARGET += u-boot.kwb
57 endif
59 ifeq ($(BR2_TARGET_UBOOT_FORMAT_AIS),y)
60 UBOOT_BINS += u-boot.ais
61 UBOOT_MAKE_TARGET += u-boot.ais
62 endif
64 ifeq ($(BR2_TARGET_UBOOT_FORMAT_LDR),y)
65 UBOOT_BINS += u-boot.ldr
66 endif
68 ifeq ($(BR2_TARGET_UBOOT_FORMAT_NAND_BIN),y)
69 UBOOT_BINS += u-boot-nand.bin
70 endif
72 ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB_IMG),y)
73 UBOOT_BINS += u-boot-dtb.img
74 UBOOT_MAKE_TARGET += u-boot-dtb.img
75 endif
77 ifeq ($(BR2_TARGET_UBOOT_FORMAT_IMG),y)
78 UBOOT_BINS += u-boot.img
79 UBOOT_MAKE_TARGET += u-boot.img
80 endif
82 ifeq ($(BR2_TARGET_UBOOT_FORMAT_IMX),y)
83 UBOOT_BINS += u-boot.imx
84 UBOOT_MAKE_TARGET += u-boot.imx
85 endif
87 ifeq ($(BR2_TARGET_UBOOT_FORMAT_SB),y)
88 UBOOT_BINS += u-boot.sb
89 UBOOT_MAKE_TARGET += u-boot.sb
90 # mxsimage needs OpenSSL
91 UBOOT_DEPENDENCIES += host-elftosb host-openssl
92 endif
94 ifeq ($(BR2_TARGET_UBOOT_FORMAT_SD),y)
95 # BootStream (.sb) is generated by U-Boot, we convert it to SD format
96 UBOOT_BINS += u-boot.sd
97 UBOOT_MAKE_TARGET += u-boot.sb
98 UBOOT_DEPENDENCIES += host-elftosb host-openssl
99 endif
101 ifeq ($(BR2_TARGET_UBOOT_FORMAT_NAND),y)
102 UBOOT_BINS += u-boot.nand
103 UBOOT_MAKE_TARGET += u-boot.sb
104 UBOOT_DEPENDENCIES += host-elftosb host-openssl
105 endif
107 ifeq ($(BR2_TARGET_UBOOT_FORMAT_CUSTOM),y)
108 UBOOT_BINS += $(call qstrip,$(BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME))
109 endif
111 ifeq ($(BR2_TARGET_UBOOT_OMAP_IFT),y)
112 UBOOT_BINS += u-boot.bin
113 UBOOT_BIN_IFT = u-boot.bin.ift
114 endif
116 # The kernel calls AArch64 'arm64', but U-Boot calls it just 'arm', so
117 # we have to special case it. Similar for i386/x86_64 -> x86
118 ifeq ($(KERNEL_ARCH),arm64)
119 UBOOT_ARCH = arm
120 else ifneq ($(filter $(KERNEL_ARCH),i386 x86_64),)
121 UBOOT_ARCH = x86
122 else
123 UBOOT_ARCH = $(KERNEL_ARCH)
124 endif
126 UBOOT_MAKE_OPTS += \
127 CROSS_COMPILE="$(TARGET_CROSS)" \
128 ARCH=$(UBOOT_ARCH) \
129 HOSTCC="$(HOSTCC) $(HOST_CFLAGS)" \
130 HOSTLDFLAGS="$(HOST_LDFLAGS)"
132 ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
133 UBOOT_DEPENDENCIES += host-dtc
134 endif
136 ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSSL),y)
137 UBOOT_DEPENDENCIES += host-openssl
138 endif
140 # prior to u-boot 2013.10 the license info was in COPYING. Copy it so
141 # legal-info finds it
142 define UBOOT_COPY_OLD_LICENSE_FILE
143 if [ -f $(@D)/COPYING ]; then \
144 $(INSTALL) -m 0644 -D $(@D)/COPYING $(@D)/Licenses/gpl-2.0.txt; \
146 endef
148 UBOOT_POST_EXTRACT_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
149 UBOOT_POST_RSYNC_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
151 # Analogous code exists in linux/linux.mk. Basically, the generic
152 # package infrastructure handles downloading and applying remote
153 # patches. Local patches are handled depending on whether they are
154 # directories or files.
155 UBOOT_PATCHES = $(call qstrip,$(BR2_TARGET_UBOOT_PATCH))
156 UBOOT_PATCH = $(filter ftp://% http://% https://%,$(UBOOT_PATCHES))
158 define UBOOT_APPLY_LOCAL_PATCHES
159 for p in $(filter-out ftp://% http://% https://%,$(UBOOT_PATCHES)) ; do \
160 if test -d $$p ; then \
161 $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \
162 else \
163 $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \
164 fi \
165 done
166 endef
167 UBOOT_POST_PATCH_HOOKS += UBOOT_APPLY_LOCAL_PATCHES
169 ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
170 define UBOOT_CONFIGURE_CMDS
171 $(TARGET_CONFIGURE_OPTS) \
172 $(MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
173 $(UBOOT_BOARD_NAME)_config
174 endef
175 else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
176 ifeq ($(BR2_TARGET_UBOOT_USE_DEFCONFIG),y)
177 UBOOT_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_TARGET_UBOOT_BOARD_DEFCONFIG))_defconfig
178 else ifeq ($(BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG),y)
179 UBOOT_KCONFIG_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE))
180 endif # BR2_TARGET_UBOOT_USE_DEFCONFIG
182 UBOOT_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
183 UBOOT_KCONFIG_OPTS = $(UBOOT_MAKE_OPTS)
184 define UBOOT_HELP_CMDS
185 @echo ' uboot-menuconfig - Run U-Boot menuconfig'
186 @echo ' uboot-savedefconfig - Run U-Boot savedefconfig'
187 @echo ' uboot-update-defconfig - Save the U-Boot configuration to the path specified'
188 @echo ' by BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE'
189 endef
190 endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
192 define UBOOT_BUILD_CMDS
193 $(TARGET_CONFIGURE_OPTS) \
194 $(MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
195 $(UBOOT_MAKE_TARGET)
196 $(if $(BR2_TARGET_UBOOT_FORMAT_SD),
197 $(@D)/tools/mxsboot sd $(@D)/u-boot.sb $(@D)/u-boot.sd)
198 $(if $(BR2_TARGET_UBOOT_FORMAT_NAND),
199 $(@D)/tools/mxsboot \
200 -w $(BR2_TARGET_UBOOT_FORMAT_NAND_PAGE_SIZE) \
201 -o $(BR2_TARGET_UBOOT_FORMAT_NAND_OOB_SIZE) \
202 -e $(BR2_TARGET_UBOOT_FORMAT_NAND_ERASE_SIZE) \
203 nand $(@D)/u-boot.sb $(@D)/u-boot.nand)
204 endef
206 define UBOOT_BUILD_OMAP_IFT
207 $(HOST_DIR)/usr/bin/gpsign -f $(@D)/u-boot.bin \
208 -c $(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG))
209 endef
211 define UBOOT_INSTALL_IMAGES_CMDS
212 $(foreach f,$(UBOOT_BINS), \
213 cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
215 $(if $(BR2_TARGET_UBOOT_FORMAT_NAND),
216 cp -dpf $(@D)/u-boot.sb $(BINARIES_DIR))
217 $(if $(BR2_TARGET_UBOOT_SPL),
218 $(foreach f,$(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME)), \
219 cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
222 $(if $(BR2_TARGET_UBOOT_ENVIMAGE),
223 cat $(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)) | \
224 $(HOST_DIR)/usr/bin/mkenvimage -s $(BR2_TARGET_UBOOT_ENVIMAGE_SIZE) \
225 $(if $(BR2_TARGET_UBOOT_ENVIMAGE_REDUNDANT),-r) \
226 $(if $(filter BIG,$(BR2_ENDIAN)),-b) \
227 -o $(BINARIES_DIR)/uboot-env.bin -)
228 endef
230 define UBOOT_INSTALL_OMAP_IFT_IMAGE
231 cp -dpf $(@D)/$(UBOOT_BIN_IFT) $(BINARIES_DIR)/
232 endef
234 ifeq ($(BR2_TARGET_UBOOT_OMAP_IFT),y)
235 ifeq ($(BR_BUILDING),y)
236 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG)),)
237 $(error No gpsign config file. Check your BR2_TARGET_UBOOT_OMAP_IFT_CONFIG setting)
238 endif
239 ifeq ($(wildcard $(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG))),)
240 $(error gpsign config file $(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG) not found. Check your BR2_TARGET_UBOOT_OMAP_IFT_CONFIG setting)
241 endif
242 endif
243 UBOOT_DEPENDENCIES += host-omap-u-boot-utils
244 UBOOT_POST_BUILD_HOOKS += UBOOT_BUILD_OMAP_IFT
245 UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_INSTALL_OMAP_IFT_IMAGE
246 endif
248 ifeq ($(BR2_TARGET_UBOOT_ZYNQ_IMAGE),y)
249 define UBOOT_GENERATE_ZYNQ_IMAGE
250 $(HOST_DIR)/usr/bin/python2 \
251 $(HOST_DIR)/usr/bin/zynq-boot-bin.py \
252 -u $(@D)/$(firstword $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))) \
253 -o $(BINARIES_DIR)/BOOT.BIN
254 endef
255 UBOOT_DEPENDENCIES += host-zynq-boot-bin
256 UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_GENERATE_ZYNQ_IMAGE
257 endif
259 ifeq ($(BR2_TARGET_UBOOT_ALTERA_SOCFPGA_IMAGE_CRC),y)
260 define UBOOT_CRC_ALTERA_SOCFPGA_IMAGE
261 $(foreach f,$(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME)), \
262 $(HOST_DIR)/usr/bin/mkpimage \
263 -o $(BINARIES_DIR)/$(notdir $(call qstrip,$(f))).crc \
264 $(@D)/$(call qstrip,$(f))
266 endef
267 UBOOT_DEPENDENCIES += host-mkpimage
268 UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_CRC_ALTERA_SOCFPGA_IMAGE
269 endif
271 ifeq ($(BR2_TARGET_UBOOT_ENVIMAGE),y)
272 ifeq ($(BR_BUILDING),y)
273 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SOURCE)),)
274 $(error Please define a source file for Uboot environment (BR2_TARGET_UBOOT_ENVIMAGE_SOURCE setting))
275 endif
276 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_ENVIMAGE_SIZE)),)
277 $(error Please provide Uboot environment size (BR2_TARGET_UBOOT_ENVIMAGE_SIZE setting))
278 endif
279 endif
280 UBOOT_DEPENDENCIES += host-uboot-tools
281 endif
283 ifeq ($(BR2_TARGET_UBOOT)$(BR_BUILDING),yy)
286 # Check U-Boot board name (for legacy) or the defconfig/custom config
287 # file options (for kconfig)
289 ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
290 ifeq ($(UBOOT_BOARD_NAME),)
291 $(error No U-Boot board name set. Check your BR2_TARGET_UBOOT_BOARDNAME setting)
292 endif # UBOOT_BOARD_NAME
293 else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
294 ifeq ($(BR2_TARGET_UBOOT_USE_DEFCONFIG),y)
295 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_BOARD_DEFCONFIG)),)
296 $(error No board defconfig name specified, check your BR2_TARGET_UBOOT_DEFCONFIG setting)
297 endif # qstrip BR2_TARGET_UBOOT_BOARD_DEFCONFIG
298 endif # BR2_TARGET_UBOOT_USE_DEFCONFIG
299 ifeq ($(BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG),y)
300 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE)),)
301 $(error No board configuration file specified, check your BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE setting)
302 endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE
303 endif # BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG
304 endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
307 # Check custom version option
309 ifeq ($(BR2_TARGET_UBOOT_CUSTOM_VERSION),y)
310 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE)),)
311 $(error No custom U-Boot version specified. Check your BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE setting)
312 endif # qstrip BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE
313 endif # BR2_TARGET_UBOOT_CUSTOM_VERSION
316 # Check custom tarball option
318 ifeq ($(BR2_TARGET_UBOOT_CUSTOM_TARBALL),y)
319 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION)),)
320 $(error No custom U-Boot tarball specified. Check your BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION setting)
321 endif # qstrip BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION
322 endif # BR2_TARGET_UBOOT_CUSTOM_TARBALL
325 # Check Git/Mercurial repo options
327 ifeq ($(BR2_TARGET_UBOOT_CUSTOM_GIT)$(BR2_TARGET_UBOOT_CUSTOM_HG),y)
328 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL)),)
329 $(error No custom U-Boot repository URL specified. Check your BR2_TARGET_UBOOT_CUSTOM_REPO_URL setting)
330 endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CUSTOM_REPO_URL
331 ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION)),)
332 $(error No custom U-Boot repository URL specified. Check your BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION setting)
333 endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CUSTOM_REPO_VERSION
334 endif # BR2_TARGET_UBOOT_CUSTOM_GIT || BR2_TARGET_UBOOT_CUSTOM_HG
336 endif # BR2_TARGET_UBOOT && BR_BUILDING
338 ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
339 $(eval $(generic-package))
340 else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
341 $(eval $(kconfig-package))
342 endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY