Commit f2d16ae0 authored by Thomas Petazzoni's avatar Thomas Petazzoni
Browse files

u-boot: support building for mkimage



To build mkimage for the host (which is needed to build an uImage of
the kernel), it is not necessary to configure U-Boot, and therefore to
have a particular board selected.

Therefore, this commit:

 * Adds a verification at U-Boot configure step that a U-Boot board
   name has been defined

 * Sets a default U-Boot version if none has been specified, so that
   even when U-Boot isn't selected but we want to build mkimage for
   the host, a particular U-Boot version is picked.

 * Make the host mkimage target depend only on U-Boot being
   downloaded/extracted/patched, and the target mkimage/fw_printenv
   targets depend on U-Boot being fully configured.

Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
parent dc63ef95
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -4,6 +4,15 @@
#
#############################################################
U_BOOT_VERSION:=$(call qstrip,$(BR2_UBOOT_VERSION))
U_BOOT_BOARD_NAME:=$(call qstrip,$(BR2_TARGET_UBOOT_BOARDNAME))

# U-Boot may not be selected in the configuration, but mkimage might
# be needed to build/prepare a kernel image. In this case, we just
# pick some random stable U-Boot version that will be used just to
# build mkimage.
ifeq ($(U_BOOT_VERSION),)
U_BOOT_VERSION=2010.03
endif

U_BOOT_SOURCE:=u-boot-$(U_BOOT_VERSION).tar.bz2

@@ -30,9 +39,6 @@ TARGET_UBOOT_ETHADDR:=$(call qstrip,$(BR2_TARGET_UBOOT_ETHADDR))

# u-boot still uses arch=ppc for powerpc
U_BOOT_ARCH=$(KERNEL_ARCH:powerpc=ppc)
ifeq ($(UBOOT_BOARD_NAME),)
UBOOT_BOARD_NAME:=$(call qstrip,$(BR2_TARGET_UBOOT_BOARDNAME))
endif

U_BOOT_INC_CONF_FILE:=$(U_BOOT_DIR)/include/config.h

@@ -73,6 +79,9 @@ endif
	touch $@

$(U_BOOT_DIR)/.configured: $(U_BOOT_DIR)/.patched
ifeq ($(U_BOOT_BOARD_NAME),)
	$(error NO U-Boot board name set. Check your BR2_TARGET_UBOOT_BOARDNAME setting)
endif
	$(TARGET_CONFIGURE_OPTS)		\
		CFLAGS="$(TARGET_CFLAGS)"	\
		LDFLAGS="$(TARGET_LDFLAGS)"	\
@@ -154,11 +163,16 @@ $(BINARIES_DIR)/$(U_BOOT_BIN): $(U_BOOT_DIR)/$(U_BOOT_BIN)
	rm -f $(BINARIES_DIR)/$(U_BOOT_BIN)
	cp -dpf $(U_BOOT_DIR)/$(U_BOOT_BIN) $(BINARIES_DIR)/

$(U_BOOT_TOOLS): $(U_BOOT_DIR)/$(U_BOOT_BIN)
# Build just mkimage for the host. It might have already been built by
# the U-Boot build procedure, but mkimage may also be needed even if
# U-Boot isn't selected in the configuration, to generate a kernel
# uImage.
$(MKIMAGE): $(U_BOOT_DIR)/.patched
	mkdir -p $(@D)
	cp -dpf $(U_BOOT_DIR)/tools/mkimage $@
	$(MAKE) -C $(U_BOOT_DIR) tools
	cp -dpf $(U_BOOT_DIR)/tools/mkimage $(@D)

$(TARGET_DIR)/usr/bin/mkimage: $(U_BOOT_DIR)/$(U_BOOT_BIN)
$(TARGET_DIR)/usr/bin/mkimage: $(U_BOOT_DIR)/.configured
	mkdir -p $(@D)
	$(TARGET_CC) -I$(U_BOOT_DIR)/include -I$(U_BOOT_DIR)/tools \
		-DUSE_HOSTCC -o $@ \
@@ -171,7 +185,7 @@ $(TARGET_DIR)/usr/bin/mkimage: $(U_BOOT_DIR)/$(U_BOOT_BIN)

	$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $@

$(TARGET_DIR)/usr/sbin/fw_printenv: $(U_BOOT_DIR)/$(U_BOOT_BIN)
$(TARGET_DIR)/usr/sbin/fw_printenv: $(U_BOOT_DIR)/.configured
	mkdir -p $(@D)
	$(TARGET_CC) -I$(U_BOOT_DIR)/include -I$(LINUX_HEADERS_DIR)/include \
		-DUSE_HOSTCC -o $@ \