# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=rtl8821ce-src
_commit=98cff1d7dcbf17b36a98bac342df75dfe0b79017
_modname=${pkgname%-src}
pkgver=5_git20250331
pkgrel=0
pkgdesc="Wifi drivers for Realtek 8821ce (src, AKMS)"
url="https://github.com/tomaspinho/rtl8821ce"
arch="x86_64 x86" # Module supports these arches
license="GPL-2.0-only"
options="!check" # No test suite
source="$pkgname-$_commit.tar.gz::https://github.com/tomaspinho/rtl8821ce/archive/$_commit.tar.gz"
builddir="$srcdir/$_modname-$_commit"

prepare() {
	default_prepare

	cat >AKMBUILD <<-EOF
	modname=$_modname
	modver=$pkgver
	built_modules=8821ce.ko

	# This module doesn't support building outside of its source dir.
	build() {
	    cp -r "\$srcdir"/* .
	    make \$MAKEFLAGS KVER="\$kernel_ver" KSRC="\$kernel_srcdir"
	}
	EOF
}

package() {
	local destdir="$pkgdir/usr/src/$_modname-$pkgver"
	install -Dm0644 -t "$destdir" AKMBUILD Makefile halmac.mk rtl8821c.mk
	cp -r core hal include os_dep platform "$destdir"
}

sha512sums="
a68e623eefca588de13108f03502601508f33f7fb0dba1ac4bd37374cdc6b35ae0bf2ff9a93c069fc5ee749976bcbe8589e53def0a6a977042513efbf7a24054  rtl8821ce-src-98cff1d7dcbf17b36a98bac342df75dfe0b79017.tar.gz
"