# Unmaintained: Downstream port, only for testing. Use mainline port (xiaomi-tissot)!
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/tissot_defconfig

pkgname=linux-xiaomi-tissot-downstream
pkgver=4.9.188
pkgrel=0
pkgdesc="Xiaomi A1 kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-tissot"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev openssl-dev"

# Source
_repository="android_kernel_xiaomi_msm8953"
_commit="b9d144f1c1eb3b959f3cc1c1d8eef87b4383a238"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
	$_config
	0001-use-relative-includes-for-btfs_slim.patch
	0002-use-relative-include-for-including-msm_camera.patch
	0003-use-relative-include-for-u_ncm.patch
	0004-use-relative-include-for-kgsl_device.patch
	0005-narrow-down-include-path-for-msm_isp.patch
	0006-narrow-down-include-path-for-msm_camera.patch
	0007-narrow-down-trace-include-paths.patch
	0008-Add-config-option-to-fix-bootloader-cmdline-args.patch
	fix-xorg-mdss-update-fb-info.patch
	linux4.2-gcc10-extern_YYLOC_global_declaration.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

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="
4d1b8b87369af2eac7f0856f07514d1b3f7caab4234da21fc49d2b3c8d1677e758586933a114f34ec31a8d46d0dbef225bc3d140c5996464f4ea5ffab8c8454b  linux-xiaomi-tissot-downstream-b9d144f1c1eb3b959f3cc1c1d8eef87b4383a238.tar.gz
134c3a05af45d67bb4b97105b91f9d8d864c2bf09e204391c509949e4df088ca8a308dd48a452c278d9071f35374ac31e1a9f1d0ab4954765862daccff860a57  config-xiaomi-tissot.aarch64
8a17e5b943383f87f26fd548087c6a38886f768f207825b30cab193ed7af6b32abb12775964669d5a143f43dc772dc4265f5de3c3c7f6ec0296b18d2c68e0344  0001-use-relative-includes-for-btfs_slim.patch
3645cc9e4c14442409e842de7f508352a8549a1189fa36931d8835b998b1a6fa1e8b7ddf20cad5597713639a6b708e1318dcadf3d8e07c67d6b3b2f3f412c33d  0002-use-relative-include-for-including-msm_camera.patch
fdf3b03b706234d1b71f5031f6c857e2773bb0b08157945f17d9724303f0878173d994bea610869d7c814706927c24502017ecfeefe02bd9e0e24595ecec1c79  0003-use-relative-include-for-u_ncm.patch
c9f5e6de01ce31bdf0c599a5a8569d901d35d767c3965183f706670cc5c4823cf60af90ea9867e3a632f73a26c774c4a50b84b1e2d5bc0c21d0fece4292fb194  0004-use-relative-include-for-kgsl_device.patch
d2da0e6d6945e7396d2cb7e30e64806be2473f0fb67e0117a0b9dc5204a105873828bd8d0c6cfbec26881deb31184db3f42d19e8700ac9226822fcf6d2eec6e3  0005-narrow-down-include-path-for-msm_isp.patch
34d588925668b730aad131ec6b899d0f06538fffeb4a913ed0d1765e2caea417a8711a98c4a06bb100e98c0dd3ab43b762dc3a36a288b664af337ff1803eeeb6  0006-narrow-down-include-path-for-msm_camera.patch
0ee10f54d0a66d4ee4b32599847e977262a3d906093efd34216b91aa12b9f7b46bcd28fffa8b054931eb77c82496d474eee9c5d28c59fc33f8903e6c536189e2  0007-narrow-down-trace-include-paths.patch
cf5c7f3df4bb62617f0d6e3ece29fe2f316fd8d6d38ca352706cb207947ded2bfe7a6b65f9480843204610d6dffe52e6b11df24d3d0cae7812de56bc41081b20  0008-Add-config-option-to-fix-bootloader-cmdline-args.patch
4f73a06557207733707ca08c9991e04734e56386f3ce8e9cc5b640f4b47e1ae607ae3ea14a7003cb98a04f9df943e22c1baf316d520724237533c2c337cc56f2  fix-xorg-mdss-update-fb-info.patch
eaf2e61fcb508cdd239b8fed209d2a09ecac77287f6b46d003918fdf1c6fa2ee63f7390f3ff7c49029b8ed6cbcdd81c7e9a4b1ece9f5060b6fc84e322bd47f41  linux4.2-gcc10-extern_YYLOC_global_declaration.patch
"
