<commit_before>include	../host.mk

BUILD_SCRIPT=build-u-boot.sh

TOPDIR=`pwd`
TARGETS=install
MAKE=make $(XMAKEFLAGS)


ifneq ("$(ARCH)","arm")
TARGETS=help
configure:	help
compile:	help
install:	help
else

ifndef CROSS_COMPILE
TARGETS=help
configure:	help
compile:	help
install:	help
else

UBOOT_VERSION=2013.10
UBOOT=u-boot-$(UBOOT_VERSION)
UBOOT_DIR=$(UBOOT)
PATCH_DIR=../data
UBOOT_SRC=$(UBOOT).tar.bz2

UBOOT_IMAGE=u-boot.img

SRC_URI=ftp://ftp.denx.de/pub/u-boot/

MACHINE_CONFIG=$(UBOOT_DIR)/.config
BOARD_CONFIG=beaglebone_defconfig

all:	setup	$(TARGETS)

download:	$(UBOOT_SRC)

unpack:		$(UBOOT_DIR)/.extracted

configure:	$(MACHINE_CONFIG)

compile:	$(UBOOT_IMAGE)	$(UBOOT_DT)

patched:	$(UBOOT_DIR)/.patched

install:	compile modules	$(NFS_PATH)
	install	-d	$(NFS_PATH)/boot
	install	-m 0755	$(UBOOT_IMAGE)	$(NFS_PATH)/boot
	install	-m 0755	$(UBOOT_DT)	$(NFS_PATH)/boot
	@echo	"$(MAKE) -C $(UBOOT_DIR) INSTALL_MOD_PATH=$(NFS_PATH) modules_install"	>>	$(BUILD_SCRIPT)
	$(MAKE) -C $(UBOOT_DIR) INSTALL_MOD_PATH=$(NFS_PATH) modules_install
	chmod	a+x	$(BUILD_SCRIPT)

source:		$(UBOOT_DIR)

setup:
	echo	"#!/bin/sh"						>	$(BUILD_SCRIPT)

$(UBOOT_SRC):
	@echo	"wget	$(SRC_URI)/$(UBOOT_SRC)"			>>	$(BUILD_SCRIPT)
	wget	$(SRC_URI)/$(UBOOT_SRC)
	touch	$@

$(UBOOT_DIR)/.extracted:	$(UBOOT_SRC)
	@echo	"tar	-jxvf	$(UBOOT_SRC)"				>>	$(BUILD_SCRIPT)
	tar	-jxvf	$(UBOOT_SRC)
	touch	$@

$(UBOOT_DIR)/.git:	$(UBOOT_DIR)/.extracted
	@echo	"git	init; git add . ; git commit -m \"Initial Commit\" -s"	>>	$(BUILD_SCRIPT)
	(			\
	cd $(UBOOT_DIR) ;	\
	git init ;		\
	git add .;		\
	git commit -m "Initial Commit" -s	\
	)

$(UBOOT_DIR)/.patched:	$(UBOOT_DIR)/.git
	@echo	"git	am	$(PATCH_DIR)/0001-arm-omap-i2c-don-t-zero-cnt-in-i2c_write.patch"	>>	$(BUILD_SCRIPT)
	(cd	$(UBOOT_DIR) ;	\
	git	am	$(PATCH_DIR)/0001-arm-omap-i2c-don-t-zero-cnt-in-i2c_write.patch	\
	)
	touch	$@

$(MACHINE_CONFIG):	$(UBOOT_DIR)/.patched
	@echo	"$(MAKE) -C $(UBOOT_DIR)	$(BOARD_CONFIG)"	>>	$(BUILD_SCRIPT)
	$(MAKE) -C $(UBOOT_DIR)	$(BOARD_CONFIG)

$(UBOOT_IMAGE):	$(MACHINE_CONFIG)
	@echo	"$(MAKE) -C $(UBOOT_DIR)"	>>	$(BUILD_SCRIPT)
	$(MAKE) -C $(UBOOT_DIR)
	cp	$(UBOOT_DIR)/$(UBOOT_IMAGE)	.


$(NFS_PATH):
	$(MAKE)	-C .. nfs

#	mkdir	-p	$(NFS_PATH)

prepare:	$(NFS_PATH)
	$(MAKE)	-C .. prepare

endif

endif

clean:
	rm	-fr	$(UBOOT_DIR)	$(UBOOT_IMAGE)	$(UBOOT_DT)
	rm	-fr	$(NFS_PATH)/boot/$(UBOOT_IMAGE)
	rm	-fr	$(NFS_PATH)/boot/$(UBOOT_DT)
	rm	-fr	$(NFS_PATH)/lib/modules
	rm	-f	*~
	rm	-f	$(BUILD_SCRIPT)

help:
	@echo "You need to have a valid arm-linux-gcc"
	@echo "CROSS_COMPILE needs to be defines"
	@echo "ARCH needs to be arm"

debug:
	@echo	MACHINE_CONFIG=$(MACHINE_CONFIG)
	@echo	UBOOT_IMAGE=$(UBOOT_IMAGE)
	@echo	UBOOT_DT=$(UBOOT_DT)<commit_msg>U-Boot Makefile<commit_after>include	../host.mk

BUILD_SCRIPT=build-u-boot.sh

TOPDIR=`pwd`
TARGETS=install
MAKE=make


ifneq ("$(ARCH)","arm")
TARGETS=help
configure:	help
compile:	help
install:	help
else

ifndef CROSS_COMPILE
TARGETS=help
configure:	help
compile:	help
install:	help
else

UBOOT_VERSION=2013.10
UBOOT=u-boot-$(UBOOT_VERSION)
UBOOT_DIR=$(UBOOT)
PATCH_DIR=../data
UBOOT_SRC=$(UBOOT).tar.bz2
UBOOT_PATCH=0001-arm-omap-i2c-don-t-zero-cnt-in-i2c_write.patch

UBOOT_IMAGE=u-boot.img

SRC_URI=ftp://ftp.denx.de/pub/u-boot

MACHINE_CONFIG=$(UBOOT_DIR)/include/autoconf.mk
BOARD_CONFIG=am335x_boneblack

all:	setup	$(TARGETS)

download:	$(UBOOT_SRC)

unpack:		$(UBOOT_DIR)/.extracted

configure:	$(MACHINE_CONFIG)

compile:	$(UBOOT_DIR)/$(UBOOT_IMAGE)

patched:	$(UBOOT_DIR)/.patched

install:	$(UBOOT_DIR)/$(UBOOT_IMAGE)
	@echo	"mkdir	-p	deploy"					>>	$(BUILD_SCRIPT)
	@echo	"cp	$(UBOOT_DIR)/$(UBOOT_IMAGE)	deploy"		>>	$(BUILD_SCRIPT)
	@echo	"cp	$(UBOOT_DIR)/MLO		deploy"		>>	$(BUILD_SCRIPT)
	mkdir	-p	deploy
	cp	$(UBOOT_DIR)/$(UBOOT_IMAGE)	deploy
	cp	$(UBOOT_DIR)/MLO		deploy
	chmod	a+x	$(BUILD_SCRIPT)

source:		$(UBOOT_DIR)

setup:
	echo	"#!/bin/sh"						>	$(BUILD_SCRIPT)

$(UBOOT_SRC):
	@echo	"wget	$(SRC_URI)/$(UBOOT_SRC)"			>>	$(BUILD_SCRIPT)
	wget	$(SRC_URI)/$(UBOOT_SRC)
	touch	$@

$(UBOOT_DIR)/.extracted:	$(UBOOT_SRC)
	@echo	"tar	-jxvf	$(UBOOT_SRC)"				>>	$(BUILD_SCRIPT)
	tar	-jxvf	$(UBOOT_SRC)
	touch	$@

$(UBOOT_DIR)/.git:	$(UBOOT_DIR)/.extracted
	@echo	"cd	$(UBOOT_DIR)"					>>	$(BUILD_SCRIPT)
	@echo	"git	init"						>>	$(BUILD_SCRIPT)
	@echo	"git	add ."						>>	$(BUILD_SCRIPT)
	@echo	"git	commit -m \"Initial Commit\" -s"		>>	$(BUILD_SCRIPT)
	@echo	"cd	.."						>>	$(BUILD_SCRIPT)
	(			\
	cd $(UBOOT_DIR) ;	\
	git init ;		\
	git add .;		\
	git commit -m "Initial Commit" -s	\
	)

$(UBOOT_DIR)/.patched:	$(UBOOT_DIR)/.git
	@echo	"cd	$(UBOOT_DIR)"					>>	$(BUILD_SCRIPT)
	@echo	"git	am	$(PATCH_DIR)/$(UBOOT_PATCH)"		>>	$(BUILD_SCRIPT)
	@echo	"cd	.."						>>	$(BUILD_SCRIPT)
	(cd	$(UBOOT_DIR) ;					\
	git	am	$(PATCH_DIR)/$(UBOOT_PATCH)		\
	)
	touch	$@

$(MACHINE_CONFIG):	$(UBOOT_DIR)/.patched
	@echo	"$(MAKE)	-C $(UBOOT_DIR)	$(BOARD_CONFIG)_config"	>>	$(BUILD_SCRIPT)
	$(MAKE) -C $(UBOOT_DIR)	$(BOARD_CONFIG)_config

$(UBOOT_DIR)/$(UBOOT_IMAGE):	$(MACHINE_CONFIG)
	@echo	"$(MAKE)	-C $(UBOOT_DIR)"				>>	$(BUILD_SCRIPT)
	$(MAKE)	-C $(UBOOT_DIR)

$(NFS_PATH):
	$(MAKE)	-C .. nfs

#	mkdir	-p	$(NFS_PATH)

prepare:	$(NFS_PATH)
	$(MAKE)	-C .. prepare

endif

endif

clean:
	rm	-fr	$(UBOOT_DIR)
	rm	-f	$(UBOOT_IMAGE)
	rm	-f	*~
	rm	-f	$(BUILD_SCRIPT)
	rm	-f	$(UBOOT_SRC)
	rm	-fr	deploy

help:
	@echo "You need to have a valid arm-linux-gcc"
	@echo "CROSS_COMPILE needs to be defines"
	@echo "ARCH needs to be arm"

debug:
	@echo	MACHINE_CONFIG=$(MACHINE_CONFIG)
	@echo	UBOOT_IMAGE=$(UBOOT_IMAGE)
	@echo	UBOOT_DT=$(UBOOT_DT)
{'fraction_non_alphanumeric': 0.1883745963401507, 'fraction_numerical': 0.007714388231072838, 'mean_word_length': 4.503455083909181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3365988', 'n_tokens_mistral': 2925, 'n_tokens_neox': 2775, 'n_words': 474}