# Kernel config based on: msm8956_defconfig
maintainer="Barnabas Czeman <barnabas.czeman@postmarketos.org>"
_flavor="postmarketos-qcom-msm8956"
pkgname=linux-$_flavor
pkgver=7.0
pkgrel=0
pkgdesc="Close to mainline linux kernel for Qualcomm Snapdragon MSM8953"
arch="aarch64"
_carch="arm64"
url="https://codeberg.org/msm8956-mainline/linux"
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
	python3
	zstd
"

_tag="$pkgver-r0"

source="
	$pkgname-v$_tag.tar.gz::https://codeberg.org/msm8956-mainline/linux/archive/v$_tag.tar.gz
	config-$_flavor.aarch64
"
builddir="$srcdir/linux"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" .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" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs"
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -Dm644 "$builddir/arch/$_carch/boot/vmlinuz" \
		"$pkgdir/boot/vmlinuz"

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

sha512sums="
6bd22694694d10e932060bfcfaf97e6f92356d6d793ab860770650666cb15459535923f2345c04aebcad4f89e34f78b82a2ba027f47c254d8a98a507ae7f1223  linux-postmarketos-qcom-msm8956-v7.0-r0.tar.gz
7e14bfef8dc4712e4b5f555c6b95eceb2ab39336ed720fa8bf9444636f8af6ec610a170cf366acb6fcc9491bf2168157bf16324125f41fad4a3a90e08ced7add  config-postmarketos-qcom-msm8956.aarch64
"
