kumquat-buildroot/target/device/Atmel/u-boot/u-boot.mk

283 lines
9.4 KiB
Makefile
Raw Normal View History

2007-07-20 16:39:01 +02:00
#############################################################
#
# u-boot mkimage to build to target u-boot filesystems and
2007-08-22 14:35:41 +02:00
#
# u-boot.bin - the boot loader for the target - which needs soft float, so
# we won't make it.
2007-07-20 16:39:01 +02:00
#
#
#############################################################
UBOOT_VERSION:=1.2.0-atmel
2007-08-22 14:35:41 +02:00
ATMEL_MIRROR:=$(strip $(subst ",, $(BR2_ATMEL_MIRROR)))
2007-07-29 09:05:13 +02:00
#"))
2007-07-17 14:19:56 +02:00
UBOOT_DIR:=$(BUILD_DIR)/u-boot-$(UBOOT_VERSION)
2007-07-20 16:39:01 +02:00
UBOOT_BUILD_DIR:=$(PROJECT_BUILD_DIR)/u-boot-$(UBOOT_VERSION)
UBOOT_SOURCE:=u-boot-$(UBOOT_VERSION).tar.bz2
2007-07-17 14:19:56 +02:00
#UBOOT_SOURCE:=u-boot-1.1.5-atmel.tar.bz2
#UBOOT_SITE:=http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/u-boot
UBOOT_SITE:=$(ATMEL_MIRROR)/Source
2007-07-20 16:39:01 +02:00
UBOOT_PATCH_SITE:=$(ATMEL_MIRROR)/Source
UBOOT_CAT:=$(BZCAT)
2007-07-17 14:19:56 +02:00
UBOOT_PATCH_SOURCE:=u-boot-1.2.0-atmel-patch.tar.bz2
MKIMAGE_BINLOC:=$(UBOOT_BUILD_DIR)/tools/mkimage
MKIMAGE:=$(KERNEL_CROSS)mkimage
UBOOT_BIN:=$(BOARD_NAME)-u-boot-$(UBOOT_VERSION)-$(DATE).bin
UBOOT_PATCHES:=$(PROJECT_BUILD_DIR)/u-boot-patches
2007-07-20 16:39:01 +02:00
UBOOT_ATMEL_BMP:=$(UBOOT_PATCHES)/atmel.bmp
2007-07-17 14:19:56 +02:00
UBOOT_SCR=$(BINARIES_DIR)/autoscript
2007-08-22 14:35:41 +02:00
TARGET_UBOOT_IPADDR:=$(strip $(subst ",, $(BR2_TARGET_UBOOT_IPADDR)))
#"))
2007-08-22 14:35:41 +02:00
TARGET_UBOOT_SERVERIP:=$(strip $(subst ",, $(BR2_TARGET_UBOOT_SERVERIP)))
#"))
2007-08-22 14:35:41 +02:00
TARGET_UBOOT_GATEWAY:=$(strip $(subst ",, $(BR2_TARGET_UBOOT_GATEWAY)))
#"))
2007-08-22 14:35:41 +02:00
TARGET_UBOOT_NETMASK:=$(strip $(subst ",, $(BR2_TARGET_UBOOT_NETMASK)))
#"))
2007-08-22 14:35:41 +02:00
TARGET_UBOOT_ETHADDR:=$(strip $(subst ",, $(BR2_TARGET_UBOOT_ETHADDR)))
#"))
2007-07-17 14:19:56 +02:00
UBOOT_CUSTOM:=$(UBOOT_DIR)/include/custom.h
2007-07-20 16:39:01 +02:00
$(DL_DIR)/$(UBOOT_SOURCE):
2007-07-29 09:05:13 +02:00
$(WGET) -P $(DL_DIR) $(UBOOT_SITE)/$(UBOOT_SOURCE)
2007-07-17 14:19:56 +02:00
2007-07-20 16:39:01 +02:00
$(DL_DIR)/$(UBOOT_PATCH_SOURCE):
2007-07-29 09:05:13 +02:00
$(WGET) -P $(DL_DIR) $(UBOOT_PATCH_SITE)/$(UBOOT_PATCH_SOURCE)
2007-07-20 16:39:01 +02:00
2007-07-17 14:19:56 +02:00
$(UBOOT_DIR)/.unpacked: $(DL_DIR)/$(UBOOT_SOURCE)
2007-08-22 13:47:22 +02:00
mkdir -p $(BUILD_DIR)
2007-07-20 16:39:01 +02:00
$(UBOOT_CAT) $(DL_DIR)/$(UBOOT_SOURCE) | tar -C $(BUILD_DIR) -xvf -
2007-08-22 13:47:22 +02:00
touch $@
2007-07-17 14:19:56 +02:00
$(UBOOT_PATCHES)/.unpacked: $(DL_DIR)/$(UBOOT_PATCH_SOURCE)
mkdir -p $(UBOOT_PATCHES)
2007-08-22 13:47:22 +02:00
bzcat $(DL_DIR)/$(UBOOT_PATCH_SOURCE) | tar -C $(UBOOT_PATCHES) -xvf -
touch $@
2007-07-20 16:39:01 +02:00
$(UBOOT_DIR)/.patched.$(UBOOT_PATCH_SOURCE): $(UBOOT_DIR)/.unpacked $(UBOOT_PATCHES)/.unpacked
2007-07-17 14:19:56 +02:00
toolchain/patch-kernel.sh $(UBOOT_DIR) $(UBOOT_PATCHES) *.patch
2007-07-20 16:39:01 +02:00
touch $(UBOOT_DIR)/.patched.$(UBOOT_PATCH_SOURCE)
2007-08-22 14:35:41 +02:00
# cp $(UBOOT_CONFIG_FILE) $(UBOOT_DIR)/include/configs/.
# cp $(UBOOT_PATCHES)/cmd_defenv.c $(UBOOT_DIR)/common/.
# cp $(UBOOT_ATMEL_BMP) $(UBOOT_DIR)/tools/logos/.
2007-07-20 16:39:01 +02:00
$(UBOOT_BUILD_DIR)/.configured: $(UBOOT_DIR)/.patched.$(UBOOT_PATCH_SOURCE)
2007-08-22 13:47:22 +02:00
ifneq ($(strip $(UBOOT_CONFIG_FILE)),)
2007-07-17 14:19:56 +02:00
cp $(UBOOT_CONFIG_FILE) $(UBOOT_DIR)/include/configs/.
endif
2007-08-22 13:47:22 +02:00
$(MAKE) \
O=$(UBOOT_BUILD_DIR) \
CONFIG_NOSOFTFLOAT=1 \
-C $(UBOOT_DIR) \
2007-07-20 16:39:01 +02:00
$(UBOOT_CONFIG)
$(SED) 's/ $$(SREC) $$(BIN)//' $(UBOOT_DIR)/examples/Makefile
touch $(UBOOT_BUILD_DIR)/.configured
2007-08-22 14:35:41 +02:00
# $(MAKE) O=$(UBOOT_BUILD_DIR) -C $(UBOOT_DIR)
2007-07-20 16:39:01 +02:00
2007-07-17 14:19:56 +02:00
$(MKIMAGE_BINLOC): $(UBOOT_BUILD_DIR)/.configured
$(MAKE) \
2007-08-22 13:47:22 +02:00
O=$(UBOOT_BUILD_DIR) \
CROSS_COMPILE= \
CONFIG_NOSOFTFLOAT=1 \
TOPDIR=$(UBOOT_DIR) \
SRCTREE=$(UBOOT_DIR) \
-C $(UBOOT_DIR) tools
2007-07-17 14:19:56 +02:00
touch $(MKIMAGE_BINLOC)
2007-07-20 16:39:01 +02:00
2007-08-22 13:47:22 +02:00
$(UBOOT_BUILD_DIR)/u-boot.bin: $(UBOOT_BUILD_DIR)/.configured $(UBOOT_CUSTOM)
2007-07-20 16:39:01 +02:00
echo TARGET_CROSS=$(TARGET_CROSS)
2007-08-22 13:47:22 +02:00
$(MAKE) O=$(UBOOT_BUILD_DIR) \
CROSS_COMPILE=$(TARGET_CROSS) \
CONFIG_NOSOFTFLOAT=1 \
TOPDIR=$(UBOOT_DIR) \
SRCTREE=$(UBOOT_DIR) \
TFTPBOOT=/tftpboot \
2007-07-17 14:19:56 +02:00
-C $(UBOOT_DIR)
2007-08-22 13:47:22 +02:00
$(BINARIES_DIR)/$(UBOOT_BIN): $(UBOOT_BUILD_DIR)/u-boot.bin
2007-07-20 16:39:01 +02:00
mkdir -p $(BINARIES_DIR)
2007-07-17 14:19:56 +02:00
cp $(UBOOT_BUILD_DIR)/u-boot.bin $(BINARIES_DIR)/$(UBOOT_BIN)
2007-08-22 13:47:22 +02:00
/tftpboot/$(UBOOT_BIN): $(UBOOT_BUILD_DIR)/u-boot.bin
2007-07-20 16:39:01 +02:00
mkdir -p /tftpboot
2007-07-17 14:19:56 +02:00
cp $(UBOOT_BUILD_DIR)/u-boot.bin /tftpboot/$(UBOOT_BIN)
2007-08-22 13:47:22 +02:00
uboot-bin: $(BINARIES_DIR)/$(UBOOT_BIN) /tftpboot/$(UBOOT_BIN)
2007-07-17 14:19:56 +02:00
2007-08-22 13:47:22 +02:00
$(UBOOT_CUSTOM).test: .config $(UBOOT_BUILD_DIR)/.configured
echo "/* Automatically generated file, do not edit */" \
> $(UBOOT_CUSTOM).test
ifneq ($(TARGET_HOSTNAME),)
echo "#if defined(CONFIG_HOSTNAME)">> $(UBOOT_CUSTOM).test
echo "#undef CONFIG_HOSTNAME">> $(UBOOT_CUSTOM).test
echo "#define CONFIG_HOSTNAME $(TARGET_HOSTNAME)">> $(UBOOT_CUSTOM).test
echo "#endif">> $(UBOOT_CUSTOM).test
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_IPADDR),)
echo "#define CONFIG_IPADDR $(TARGET_UBOOT_IPADDR)">> $(UBOOT_CUSTOM).test
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_SERVERIP),)
echo "#define CONFIG_SERVERIP $(TARGET_UBOOT_SERVERIP)">> $(UBOOT_CUSTOM).test
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_GATEWAY),)
echo "#define CONFIG_GATEWAYIP $(TARGET_UBOOT_GATEWAY)">> $(UBOOT_CUSTOM).test
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_NETMASK),)
echo "#define CONFIG_NETMASK $(TARGET_UBOOT_NETMASK)">> $(UBOOT_CUSTOM).test
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_ETHADDR),)
echo "#define CONFIG_ETHADDR $(TARGET_UBOOT_ETHADDR)">> $(UBOOT_CUSTOM).test
2007-07-17 14:19:56 +02:00
endif
2007-07-20 13:13:22 +02:00
diff -q $(UBOOT_CUSTOM).test $(UBOOT_CUSTOM) || cp -af $(UBOOT_CUSTOM).test $(UBOOT_CUSTOM)
2007-07-17 14:19:56 +02:00
2007-08-22 13:47:22 +02:00
$(UBOOT_SCR): .config
ifneq ($(TARGET_UBOOT_IPADDR),)
echo setenv ipaddr $(TARGET_UBOOT_IPADDR)> $(UBOOT_SCR)
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_SERVERIP),)
echo setenv serverip $(TARGET_UBOOT_SERVERIP)>> $(UBOOT_SCR)
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_GATEWAY),)
echo setenv gatewayip $(TARGET_UBOOT_GATEWAY)>> $(UBOOT_SCR)
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
ifneq ($(TARGET_UBOOT_NETMASK),)
echo setenv netmask $(TARGET_UBOOT_NETMASK)>> $(UBOOT_SCR)
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
echo setenv linux $(LINUX26_KERNEL)>> $(UBOOT_SCR)
echo setenv kernel-version $(LINUX26_VERSION)>> $(UBOOT_SCR)
echo setenv kernel-date $(DATE)>> $(UBOOT_SCR)
echo setenv hostname $(TARGET_HOSTNAME) >> $(UBOOT_SCR)
echo setenv fs-date $(DATE)>> $(UBOOT_SCR)
echo setenv rd-1 rootfs.$(BR2_ARCH)-$(DATE).ext2>> $(UBOOT_SCR)
echo setenv rd-2 rootfs.$(BR2_ARCH)-$(DATE).jffs2>> $(UBOOT_SCR)
echo setenv rd rootfs.$(BR2_ARCH)-$(DATE).ext2>> $(UBOOT_SCR)
echo setenv ver 1>> $(UBOOT_SCR)
ifneq ($(TARGET_UBOOT_ETHADDR),)
echo setenv ethaddr $(TARGET_UBOOT_ETHADDR)>> $(UBOOT_SCR)
2007-07-17 14:19:56 +02:00
endif
2007-08-22 13:47:22 +02:00
echo setenv fstype ram>> $(UBOOT_SCR)
echo fs >> $(UBOOT_SCR)
echo os >> $(UBOOT_SCR)
echo setargs>> $(UBOOT_SCR)
echo saveenv>> $(UBOOT_SCR)
$(UBOOT_SCR).$(PROJECT): $(UBOOT_SCR) $(MKIMAGE)
$(MKIMAGE) -A arm \
2007-08-22 14:35:41 +02:00
-O linux \
-T script \
-C none \
-a 0 \
-e 0 \
2007-07-17 14:19:56 +02:00
-n "autoscr config" \
2007-08-22 14:35:41 +02:00
-d $(UBOOT_SCR) \
2007-07-20 09:54:21 +02:00
$(UBOOT_SCR).$(PROJECT)
2007-08-22 13:47:22 +02:00
cp $(UBOOT_SCR).$(PROJECT) /tftpboot
2007-07-17 14:19:56 +02:00
2007-08-22 14:35:41 +02:00
$(MKIMAGE): $(MKIMAGE_BINLOC)
2007-08-22 13:47:22 +02:00
cp -f $(MKIMAGE_BINLOC) $(MKIMAGE)
2007-07-20 16:39:01 +02:00
2007-08-22 13:47:22 +02:00
uboot: $(MKIMAGE) uboot-bin $(UBOOT_SCR).$(PROJECT)
2007-07-20 16:39:01 +02:00
uboot-source: $(DL_DIR)/$(UBOOT_SOURCE)
2007-07-17 14:19:56 +02:00
2007-07-20 16:39:01 +02:00
uboot-clean:
2007-08-22 13:47:22 +02:00
rm -fr $(UBOOT_BUILD_DIR)
rm -fr $(UBOOT_PATCHES)
rm -f $(BINARIES_DIR)/$(UBOOT_BIN)
rm -fr $(UBOOT_DIR)
rm -f $(UBOOT_SCR)
rm -f $(UBOOT_SCR).$(PROJECT)
2007-08-22 14:35:41 +02:00
# -$(MAKE) -C $(UBOOT_DIR)/uboot-tools clean
2007-07-20 16:39:01 +02:00
2007-08-22 13:47:22 +02:00
uboot-dirclean: uboot-clean
2007-07-20 16:39:01 +02:00
rm -rf $(UBOOT_DIR)
2007-07-17 14:19:56 +02:00
uboot-new:
2007-08-22 13:47:22 +02:00
rm -fr $(UBOOT_BUILD_DIR)/u-boot
rm -fr $(UBOOT_BUILD_DIR)/u-boot.gz
rm -fr $(UBOOT_BUILD_DIR)/u-boot.bin
rm -fr /tftpboot/$(UBOOT_BIN)
rm -fr $(BINARIES_DIR)/$(UBOOT_BIN)
2007-07-17 14:19:56 +02:00
2007-08-22 13:47:22 +02:00
.PHONY: uboot-bin
2007-07-20 16:39:01 +02:00
#############################################################
#
# Build the uboot root filesystem image
#
#############################################################
UBOOT_TARGET:=$(IMAGE).uboot
ubootroot: host-fakeroot makedevs uboot
2007-08-22 11:56:41 +02:00
-@find $(TARGET_DIR) -type f -perm +111 | xargs $(STRIP) 2>/dev/null || true
2007-07-20 16:39:01 +02:00
@rm -rf $(TARGET_DIR)/usr/man
@rm -rf $(TARGET_DIR)/usr/info
-/sbin/ldconfig -r $(TARGET_DIR) 2>/dev/null
# Use fakeroot to pretend all target binaries are owned by root
rm -f $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
touch $(STAGING_DIR)/.fakeroot.00000
cat $(STAGING_DIR)/.fakeroot* > $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
echo "chown -R root:root $(TARGET_DIR)" >> $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
# Use fakeroot to pretend to create all needed device nodes
echo "$(STAGING_DIR)/bin/makedevs -d $(TARGET_DEVICE_TABLE) $(TARGET_DIR)" \
>> $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
# Use fakeroot so mkuboot believes the previous fakery
echo "$(UBOOT_DIR)/uboot-tools/mkuboot " \
"$(TARGET_DIR) $(UBOOT_TARGET) " \
"-noappend $(UBOOT_ENDIANNESS)" \
>> $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
chmod a+x $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
$(STAGING_DIR)/usr/bin/fakeroot -- $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
-@rm -f $(STAGING_DIR)/_fakeroot.$(notdir $(UBOOT_TARGET))
ubootroot-source: uboot-source
ubootroot-clean:
-$(MAKE) -C $(UBOOT_DIR) clean
ubootroot-dirclean:
rm -rf $(UBOOT_DIR)
#############################################################
#
# Toplevel Makefile options
#
#############################################################
ifeq ($(strip $(BR2_TARGET_UBOOT)),y)
TARGETS+=uboot
2007-07-17 14:19:56 +02:00
endif
uboot-test:
2007-08-22 13:47:22 +02:00
-@echo source=$(DL_DIR)/$(UBOOT_SOURCE)
-@ls $(DL_DIR)/$(UBOOT_SOURCE)
-@echo patch=$(DL_DIR)/$(UBOOT_PATCH_SOURCE)
-@ls $(DL_DIR)/$(UBOOT_PATCH_SOURCE)
-@echo unpacked=$(UBOOT_PATCHES)/.unpacked
-@ls $(UBOOT_PATCHES)/.unpacked
-@echo patch-unpacked=$(UBOOT_PATCHES)/.unpacked
-@ls $(UBOOT_PATCHES)/.unpacked
-@echo patched-source=$(UBOOT_DIR)/.patched.$(UBOOT_PATCH_SOURCE)
-@ls $(UBOOT_DIR)/.patched.$(UBOOT_PATCH_SOURCE)
-@echo configured=$(UBOOT_BUILD_DIR)/.configured
-@ls $(UBOOT_BUILD_DIR)/.configured
-@echo mkimage=$(MKIMAGE_BINLOC)
-@ls $(MKIMAGE_BINLOC)
-@echo u-boot.bin=$(UBOOT_BUILD_DIR)/u-boot.bin
-@ls $(UBOOT_BUILD_DIR)/u-boot.bin
-@echo binaries-u-boot.bin=$(BINARIES_DIR)/$(UBOOT_BIN)
-@ls $(BINARIES_DIR)/$(UBOOT_BIN)
-@echo tftpboot=/tftpboot/$(UBOOT_BIN)
-@ls /tftpboot/$(UBOOT_BIN)
-@echo "mkimage = $(MKIMAGE)"
-@ls $(MKIMAGE)
-@echo "u-boot script=$(UBOOT_SCR).$(PROJECT)"
-@ls $(UBOOT_SCR).$(PROJECT)
-@echo "u-boot script (ASCII)=$(UBOOT_SCR)"
-@ls $(UBOOT_SCR)
2007-07-17 14:19:56 +02:00
-@echo "mkimage binary=$(MKIMAGE_BINLOC)"
2007-08-22 13:47:22 +02:00
-@ls $(MKIMAGE_BINLOC)