# Maintainer: Ultracoolguy <myownpersonalaccount@protonmail.com>
# Kernel config based on: arch/arm64/configs/msm8953_defconfig

_flavor="postmarketos-qcom-msm8953"
pkgname=linux-$_flavor
pkgver=5.10_rc6
pkgrel=0
pkgdesc="Mainline kernel fork for Qualcomm MSM8953 devices"
arch="aarch64"
url="https://github.com/msm8953-mainline/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native pmb:kconfigcheck-anbox"
makedepends="bison findutils flex installkernel openssl-dev perl"

_carch="arm64"
# Source
_commit="eb6bbe7cd751aed22254c0b3f8a6776dcb7d530f"
source="
	$pkgname-$_commit.tar.gz::https://github.com/msm8953-mainline/linux/archive/$_commit.tar.gz
	config-$_flavor.$arch
"
builddir="$srcdir/linux-$_commit"

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

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

package() {
	mkdir -p "$pkgdir"/boot
	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_DTBS_PATH="$pkgdir"/usr/share/dtb
	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="fd95f14ea14020fc73c29f434a31e4dfffaa9829e654082b8e37aa1d820696347cc9b75d690d6f271c80fb724492f9b84b5289992229e819f8f0bfc3dbd1ee40  linux-postmarketos-qcom-msm8953-eb6bbe7cd751aed22254c0b3f8a6776dcb7d530f.tar.gz
8b00f2e95bf92f972519d554fb32bd086ab33b3d0570a57249a241f7e3d05fb70047563cb6b7815cc07c5c7d18ae57409c4764b0ef745c04b1ab087136007760  config-postmarketos-qcom-msm8953.aarch64"
