maintainer="Achill Gilgenast <achill@achill.org>"
pkgname=linux-headers
pkgver=6.16.12
# NOTE: Follows Greg's stable Linux releases, see kernel.org
_kernver=${pkgver%.*}
pkgrel=0
pkgdesc="Linux system headers"
url="https://kernel.org/"
arch="all" # Headers are architecture specific
license="GPL-2.0-only"
makedepends="perl"
options="!check !dbg !strip !tracedeps !archcheck"
source="https://kernel.org/pub/linux/kernel/v6.x/linux-$_kernver.tar.xz
	revert-broken-uapi.patch
	0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch
	"
if [ "${pkgver%.0}" = "$pkgver" ]; then
	source="
		patch-$pkgver.patch.xz::https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz
		$source
		"
fi
builddir="$srcdir/linux-$_kernver"

_carch="$CARCH"
case "$_carch" in
aarch64*) _carch="arm64" ;;
arm*) _carch="arm" ;;
mips*) _carch="mips" ;;
s390*) _carch="s390" ;;
ppc*) _carch="powerpc" ;;
riscv*) _carch="riscv" ;;
loongarch*) _carch="loongarch" ;;
# not sure about this --	ppc64*) _carch="powerpc64" ;;
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="
64079698b0ad170b99f59db0ed119eb9920e2df7887c1738434583128cec578901e31f7f6002a7f397670d4d51ff2c2ac3f414c9896de9c7ba4f55e694364c11  patch-6.16.12.patch.xz
55a00f89ad6db6db2e26ff5dc5cfc96bbf6654e5bd5d17d2a3b944a47640367e54139716d230923187bebc6cb7756edc9511a620fb8abc6f32c50a658a734784  linux-6.16.tar.xz
c1fc9a8a0b42dacad51ceb13785f54dfce89369fe082e6457b80a1f75b02704415d397b5df48ca3fdf361ec8c1b72c196b5033bca0325e39d026bcc357d89452  revert-broken-uapi.patch
607c074d72aca88fea9ecdbd62198d8f7857daca75e5d027966e0a9997338d6ac8ce0a1e9114b19232b390751d05acca09e28b0cfad2a12d5942f5575a9f4684  0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch
"
