# Template file for 'cubieboard2-uboot'
pkgname=cubieboard2-uboot
version=v2013.10
revision=9
wrksrc="u-boot-sunxi-${version/v/}-sunxi"
hostmakedepends="sunxi-tools uboot-mkimage"
short_desc="Cubieboard2 U-Boot files for SD booting"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2"
homepage="https://github.com/linux-sunxi/u-boot-sunxi"
distfiles="https://github.com/linux-sunxi/u-boot-sunxi/archive/${version}-sunxi.tar.gz"
checksum=a2a606939574795598d29f04852b1a40ddfcced96e9535d1d31fad30c68e0326

only_for_archs="armv7l"

do_build() {
	unset CFLAGS CXXFLAGS LDFLAGS
  
	if [ "$CROSS_BUILD" ]; then
		make CROSS_COMPILE=${XBPS_CROSS_TRIPLET}- Cubieboard2
	else
		make Cubieboard2
	fi
	mkimage -C none -A arm -T script -d ${FILESDIR}/cubieboard2.bootcmd boot.scr
	fex2bin ${FILESDIR}/cubieboard2.fex script.bin
}

do_install() {
	vinstall u-boot-sunxi-with-spl.bin 644 boot
	vinstall script.bin 644 boot
	vinstall boot.scr 644 boot
	vinstall ${FILESDIR}/cubieboard2.bootcmd 644 boot boot.cmd
}