# Kernel config based on: arch/arm/configs/embt2_defconfig
maintainer="Andreas Kemnade <andreas@kemnade.info>"
pkgname=linux-epson-embt2ws
pkgver=7.0.6
pkgrel=0
pkgdesc="Epson Moverio BT-200 kernel fork, close to mainline"
arch="armv7"
_carch="arm"
_flavor="epson-embt2ws"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native pmb:kconfigcheck-nftables"
makedepends="
	bash
	bison
	clang
	findutils
	flex
	lld
	llvm
	openssl-dev
	perl
	postmarketos-installkernel
	xz
	zstd
"

# Source
_repository="linux"
_commit="d4881fc77ce75cdd87ecec0871d56054ff8d4eec"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/akemnade/$_repository/archive/$_commit.tar.gz
	$_config
"
builddir="$srcdir/$_repository-$_commit"

prepare() {
	default_prepare
	cp -v "$srcdir"/$_config .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" LLVM=1 \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	mkdir -p "$pkgdir"/boot
	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		LLVM=1 \
		INSTALL_MOD_STRIP=1 \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir/usr" \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs"

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

sha512sums="
a473646916bb3207a642accf699a16ea9b1069904b136507e64b9fb5fedebfde3bac4837566ebecd739da25bde2be7d46a817e912dd09ade7afc2a8c0c05eb1c  linux-epson-embt2ws-d4881fc77ce75cdd87ecec0871d56054ff8d4eec.tar.gz
caf4eaecb249d6675ff396a6f6228aa66ed0493f709dd8312605c062bc4a9d2ba15349972343d2f147d45659d41d5b75fc64317e843aed44948671732911869e  config-epson-embt2ws.armv7
"
