# rtl8812au - Realtek RTL8812AU 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=rtl8812au
version=5.13.6
release=1
desc="Realtek RTL8812AU wireless driver"
url="https://github.com/morrownr/8812au-20210629"
license="GPL-2.0-only Realtek-proprietary"
depend="glibc"
makedepend="linux-headers"
source="https://github.com/morrownr/8812au-20210629/archive/refs/heads/main.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 "main"
	for kdir in /usr/lib/modules/*/build; do
		[ -d "$kdir" ] || continue
		gmake -C "$kdir" M="$PWD" modules
	done
}

package() {
	cd "main"
	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
}
