# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/sturgeon_defconfig

pkgname=linux-huawei-sturgeon
pkgver=3.10.40
pkgrel=0
pkgdesc="Huawei Watch kernel fork"
arch="armv7"
_carch="arm"
_flavor="huawei-sturgeon"
url="https://android.googlesource.com/kernel/msm/+/refs/heads/android-msm-sturgeon-3.10-marshmallow-dr1-wear-release/"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="
	bash
	bc
	bison
	devicepkg-dev
	flex
	linux-headers
	openssl-dev
	perl
"

# Source
_repository="android-kernel-msm-sturgeon"
_commit="97abcf5b24684a46530ffc8a4748dd7ae6c2e65a"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/timbz/$_repository/archive/$_commit.tar.gz
	$_config
	gcc7-give-up-on-ilog2-const-optimizations.patch
	gcc8-fix-put-user.patch
	gcc10-extern_YYLOC_global_declaration.patch
	kernel-use-the-gnu89-standard-explicitly.patch
	0001-mmc-card-not-access-RPMB-partition-for-normal-read-and-write.patch
	0002-msm-mdss-fix-fb-memory-allocation.patch
"

builddir="$srcdir/$_repository-$_commit"
_outdir="out"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
}

sha512sums="
515ae0ddd89251b234368c1082332e216051d528ba7164267c943b5b5b077620fe50aceabc28d0c151fc31804a1c532c38c1289e67bcd87d4a07c5cd9e9729f5  linux-huawei-sturgeon-97abcf5b24684a46530ffc8a4748dd7ae6c2e65a.tar.gz
35b286b663e474f6d20f9ad445832e534a88b74743c3ce847b3c87d5d9c1ded52d632ff8861e0d5188efef8da10b37c4d8b849362bd7d1ed7477e6c4854f6792  config-huawei-sturgeon.armv7
77eba606a71eafb36c32e9c5fe5e77f5e4746caac292440d9fb720763d766074a964db1c12bc76fe583c5d1a5c864219c59941f5e53adad182dbc70bf2bc14a7  gcc7-give-up-on-ilog2-const-optimizations.patch
197d40a214ada87fcb2dfc0ae4911704b9a93354b75179cd6b4aadbb627a37ec262cf516921c84a8b1806809b70a7b440cdc8310a4a55fca5d2c0baa988e3967  gcc8-fix-put-user.patch
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb  gcc10-extern_YYLOC_global_declaration.patch
ad0182a483791fc88e058838bc331b2f04a75ba291e763767babdb815efadfc3b4fda97e69e2e3f00a426cabea088e35297a92bd287592597d1e309be68ee92c  kernel-use-the-gnu89-standard-explicitly.patch
ed1c144529612e7e5320a00979095431135bd3a65271ca76b8b6ceecb26db11d11899a9104695387ffea64cc618f72c79d3caa41481fa11a8bd9b54fdf6fd1d7  0001-mmc-card-not-access-RPMB-partition-for-normal-read-and-write.patch
88443774add9efe2c3278da0e8e75710dbc93fcf2930d07d00346f86860278e2cfe9e9cba1192e9bafda4e0df604e63efbfe2f6242ebe67d08f2c7ce4991532c  0002-msm-mdss-fix-fb-memory-allocation.patch
"
