# Maintainer: Petr Vorel <petr.vorel@gmail.com>
# Kernel config based on: arch/arm64/configs/defconfig

_flavor="postmarketos-qcom-msm8994"
pkgname=linux-$_flavor
pkgver=6.3_rc5
pkgrel=1
pkgdesc="Mainline kernel for Qualcomm MSM8994/MSM8992 devices"
arch="aarch64"
_carch="arm64"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-nftables
	pmb:kconfigcheck-zram
	"
makedepends="
	bison
	findutils
	flex
	openssl-dev
	perl
	postmarketos-installkernel
"

_tag=${pkgver//_/-}
source="
	https://git.kernel.org/torvalds/t/linux-$_tag.tar.gz
	config-$_flavor.$arch
	0001-arm64-dts-msm8994-angler-Fix-cont_splash_mem-mapping.patch
	0002-arm64-dts-msm8994-angler-removed-clash-with-smem_reg.patch
	0003-arm64-dts-qcom-msm8994-huawei-angler-Add-regulators.patch
"
builddir="$srcdir/linux-${_tag#v}"

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

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

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="
84f8b612268a2f6d47e35afc06865db3a779c7877ab2fde8a70e219093c113fb82d10cddf042f2600522659d7f86c5daa1ee622a72baeaba74de55b374093221  linux-6.3-rc5.tar.gz
9b896642fb33669c387b6707fef50c9e680f0a290916a1a619a72b8c4c3f7dc0f0b1f63e7c5bc998e3862bd47e5a1e9411c4ea92fc49907de1250c1eab17fa4e  config-postmarketos-qcom-msm8994.aarch64
29573678c82723821e3522a649158137dfc49e61b78c6319a4c6bc97cfe0d98fdc994d2271934beb223da11bd0cdb085bf5422454287575c28ed06c47ea63f68  0001-arm64-dts-msm8994-angler-Fix-cont_splash_mem-mapping.patch
ca46f96560b14044b88791e04e49b7cff59f1217a5e7e8f56092f624c24707b30edfc3d862098599a784a8695558a1b67ff964789188f26518a1496377de7632  0002-arm64-dts-msm8994-angler-removed-clash-with-smem_reg.patch
4dc3de184eac5cfb593a308278e3a5ab27f5e94b5dec8b288c053070f788fdb8d8fad8628b5a996701eacc11b1015999b99f8d279b207e214dd0e63f97cfb4d6  0003-arm64-dts-qcom-msm8994-huawei-angler-Add-regulators.patch
"
