# Maintainer: Newbyte <newbie13xd@gmail.com>
# Kernel config based on: arch/arm/configs/qcom_defconfig

_flavor="postmarketos-qcom-msm8226"
pkgname=linux-$_flavor
pkgver=6.3.0
pkgrel=1
_tag="v$pkgver-msm8226"
pkgdesc="Mainline kernel fork for Qualcomm APQ8026/MSM8226/MSM8926 devices"
arch="armv7"
_carch="arm"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
"
makedepends="
	bison
	findutils
	flex
	gmp-dev
	mpc1-dev
	mpfr-dev
	openssl-dev
	perl
	postmarketos-installkernel
"

# Source
source="
	linux-$_tag.tar.gz::https://github.com/msm8226-mainline/linux/archive/refs/tags/$_tag.tar.gz
	config-$_flavor.armv7
	"
builddir="$srcdir/linux-$pkgver-msm8226"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$CARCH" .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_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="
a4031f1d3219f746a392b9389bbe3ff1b6ba49e59b6e97cfa02ff469236836129eae0afc0ffbaf94503328ca39626751df7d3bfb854cf22ed2bbe74da67f3474  linux-v6.3.0-msm8226.tar.gz
d51847270355b93575cf514e8e16ce309f3c5162df28a5f7003bb7987ee8ef17dc5ebd6e518e51e1473f6f832d4e8e4594059b38b46b167d60c9bda2df5511a1  config-postmarketos-qcom-msm8226.armv7
"
