# Maintainer: Luca Weiss <luca@z3ntu.xyz>

_flavor="postmarketos-qcom-sm6350"
pkgname=linux-$_flavor
pkgver=6.2.1
pkgrel=0
pkgdesc="Mainline Kernel fork for SM6350 devices"
arch="aarch64"
_carch="arm64"
url="https://github.com/z3ntu/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
	"
makedepends="bash bison findutils flex installkernel openssl-dev perl"

_repo="linux"
_config="config-$_flavor.$arch"
_commit="2f44774928675e8e291c0145984e0c17789bf7b4"

# Source
source="
	$_repo-$_commit.tar.gz::https://github.com/z3ntu/$_repo/archive/$_commit/$_repo-$_commit.tar.gz
	$_config
"
builddir="$srcdir/$_repo-$_commit"

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() {
	install -Dm644 "$builddir/arch/$_carch/boot/Image.gz" \
		"$pkgdir/boot/vmlinuz"

	make 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="
597e95f7faec52977a7c3232d7464ad8f16cbc6bd5f60c8d51b865e5d5acce8c2dfb672e3bfc098c44fd749118804bfd08ca530e8621e1c982ecd324de18ea18  linux-2f44774928675e8e291c0145984e0c17789bf7b4.tar.gz
e50500690170459a17af7fcd6092f44661450e26e77a8ced9ad010bc70ee0521eb1142e1f6435a9fa86e19f600ec713ae0149f8fa7a9bda1ba51cd18fc5895d1  config-postmarketos-qcom-sm6350.aarch64
"
