# Reference: <https://postmarketos.org/mainline>
# Kernel config based on: arch/arm64/configs/defconfig
# Maintainer: Ferass El Hafidi <vitali64pmemail@protonmail.com>
# Co-Maintainer: exkc <exxxxkc@getgoogleoff.me>
pkgname=linux-postmarketos-amlogic
pkgver=6.3.3
pkgrel=1
pkgdesc="Mainline kernel for Amlogic devices"
arch="aarch64"
_carch="arm64"
_flavor=postmarketos-amlogic
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
"
makedepends="
	bash
	bc
	bison
	devicepkg-dev
	flex
	openssl-dev
	perl
	gmp-dev
	mpc1-dev
	mpfr-dev
	findutils
	postmarketos-installkernel
	gzip
"
_config="config-$_flavor.$arch"
source="
	$pkgname-$pkgver.tar.xz::https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$pkgver.tar.xz
	$_config
	0001-arm64-dts-meson-gxbb-kii-pro-sort-and-tidy-the-dts.patch
	0002-arm64-dts-meson-gxbb-kii-pro-complete-the-bluetooth-node.patch
	0003-arm64-dts-meson-gxbb-kii-pro-add-initial-audio-support.patch
	0004-add-xiaomi-once-support.patch
	0005-add-x96-mini-support.patch
"
builddir="$srcdir/linux-$pkgver"

prepare() {
	default_prepare
	cp -v "$srcdir"/$_config .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" \
		V=1 # See pmaports#1990
}

package() {
	mkdir -p "$pkgdir"/boot
	make install modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs" \
		V=1 # See pmaports#1990

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

sha512sums="
c9bccb0c225a49009b691009eed0f2261222068e916752583f4a8261ac278eba7a5b9a9f3614624f94d59b81dcc352d2f770fe27166a04f7dbff46229afc41c2  linux-postmarketos-amlogic-6.3.3.tar.xz
6268c09fcdba61a9800b1991fad1fe7ef855c0361f40a6d9e3bb20509664369bbcff19fddae322f30c4d08e29a149441b722c2caf9c19c9446d47ee3e95b711a  config-postmarketos-amlogic.aarch64
3525e0baf74bdab925c2c3b2ce3086effbe463d303f324ac2bafaae5d56422404480ecd8762a9598b9a67fcf6163c872e9ed4c7ba555b927edfb23a8f64ceb0c  0001-arm64-dts-meson-gxbb-kii-pro-sort-and-tidy-the-dts.patch
c8d1aae798623e72248052f0fd07444bf52ee4910326c1de9b8b41a2aefd018636a292d76d7248248bad97730349a8facd32a96b00547cfa3d4ebe0125d4f2ce  0002-arm64-dts-meson-gxbb-kii-pro-complete-the-bluetooth-node.patch
e708b6a14f0ff80c3f25e0323ce3ad8139573de988e72f2f5886ad1bcb40827c4b072188278d14229d468c8a0124f4889fb894ff1fe1e2b3d6db66c3ea7067d4  0003-arm64-dts-meson-gxbb-kii-pro-add-initial-audio-support.patch
9d664c9cc6168a7aa4804662886941744e92c0748e7b7b4fad2472740a4931c89a60cbc4a519913b58933718d02f33f48ff72ea182d912bcd50014ca8d7ff110  0004-add-xiaomi-once-support.patch
3ea569b69297fdb196006b1e1bd82a9dec8d89362ec3ef17918018b6c573143f299a968b8227119660442f6a6e0b795aa4c8a272f6bc23e9622f3fd41ddc97eb  0005-add-x96-mini-support.patch
"
