# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>

pkgname=linux-rm-headers
pkgver=5.4.70
_rmver=1.3.3
pkgrel=2
pkgdesc="Linux kernel headers with reMarkable patches"
url=https://github.com/reMarkable/linux
provides="linux-headers=$pkgver-r$pkgrel"
makedepends="perl"
options="!check !dbg !strip !tracedeps"
builddir="$srcdir"/linux-RM1XX_${pkgver}_v$_rmver
source="https://github.com/reMarkable/linux/archive/refs/tags/RM1XX_${pkgver}_v$_rmver.tar.gz"
arch="noarch"
license="GPL-2.0"

_carch=$CARCH
case "$CARCH" in
	aarch64) _carch="arm64" ;;
	arm*) _carch="arm" ;;
esac

build() {
	make headers ARCH="$_carch"
}

package() {
	mkdir -p "$pkgdir"/usr/
	cp -a usr/include/ "$pkgdir"/usr/include/

	msg "purging non header files.."
	find "$pkgdir"/usr/include/ ! -iname "*.h" -type f -exec rm -v {} \+

	# provided by libdrm
	rm -rf "$pkgdir"/usr/include/drm
}
sha512sums="
80ab274ca3d30935d9913490662f17499c1ceedb438fe171554097d25ffc1cf85ee53f0c1642e94c0b833fdfb17636cd554bf685e4a6f5dac20cf122c1a25447  RM1XX_5.4.70_v1.3.3.tar.gz
"
