maintainer="Henrik Grimler <henrik@grimler.se>"
pkgname=u-boot-samsung-i9100
pkgver=2026.07_rc4
pkgrel=0
pkgdesc="u-boot bootloader for i9100 (close to mainline)"
url="https://www.denx.de/wiki/U-Boot/"
arch="armv7"
license="GPL-2.0-or-later OFL-1.1 BSD-2-Clause BSD-3-Clause WITH eCos-exception-2.0 IBM-pibs
	ISC LGPL-2.0-only LGPL-2.1-only X11"
options="!check !strip !tracedeps pmb:cross-native" # no tests
makedepends="
	bash
	bc
	bison
	dtc
	flex
	gawk
	gnutls-dev
	linux-headers
	ncurses-dev
	openssl-dev
	py3-elftools
	py3-setuptools
	python3-dev
	swig
	util-linux-dev
	"
_tag="v${pkgver//_/-}-exynos4-i9100_(trats-mod)"
source="
	https://gitlab.com/exynos4-mainline/u-boot/-/archive/$_tag/u-boot-$_tag.tar.bz2
"
builddir="$srcdir/u-boot-$pkgver"

prepare() {
	# Avoid having a folder with ( ) in filename, which u-boot
	# does not handle well
	mv "$srcdir/u-boot-$_tag" "$srcdir/u-boot-$pkgver"

	default_prepare
}

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

	make O="$builddir/build" trats_config
	make O="$builddir/build" all
}

package() {
	install -D -m644 build/u-boot.bin \
		"$pkgdir"/usr/share/u-boot/trats/u-boot.bin
}

sha512sums="
5045f7dbfb8db6ba07080959940378e18aaa6ce39c56d8fccff4580045d03bafd5705bf9fbb49ab2df441ac36c1deb243b1cf9be7d0ff253f27c118db3daa48a  u-boot-v2026.07-rc4-exynos4-i9100_(trats-mod).tar.bz2
"
