Re: graphics/gpu-firmware-kmod and PORTS_MODULES - how to!?

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Sat, 28 May 2022 00:59:23 UTC
Hello.

My stable/12 was patched as follows.
And PORTS_MODULES is
PORTS_MODULES=\
	graphics/drm-fbsd12.0-kmod\
	graphics/gpu-firmware-radeon-kmod@caicos\
	graphics/gpu-firmware-radeon-kmod@btc\
	graphics/gpu-firmware-radeon-kmod@sumo

Regards.

diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index cce9fcfd1c6..f6217d38bb8 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -95,7 +95,12 @@ PORTSMODULESENV=\
 all:
 .for __i in ${PORTS_MODULES}
 	@${ECHO} "===> Ports module ${__i} (all)"
-	cd $${PORTSDIR:-/usr/ports}/${__i}; ${PORTSMODULESENV} ${MAKE} -B clean build
+	__i="${__i}" ;\
+	if [ "$${__i%@*}" = "$${__i}" ] ; then\
+	cd $${PORTSDIR:-/usr/ports}/$${__i}; ${PORTSMODULESENV} ${MAKE} -B clean build ;\
+	else\
+	cd $${PORTSDIR:-/usr/ports}/$${__i%@*}; ${PORTSMODULESENV} ${MAKE} -B "FLAVOR=$${__i##*@}" clean build ;\
+	fi
 .endfor

 .for __target in install reinstall clean
@@ -103,7 +108,12 @@ ${__target}: ports-${__target}
 ports-${__target}:
 .for __i in ${PORTS_MODULES}
 	@${ECHO} "===> Ports module ${__i} (${__target})"
-	cd $${PORTSDIR:-/usr/ports}/${__i}; ${PORTSMODULESENV} ${MAKE} -B ${__target:C/(re)?install/deinstall reinstall/}
+	__i="${__i}" ;\
+	if [ "$${__i%@*}" = "$${__i}" ] ; then\
+	cd $${PORTSDIR:-/usr/ports}/$${__i}; ${PORTSMODULESENV} ${MAKE} -B ${__target:C/(re)?install/deinstall reinstall/} ;\
+	else\
+	cd $${PORTSDIR:-/usr/ports}/$${__i%@*}; ${PORTSMODULESENV} ${MAKE} -B "FLAVOR=$${__i##*@}" ${__target:C/(re)?install/deinstall reinstall/} ;\
+	fi
 .endfor
 .endfor
 .endif