maintainer="Alexandre MINETTE <contact@alex-min.fr>"
_flavor="postmarketos-qcom-apq8064"
pkgname=linux-postmarketos-qcom-apq8064
pkgver=7.1
pkgrel=0
_commit="085b3970a6a591d6703749aeed290413fe2a68b4"
pkgdesc="Mainline Kernel fork for APQ8064 devices"
url="https://github.com/apq8064-mainline/linux"
arch="armv7"
_carch="arm"
license="GPL-2.0-only"
options="
	!check
	!strip
	!tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
"
makedepends="
	bison
	clang
	findutils
	flex
	lld
	llvm
	openssl-dev
	perl
	postmarketos-installkernel
	python3
	xz
	zstd
"
_config="config-$_flavor.$arch"
_tag="qcom-apq8064-v${pkgver/_/-}"

# Source
source="
	https://github.com/apq8064-mainline/linux/archive/$_tag/$_commit.tar.gz
	$_config
"
builddir="$srcdir/linux-qcom-apq8064-v7.1"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" LLVM=1 \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot
	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		LLVM=1 \
		INSTALL_PATH="$pkgdir"/boot/ \
		INSTALL_MOD_PATH="$pkgdir"/usr \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/usr/lib/modules/*/build "$pkgdir"/usr/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/"$_flavor"/kernel.release
}

sha512sums="
b314e9385eb33b422ebfaf0e27641cf615247dcc2e0d77ae32c72ab77ea48c58cf1df1b39775b6e3ef14b98466085f3445934ba45796e14817b28576895983ee  085b3970a6a591d6703749aeed290413fe2a68b4.tar.gz
f9fd62aa490658864e1295a84a720602da3bbd60aa6ef5f90af55ab878898381eb5528b2470732f88f3126ce852aafa3cc1a3615db138114d1c9f11f648da4e8  config-postmarketos-qcom-apq8064.armv7
"
