maintainer="Barnabas Czeman <barnabas.czeman@postmarketos.org>"
_flavor="postmarketos-qcom-msm89x7"
pkgname=linux-postmarketos-qcom-msm89x7
pkgver=6.17.8
pkgrel=0
pkgdesc="Mainline kernel fork for Qualcomm QM215/MSM8917/MSM8937/MSM8940/SDM429/SDM439 devices"
arch="aarch64"
_carch="arm64"
url="https://github.com/msm89x7-mainline/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-nftables
	"
makedepends="
	bash
	bc
	bison
	devicepkg-dev
	findutils
	flex
	openssl-dev
	perl
	postmarketos-installkernel
	python3
	"
_tag="$pkgver-r0"
_config="config-$_flavor.$arch"
source="
	$pkgname-v$_tag.tar.gz::$url/archive/v$_tag.tar.gz
	$_config
"
builddir="$srcdir/linux-$_tag"

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

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

package() {
	mkdir -p "$pkgdir"/boot
	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}
sha512sums="
dda3550657673cd6f606c0cabed8c55d449a9e2110e1ab579bdef37ec04d346e0c953fd98c66970fe36c2a0599d260cae25ecefe644da6c95d4d1b5cc7b25d87  linux-postmarketos-qcom-msm89x7-v6.17.8-r0.tar.gz
5fa02507dc15cf34253563946a7cfc47711573b8c2135bef88fd4895795b4c42e4eb6cbe0665a9523a6bab4977b7d9f97fc1432505307e7fd77b3cc6a6eeab1f  config-postmarketos-qcom-msm89x7.aarch64
"
