# Template file for 'odroid-u2-uboot'
pkgname=bananapi-uboot
version=15.01
revision=2
hostmakedepends="sunxi-tools uboot-mkimage"
short_desc="Banana Pi uboot module"
maintainer="necrophcodr <necrophcodr@necrophcodr.me>"
license="GPL-2"
homepage="https://github.com/hardkernel/u-boot"
distfiles="https://github.com/Bananian/u-boot-bananapi/archive/bananian-v${version}.tar.gz"
checksum="935ac90624cc00106a1547b8da2b3e59ab09db9cf658df7126a93738fac74fe5"
wrksrc="u-boot-bananapi-bananian-v${version}"

conf_files="/boot/uEnv.txt"
only_for_archs="armv7l"

do_configure() {
	make mrproper
	make Bananapi_config
}

do_build() {
	unset CFLAGS CXXFLAGS LDFLAGS
  
	if [ "$CROSS_BUILD" ]; then
		make ARCH=arm CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-
	else
		make ARCH=arm
	fi

}

do_install() {
	# Certain files in `files` directory *NEED* to be installed.
	# uEnv.txt: The boot configuration file, in pure text for readability.
	# script.fex: Pure text board configuration, compiled to script.bin.
	vmkdir boot
	cp ${FILESDIR}/uEnv.txt ${DESTDIR}/boot/
	fexc ${FILESDIR}/script.fex ${DESTDIR}/boot/script.bin
	vinstall u-boot-sunxi-with-spl.bin 644 boot
}
