# Maintainer: David Wronek <w.david0@protonmail.com>
# Co-Maintainer: Danila Tikhonov <JIaxyga@protonmail.com>

_flavor="postmarketos-qcom-sm7150"
pkgname=linux-$_flavor
pkgver=6.2.0
pkgrel=1
pkgdesc="Mainline Kernel fork for SM7150 devices"
arch="aarch64"
_carch="arm64"
url="https://github.com/sm7150-mainline/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-nftables
	"
makedepends="bison findutils flex installkernel openssl-dev perl"

_repo="linux"
_config="config-$_flavor.$arch"
_commit="106298cb0d89286b8ea78de606967d02cdc81dc5"

# Source
source="
	$_repo-$_commit.tar.gz::https://github.com/sm7150-mainline/$_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() {
	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="
1dcd8a6180874465cc5f61a9a1d8a196fceb67a50fa39077547b5bb7fd6d2fc803764e3bcbc3b1d4806dfdf3d5eb1c5f19e665cb9684eb333672bf3aef98b618  linux-106298cb0d89286b8ea78de606967d02cdc81dc5.tar.gz
44b0a2ca1481e832e08f1e6998cb2a9b297b2774252d08ac4a12a2ff59a4c9750d997fb7abef34e6c3c912288f1332a731e77075aadfc3b0320570e6c82ac04a  config-postmarketos-qcom-sm7150.aarch64
"
