# Contributor:
# Maintainer:
pkgname=u-boot-q8-a33-tablet
pkgver=2023.01
pkgrel=0
pkgdesc="U-Boot bootloader for the Q8 A33 Tablet"
url="https://source.denx.de/u-boot"
arch="armv7"
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"
depends="linux-postmarketos-allwinner>=5.12"
makedepends="$depends_dev
	bc
	bison
	dtc
	flex
	openssl-dev
	py3-setuptools
	python3-dev
	swig
	"
options="!check"
source="https://source.denx.de/u-boot/u-boot/-/archive/v$pkgver/u-boot-v$pkgver.tar.gz"
builddir="$srcdir/u-boot-v$pkgver"

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 BUILD_DIR="$builddir"/build

		make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm q8_a33_tablet_1024x600_defconfig
		make O="$BUILD_DIR" HOSTCC=gcc ARCH=arm all
		sha512sum -b "$BUILD_DIR/u-boot-sunxi-with-spl.bin" > "$BUILD_DIR/u-boot-sunxi-with-spl.bin.sha512"
}

package() {
		install -D -m644 "build/u-boot-sunxi-with-spl.bin" \
			"$pkgdir/usr/share/u-boot/q8-a33/u-boot-sunxi-with-spl.bin"
		install -D -m644 "build/u-boot-sunxi-with-spl.bin.sha512" \
			"$pkgdir/usr/share/u-boot/q8-a33/u-boot-sunxi-with-spl.bin.sha512"
}
sha512sums="
c25aae1b0d2f677d295587c6d318f23d52bc3a79e968bed9093645943a9840c56b1f6f44e5649d236e76e3dc85f0473c1da4a5205c02dcf437bca820acaf6fb8  u-boot-v2023.01.tar.gz
"
