# Template file for 'asahi-uboot'
pkgname=asahi-uboot
version=2024.10+1
revision=1
archs="aarch64*"
hostmakedepends="bison flex which python3 swig python3-devel
 python3-setuptools python3-pyelftools bc dtc openssl-devel libuuid-devel
 gnutls-devel"
depends="m1n1"
checkdepends="python3-pytest dtc-devel python3-filelock"
short_desc="Das U-Boot for Apple Silicon Macs"
maintainer="Will Springer <skirmisher@protonmail.com>, dkwo <npiazza@disroot.org>"
license="GPL-2.0-or-later, MIT"
homepage="https://asahilinux.org"
distfiles="https://github.com/AsahiLinux/u-boot/archive/refs/tags/asahi-v${version/+/-}.tar.gz"
checksum=c226191d52d3f853dd7d4e2c241e4259b90bd0aecb4c56e324936cc61b1bb53e
make_check=no # missing python3-libftf ?

do_configure() {
	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
	make ${makejobs} apple_m1_defconfig
}

do_build() {
	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
	if [ "$CROSS_BUILD" ]; then
		export CROSS_COMPILE=${XBPS_CROSS_TRIPLET}-
	fi
	make ${makejobs} EXTRAVERSION=-${revision}
}

do_install() {
	vinstall u-boot-nodtb.bin 0644 usr/lib/asahi-boot
	for dtb in arch/arm/dts/t[86]*.dtb ; do
		vinstall ${dtb} 0644 usr/lib/asahi-boot/dtb
	done
}

post_install() {
	vlicense Licenses/Exceptions
	vlicense Licenses/OFL.txt
	vlicense Licenses/README
	vlicense Licenses/bsd-2-clause.txt
	vlicense Licenses/bsd-3-clause.txt
	vlicense Licenses/eCos-2.0.txt
	vlicense Licenses/gpl-2.0.txt
	vlicense Licenses/ibm-pibs.txt
	vlicense Licenses/isc.txt
	vlicense Licenses/lgpl-2.0.txt
	vlicense Licenses/lgpl-2.1.txt
	vlicense Licenses/r8a779x_usb3.txt
	vlicense Licenses/x11.txt
}
