# Template file for 'cubietruck-uboot'
pkgname=cubietruck-uboot
version=2015.04
revision=1
wrksrc="u-boot-${version}"
hostmakedepends="sunxi-tools uboot-mkimage"
short_desc="Cubietruck U-Boot files for SD booting"
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
license="GPL-2"
homepage="https://github.com/RobertCNelson/u-boot"
distfiles="https://codeload.github.com/RobertCNelson/u-boot/tar.gz/v${version}>u-boot-${version}.tar.gz"
checksum=b7cc9d61eb958ed794918aef72a92f07f41315c164cd9ace5a6ca18e3db4b0e1

only_for_archs="armv7l"

do_build() {
	unset CFLAGS CXXFLAGS LDFLAGS

	if [ "$CROSS_BUILD" ]; then
		make CROSS_COMPILE=${XBPS_CROSS_TRIPLET}- Cubietruck_config
		make CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-
	else
		make Cubietruck_config
		make
	fi
	mkimage -C none -A arm -T script -d ${FILESDIR}/cubietruck.bootcmd boot.scr
	fex2bin ${FILESDIR}/cubietruck.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}/cubietruck.bootcmd 644 boot boot.cmd
}
