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

pkgname=linux-lg-d855
pkgver=3.4.0
pkgrel=17
pkgdesc="LG G3 International kernel fork"
arch="armv7"
_carch="arm"
_flavor="lg-d855"
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 xz gcc6"

# Compiler: this kernel was only tested with GCC6. Feel free to make a merge
# request if you find out that it is booting working with newer GCCs as
# well. See <https://postmarketos.org/vendorkernel> for instructions.
if [ "${CC:0:5}" != "gcc6-" ]; then
	CC="gcc6-$CC"
	HOSTCC="gcc6-gcc"
	CROSS_COMPILE="gcc6-$CROSS_COMPILE"
fi

# Source
_repository="android_kernel_lge_g3"
_commit="efce7b0879c76224f5bf37d8a1025eaed99192b0"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
	$_config
	gcc10-extern_YYLOC_global_declaration.patch
	02_gpu-msm-fix-gcc5-compile.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="a2e7c0575a677846f734804a462729ca97505101e9090231aeeae5c863b9d1a65d227f04a302157ee9579336be4f8b589f77cb7916ee7d8fc8b8d7fb97295374  linux-lg-d855-efce7b0879c76224f5bf37d8a1025eaed99192b0.tar.gz
ac58be15288d689bef16b7ea84793db97d5be5ab0d02f563ad4753c342a011d16ba4336a5b2c472f498ed328e2045228d32c23d4552a7ef95f82a0a15d0d4c79  config-lg-d855.armv7
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb  gcc10-extern_YYLOC_global_declaration.patch
7be03a9e78b7ac330a54b1f00509caa0621a95c0c55901878ad757f9dd69cc05ba2c8b5ea987063ae1224f92c4d090d515fa5d369e7755181a4871b0d0f82881  02_gpu-msm-fix-gcc5-compile.patch"
