# Kernel config based on: arch/arm/configs/aosp_shinano_aries_defconfig

pkgname="linux-sony-aries"
pkgver=3.10.84
pkgrel=7
pkgdesc="Sony Xperia Z3 Compact kernel"
arch="armhf"
_carch="arm"
_flavor=sony-aries
url="https://github.com/sonyxperiadev/kernel"
license="GPL2"
options="!strip !check !tracedeps"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev"
HOSTCC="${CC:-gcc}"
HOSTCC="${HOSTCC#${CROSS_COMPILE}}"

# Source
_repository="kernel"
_commit="b1ceda7b02ea29c526d329884db1e9f2694ab394"
_config="config-${_flavor}.armhf"
source="
	$pkgname-$_commit.tar.gz::https://github.com/sonyxperiadev/${_repository}/archive/${_commit}.tar.gz
	$_config
	compiler-gcc6.h
	02_mdss_fb_refresh_rate.patch
"
builddir="$srcdir/${_repository}-${_commit}"

prepare() {
	default_prepare

	# gcc6 support
	cp -v "$srcdir/compiler-gcc6.h" "$builddir/include/linux/"

	cp "$srcdir"/$_config "$builddir"/.config
	make ARCH="$_carch" HOSTCC="$HOSTCC" silentoldconfig
}

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

package() {
	install -Dm644 "$builddir/arch/arm/boot/zImage-dtb" \
		"$pkgdir/boot/vmlinuz-$_flavor"

	install -D "$builddir/include/config/kernel.release" \
		"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
}

sha512sums="f63f32b9eb0e81509dad2ede7c8e8f8e367c80ede2c411009c7135a1108a62042a67e911bf7811fb340e9a868a382b7da18f2b5c01e04034c2b5661049a573e0  linux-sony-aries-b1ceda7b02ea29c526d329884db1e9f2694ab394.tar.gz
0c453c3f74941854e98d3a4465e667e6996192b2c0e8ef69a3de5815cd26317642099bf7e85b91f200c5ba5edd70c43fb7a5982f0268fb8d31788a537914c8ef  config-sony-aries.armhf
d80980e9474c82ba0ef1a6903b434d8bd1b092c40367ba543e72d2c119301c8b2d05265740e4104ca1ac5d15f6c4aa49e8776cb44264a9a28dc551e0d1850dcc  compiler-gcc6.h
a8c955bf718f155011e980f3d0948be98e1fee5649f418299a4851780543019daf7afa406aa7b0829375645107e4e6fbf241026b0cabe2b2ac895a47df83d2d8  02_mdss_fb_refresh_rate.patch"
