# Kernel config based on: arch/arm64/configs/lineage_ido_defconfig

pkgname="linux-xiaomi-ido"
pkgver=3.10.107
pkgrel=4
pkgdesc="Xiaomi Xiaomi RedMi 3 kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-ido"
url="https://kernel.org"
license="GPL2"
options="!strip !check !tracedeps"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev dtbtool python 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_xiaomi_msm8916"
_commit="8f4c7c59fb3a29344af202150030ae712f801d6b"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
	$_config
	compiler-gcc6.h
	01_fix_gcc6_errors.patch
"
builddir="$srcdir/$_repository-$_commit"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

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

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

	install -Dm644 "$builddir/arch/arm/boot/dt.img" "$pkgdir/boot/dt.img"
}

sha512sums="e22e3cff0819edd2d9f0f16bc952a97773a8b4b36394ab6acf61fd619988d6d0bf1f7d29cba904a09ca0c63209fcedcdf65ee522646193980c5ac6c60e1c3a97  linux-xiaomi-ido-8f4c7c59fb3a29344af202150030ae712f801d6b.tar.gz
c7b9c2900c7d9fa49ea8ceb511092e58aa57e3cf6808e0c9130fac5a5619c7e67b7292e5c4dd23b0a9d3f14f73ba26cbc6c926d5947974395fd602c65324cc1d  config-xiaomi-ido.aarch64
d80980e9474c82ba0ef1a6903b434d8bd1b092c40367ba543e72d2c119301c8b2d05265740e4104ca1ac5d15f6c4aa49e8776cb44264a9a28dc551e0d1850dcc  compiler-gcc6.h
972e98523d6ef06342e69a09e979bdd86904cf7f9a843b519b37791e531b680182564a2ab537c94629c3589f4e775b2c39de04c64e210a0f8b6f10745c3596f1  01_fix_gcc6_errors.patch"
