pkgname=linux-postmarketos-grate
pkgver=5.13.0_rc3
pkgrel=0
arch="armv7"
pkgdesc="Linux kernel with experimental patches for Tegra"
url="https://postmarketos.org"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev
	     devicepkg-dev bison flex openssl-dev xz findutils"
options="!strip !check !tracedeps pmb:cross-native"
license="GPL-2.0-only"

# Source
_flavor=postmarketos-grate
_commit="999f244a57a6927de12e142ae8d71acbbf41b47c"
_carch="arm"
_config="config-$_flavor.$arch"
source="$pkgname-$pkgver-$_commit.tar.gz::https://github.com/grate-driver/linux/archive/$_commit.tar.gz
	$_config"
builddir="$srcdir/linux-$_commit"
_outdir="out"

prepare() {
	default_prepare
	REPLACE_GCCH=0 \
		. downstreamkernel_prepare
}

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

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

	make modules_install dtbs_install \
		O="$_outdir" ARCH="$_carch" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_DTBS_PATH="$pkgdir/usr/share/dtb"
}

sha512sums="
6f86c2b5c00909be1fcb0cab746e07c7edd12d24a808ac1385ce8aa2f15367713fb67edc7725943cf3926ab909e05069408263e2edc20c8608a06975fa27be3a  linux-postmarketos-grate-5.13.0_rc3-999f244a57a6927de12e142ae8d71acbbf41b47c.tar.gz
9cb7f681d2444eee038cdac6097fcecd1b7c14ed1ebf85cd86275cda9a2ff6d6729379af171c97894a33332958d8d946a5eb36729b4cdc48e551d77ea1800a08  config-postmarketos-grate.armv7
"
