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

pkgname=linux-wexler-qc750
pkgver=3.1.10
pkgrel=2
pkgdesc="WEXLER Tab 7t kernel fork"
arch="armv7"
_carch="arm"
_flavor="wexler-qc750"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="bash bc bison devicepkg-dev flex openssl-dev perl gcc6"

# Compiler: GCC 6 (doesn't boot when compiled with newer versions)
if [ "${CC:0:5}" != "gcc6-" ]; then
	CC="gcc6-$CC"
	HOSTCC="gcc6-gcc"
	CROSS_COMPILE="gcc6-$CROSS_COMPILE"
fi

# Source
_repository="morpheus_kernel_wexler_qc750"
_commit="f1b77fa6e9553cf16f39ca8d328e1e5d45f74a62"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/DmitryADP/$_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
	03_fix_rndis.patch
	00-nt11003-touchscreen-fix.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

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

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

sha512sums="0a09ce448b393eb1ab11a0b9b24c8cfc924d3a8c246f230cce03cf24bf9e7f501d7b116114727be0cafbcd1749d81c5bbc5e3d23e663d1f7f6c339a919424917  linux-wexler-qc750-f1b77fa6e9553cf16f39ca8d328e1e5d45f74a62.tar.gz
569f5d82f3e13235a6343e53501c0c4aa06af958726cbb272108d318ddec74f5005e3dc6a87e51e8bae39c3d6be3e1340dc8acc619e855062e1304082d41b19e  config-wexler-qc750.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
6585c67450f1ef6d0c165ce4cb5c64f64d779147d1390558bf72cd40da5a33d53de6fd3c67e5ab864c14b3f67602bbe3060eea07c85b19bb82a0735024b369eb  03_fix_rndis.patch
729d57263eec3df038debd0f6abac748cee0a346d87e1bded7c905d5ae5ba224be7313488345c6e77f5f7c3d59d5f226bf9c3c2e5b331e461356c748ad1a422e  00-nt11003-touchscreen-fix.patch"
