# Kernel config based on: arch/arm/configs/qcom_defconfig
# Co-Maintainer: Luca Weiss <luca@lucaweiss.eu>
maintainer="Newbyte <newbie13xd@gmail.com>"
_flavor="postmarketos-qcom-msm8226"
pkgname=linux-$_flavor
pkgver=6.15.2
pkgrel=0
_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="
	!check
	!strip
	!tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
	"
makedepends="
	bison
	findutils
	flex
	gmp-dev
	mpc1-dev
	mpfr-dev
	openssl-dev
	perl
	postmarketos-installkernel
	python3
"

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

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="
fcc51b32f987afb4f0a09ba18418f099fb14d2fece395a0b1044551106c9e468885c0143af2df73f5d880707cf87ffe853a1161cb3e0122009a762c409e48704  linux-v6.15.2-msm8226.tar.gz
2ca0d6aee757d65eb10e3653e089a77848f3fd9aa107926196f82214226577ff7f9654b0a681c08e5edd9acc57ab83bcf178e37a74f6c73c29021cb412a00b53  config-postmarketos-qcom-msm8226.armv7
"
