# Maintainer: Jonathan Albrieux <jonathan.albrieux@gmail.com>
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/picmt_defconfig

pkgname=linux-bq-picmt
pkgver=3.10.49
pkgrel=0
pkgdesc="BQ Aquaris X5 kernel fork"
arch="armv7"
_carch="arm"
_flavor="bq-picmt"
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 gcc4 linux-headers"

# Compiler: GCC 4 (Last kernel version built with gcc4.8.x)
if [ "${CC:0:5}" != "gcc4-" ]; then
	CC="gcc4-$CC"
	HOSTCC="gcc4-gcc"
	CROSS_COMPILE="gcc4-$CROSS_COMPILE"
fi

# Source
_repository="aquaris-X5"
_commit="f727041ed84edbe41169f612430ec23fe0754a7e"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/JonnyMe/$_repository/archive/$_commit.tar.gz
	$_config
	gcc10-extern_YYLOC_global_declaration.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"
}

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

sha512sums="409acfb8f8951e3b0d1a11160d2f21e5f4f7de932187ab35828df84b6a3532a9711eceae82105bc93785a0fff1483b994c51ceb4cb60ec34943db137a4091480  linux-bq-picmt-f727041ed84edbe41169f612430ec23fe0754a7e.tar.gz
0393408784501f499dbd41f4e24389e2deab73d55201dc1dcb5a95f0e33d0823aa8d090bab47f8facba518600840098e754a65118cfc002f220581aed4d842ab  config-bq-picmt.armv7
2b48f1bf0e3f70703d2cdafc47d5e615cc7c56c70bec56b2e3297d3fa4a7a1321d649a8679614553dde8fe52ff1051dae38d5990e3744c9ca986d92187dcdbeb  gcc10-extern_YYLOC_global_declaration.patch"