# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/arubaslim_defconfig
pkgname=linux-samsung-arubaslim
pkgver=3.5.1
pkgrel=0
pkgdesc="Samsung Galaxy Core kernel fork"
arch="armv7"
_carch="arm"
_flavor="samsung-arubaslim"
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
"

# Source
_repository="android_kernel_arubaslim"
_commit="aade88cd972ba99b4542a2f8d504cadd3d21c268"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/I8552-CM/$_repository/archive/$_commit.tar.gz
	$_config
	00_fix_return_address.patch
	01_prepare_makefile.patch
	linux3.4-ptrace-fix-ptrace-defect-cause-by-a-merge-fail.patch
	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
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

# 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


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="
e6bb390a7f088afba5833b19d7ece0f086629c182b7fdbdd7ebb014040b9229eeaffd88a9c170f5b1904bb9a54878677a420318eb181846dfede77537160859b  linux-samsung-arubaslim-aade88cd972ba99b4542a2f8d504cadd3d21c268.tar.gz
7956fd9195a0a60f5157cd19f1513637288291bcf84d94e2ff373421eaa2cb3f7e195e89ce3461eb14b174dd5b07d1bf611eaec0b832c38232fb564f6f9d2e47  config-samsung-arubaslim.armv7
ea1d3b5a234fa565e3c1a792de48f4fc4e6023d281d303c8e319c7ef28edc5739ab0e4dea0139a41f0a5c7d03e27921ccaa214fd0ac5c72245a094ce60128864  00_fix_return_address.patch
7c6bdfa9f926c29306cb9f744d6afdca9063ce7eca7bd19ae3460f578e1cf3530893e679273079946970e7224a637dd76f6d279ce7bf14fbdd3fa506b2d4f159  01_prepare_makefile.patch
13f82d1ca9b621f026f12f91bbe03d913be41ebed717e9c657e0f3a4d39c0201ba651a7352c2d27b98bb6641b77ccc1b3ee7d4a7c9e91ddb1e347adcb5c9a780  linux3.4-ptrace-fix-ptrace-defect-cause-by-a-merge-fail.patch
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
"
