# Maintainer: exkc <exxxxkc@getgoogleoff.me>
pkgname=u-boot-mangopi-mq-pro
pkgver=2022.11.01
pkgrel=1
pkgdesc="u-boot bootloader for mangopi mq pro"
url="https://github.com/smaeul/u-boot/tree/d1-wip"
arch="riscv64"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause eCos-2.0 IBM-pibs
	ISC LGPL-2.0-only LGPL-2.1-only X11"
makedepends="$depends_dev py3-setuptools bc dtc python3-dev swig bison flex openssl-dev opensbi"
options="!check"
#The lastest tag dont had mangopi mq pro support so we use this commit
_commit="528ae9bc6c55edd3ffe642734b4132a8246ea777"
source="u-boot-$_commit.tar.gz::https://github.com/smaeul/u-boot/archive/$_commit.tar.gz
	update-u-boot
	"
builddir="$srcdir"/u-boot-$_commit

build() {
	touch include/config.h
	LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
	LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h

	export OPENSBI="/usr/share/opensbi/generic/firmware/fw_dynamic.bin"
	export BUILD_DIR="$builddir"/build
	mkdir -p "$BUILD_DIR"
	make O="$BUILD_DIR" HOSTCC=gcc ARCH=riscv mangopi_mq_pro_defconfig
	make O="$BUILD_DIR" HOSTCC=gcc ARCH=riscv all
}

package() {
	install -D -m644 build/u-boot-sunxi-with-spl.bin \
		"$pkgdir"/usr/share/u-boot/mangopi_mq_pro/u-boot-sunxi-with-spl.bin
	install -D -m755 "$srcdir"/update-u-boot "$pkgdir"/usr/sbin/update-u-boot
}


sha512sums="
41cac25c10c6a1ac951a10af336df96ad77283b036cf17d7aca64bf81bc7e04b8c145778fb250b429cae71ac3350e1ba42ef8d9604d52d03c5fe8715901994b3  u-boot-$_commit.tar.gz
7a683d22073223cab7b65783ee4f8dc2c0c1b2c651be8da885bc657dc2442959c67b581984d6e6830d329fbaacf747da0fbec2ee36da6ff17930fed6dfa7abbb  update-u-boot
"

