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

_flavor="postmarketos-qcom-sm6350"
pkgname=linux-$_flavor
pkgver=6.3.3
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="cfe760d759879fde653a77e79e99f3dd0ebd044a"

# 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="
7803c90a17c3b239e714131a3ea6239f100b1eba043c15cce0536a15a4f33f93fe7adb539824f2fb5d2c26c74908462a43ba2060c7dd3382cc8535909c95ed07  linux-cfe760d759879fde653a77e79e99f3dd0ebd044a.tar.gz
f8da4a95544c247580921e702c60e47c853be3949fa86654ce873338d967ae32c8505e1000e53ae280b89c35b60d97f9076f8accbe88488b6b73d7d7e0a8e545  config-postmarketos-qcom-sm6350.aarch64
"
