# rtl8821ce - Realtek RTL8821CE wireless driver
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=rtl8821ce
version=6.30.0
release=1
desc="Realtek RTL8821CE wireless driver"
url="https://github.com/tomaspinho/rtl8821ce"
license="GPL-2.0-only Realtek-proprietary"
depend="glibc"
makedepend="linux-headers"
source="https://github.com/tomaspinho/rtl8821ce/archive/refs/tags/v6.30.0.tar.gz"
sha256="SKIP"

# Built against every installed kernel. alpm re-runs this from the package's
# post_upgrade hook whenever a kernel changes, which is what dkms is for.
#
# gmake, not make: Linux's kbuild is written against GNU make and bmake cannot
# drive it. /usr/bin/make on Arctic is bmake, so kernel modules ask for gmake
# explicitly.
build() {
	cd "rtl8821ce-6.30.0"
	for kdir in /usr/lib/modules/*/build; do
		[ -d "$kdir" ] || continue
		gmake -C "$kdir" M="$PWD" modules
	done
}

package() {
	cd "rtl8821ce-6.30.0"
	for kver in $(ls /usr/lib/modules); do
		install -d "$pkgdir/usr/lib/modules/$kver/extra"
		for ko in *.ko; do
			[ -f "$ko" ] && install -Dm644 "$ko" \
				"$pkgdir/usr/lib/modules/$kver/extra/$ko"
		done
	done
	true
}
