# Archived: unmaintained
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/apq8084_sec_defconfig
#                         arch/arm/configs/apq8084_sec_kccat6_eur_defconfig
#                         arch/arm/configs/selinux_defconfig

maintainer=""
pkgname=linux-samsung-kccat6
pkgver=3.10.100
pkgrel=3
pkgdesc="Samsung Galaxy S5 Plus kernel fork"
arch="armv7"
_carch="arm"
_flavor="samsung-kccat6"
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 xz dtbtool"

# Source
_repository="android_kernel_samsung_apq8084"
_commit="45470c5e5fde343926188c3e78a3c652c81408cb"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
	$_config
	gcc8-fix-put-user.patch
	gcc10-extern_YYLOC_global_declaration.patch
	linux3.4-ARM-8933-1-replace-Sun-Solaris-style-flag-on-section.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

# 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

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
	dtbTool -s 2048 -p "scripts/dtc/" -o "arch/arm/boot/dt.img" "out/arch/arm/boot/dts/"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
	install -Dm644 "$builddir/arch/arm/boot/dt.img" \
		"$pkgdir/boot/dt.img"
}

sha512sums="
a09b9f7ac2c70935678e2faac76d5db2d8d98e2dde17de3ed449f5e521c460f6c1d62056b670aba2c99ce0f6941991f8402f31a0696c5763fc799514d6bf3367  linux-samsung-kccat6-45470c5e5fde343926188c3e78a3c652c81408cb.tar.gz
e6a0a6f3bce14bd085dd5f71b842091df898b9e8d13ce7fc2fd55c12676f998ca4160ace533834a504cc091e9c5cb1e3020f14253e2739d86b0794b990e7e2ce  config-samsung-kccat6.armv7
197d40a214ada87fcb2dfc0ae4911704b9a93354b75179cd6b4aadbb627a37ec262cf516921c84a8b1806809b70a7b440cdc8310a4a55fca5d2c0baa988e3967  gcc8-fix-put-user.patch
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb  gcc10-extern_YYLOC_global_declaration.patch
9e3b067fa1b19ad02500c4fce1b6142051df3845c508e615788beb650c4f953683107ac2d80670c4e3df38f532e0e91060d2d13ec04c9ec985abd2dfa82e900b  linux3.4-ARM-8933-1-replace-Sun-Solaris-style-flag-on-section.patch
"
