# Co-Maintainer: WeirdTreeThing <bradyn127@protonmail.com>
maintainer="Eric Anderson <ejona86@gmail.com>"
pkgname=linux-google-veyron
pkgver=6.12.90
pkgrel=0
pkgdesc="Mainline kernel for Google Veyron devices"
arch="armv7"
_carch="arm"
_flavor="${pkgname#linux-}"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
"
makedepends="
	bison
	clang
	findutils
	flex
	lld
	llvm
	openssl-dev
	perl
	postmarketos-installkernel
	xz
	zstd
"
_config="config-$_flavor.$arch"
case $pkgver in
	*.*.*)	_kernver=${pkgver%.0};;
	*.*)	_kernver=$pkgver;;
esac
source="
	https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${pkgver//_/-}.tar.xz
	$_config
	veyron.better_clock_selection_logic_and_dts_rate_list.patch
	veyron.dts_allow_dedicating_npll_to_vop.patch
	veyron.dts_do_dedicate_npll_to_vop.patch
	veyron.ignore-gpt-ignoreme.patch
	veyron.support_dedicating_npll_to_vop.patch
"
builddir="$srcdir/linux-$_kernver"
replaces="linux-postmarketos-rockchip"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$CARCH" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" LLVM=1 \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot

	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		LLVM=1 \
		INSTALL_PATH="$pkgdir"/boot/ \
		INSTALL_MOD_PATH="$pkgdir"/usr \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs"

	rm -f "$pkgdir"/usr/lib/modules/*/build \
		"$pkgdir"/usr/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

sha512sums="
8b909649740677cebb8876f61c6dcfe5646f5d4acd1a8141830a1ec21e5eedf8b0c678f37df13a5733f21c2ef137faf81ed09407d7bdc1dca35b134233f71317  linux-6.12.90.tar.xz
f50dcbfebdcce33cbf5a6da7b91f621ce8510aa56730105e67f9c15998138ff7cc44bcec62dd9f2b23d682a8a6c6f394f6c0a1f4ef8af10030d366ed22e50c00  config-google-veyron.armv7
4f74aa47f8296c03db33ed808c3f7609a87a6109abff6efb47abfaff14d68f57cb05ad5fbb255dc00541b08c0853b241554defc43513f4eb5a4709de952b0e89  veyron.better_clock_selection_logic_and_dts_rate_list.patch
cec81f88da19dc928c54780bf1d39efdf23dee481bc1a3a81cb17f506328103221ef47ee020f5e5b393f20fc20242937698cb733aa376e5d79a75b98c486e513  veyron.dts_allow_dedicating_npll_to_vop.patch
f4336cc18991a01a7d532610758c640d633d1f7ac05e42c229da418eeed109c67c721d6ed5eea593d36178fb8b420dcbd2c0759876358081c669919192330cec  veyron.dts_do_dedicate_npll_to_vop.patch
67f49d49457eed7ae2de4582d53602743dc9c785720527d713e9b14a027a4716c755cf56e5188641cb69b35c5a561f298fa4cf2b37751696768e76e534139f40  veyron.ignore-gpt-ignoreme.patch
c7b8655eff9cce714f9c44c13261750e37ca401930e46f8a57e60dc328927ba2163216a5c66444b9bb51c786daaf4a63f08469e97b24da8d3f28fc8f784269d4  veyron.support_dedicating_npll_to_vop.patch
"
