git: 5d6891c1e621 - main - textproc/fcitx5-gtk*: Add GTK4 support

From: Li-Wen Hsu <lwhsu_at_FreeBSD.org>
Date: Sat, 18 Mar 2023 13:13:32 UTC
The branch main has been updated by lwhsu:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5d6891c1e621ca95fd97010a069c0781e0d41b81

commit 5d6891c1e621ca95fd97010a069c0781e0d41b81
Author:     Li-Wen Hsu <lwhsu@FreeBSD.org>
AuthorDate: 2023-03-18 13:06:19 +0000
Commit:     Li-Wen Hsu <lwhsu@FreeBSD.org>
CommitDate: 2023-03-18 13:06:19 +0000

    textproc/fcitx5-gtk*: Add GTK4 support
    
    - Split into gtk2, gtk3, gtk4 FLAVORS
    - Extract common files to textproc/fcitx5-gtk-common
    
    Approved by:    khng
    Differential Revision: https://reviews.freebsd.org/D38074
---
 textproc/Makefile                                  |  1 +
 textproc/fcitx5-gtk-common/Makefile                | 18 ++++++++++++++
 textproc/fcitx5-gtk/Makefile                       | 28 +++++++++++++++++++---
 .../fcitx5-gtk/{pkg-plist => pkg-plist.common}     |  6 -----
 textproc/fcitx5-gtk/pkg-plist.gtk2                 |  3 +++
 textproc/fcitx5-gtk/pkg-plist.gtk3                 |  3 +++
 textproc/fcitx5-gtk/pkg-plist.gtk4                 |  1 +
 7 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/textproc/Makefile b/textproc/Makefile
index fbba825f4661..eb715443fc39 100644
--- a/textproc/Makefile
+++ b/textproc/Makefile
@@ -205,6 +205,7 @@
     SUBDIR += fcitx5
     SUBDIR += fcitx5-configtool
     SUBDIR += fcitx5-gtk
+    SUBDIR += fcitx5-gtk-common
     SUBDIR += fcitx5-lua
     SUBDIR += fcitx5-m17n
     SUBDIR += fcitx5-qt
diff --git a/textproc/fcitx5-gtk-common/Makefile b/textproc/fcitx5-gtk-common/Makefile
new file mode 100644
index 000000000000..79e1e775e448
--- /dev/null
+++ b/textproc/fcitx5-gtk-common/Makefile
@@ -0,0 +1,18 @@
+COMMENT=	Fcitx support for GTK+ (common files)
+
+PKGNAMESUFFIX=	-common
+
+MASTERDIR=	${.CURDIR}/../fcitx5-gtk
+
+RUN_DEPENDS=	# empty
+
+PLIST=	${MASTERDIR}/pkg-plist.common
+
+FLAVORS=	# empty
+FLAVOR=	# empty
+
+CMAKE_ON=	# empty
+CMAKE_OFF=	ENABLE_GTK2_IM_MODULE ENABLE_GTK3_IM_MODULE \
+		ENABLE_GTK4_IM_MODULE
+
+.include "${MASTERDIR}/Makefile"
diff --git a/textproc/fcitx5-gtk/Makefile b/textproc/fcitx5-gtk/Makefile
index 3d4bae6ee258..0bb995ec2f22 100644
--- a/textproc/fcitx5-gtk/Makefile
+++ b/textproc/fcitx5-gtk/Makefile
@@ -4,13 +4,21 @@ PORTREVISION=	1
 CATEGORIES=	textproc
 
 MAINTAINER=	khng@FreeBSD.org
-COMMENT=	Fcitx support for GTK+ 2/3
+COMMENT?=	Fcitx support for GTK+ ${FLAVOR}
 WWW=		https://github.com/fcitx/fcitx5-gtk
 
 LICENSE=	LGPL21+
 LICENSE_FILE=	${WRKSRC}/LICENSES/LGPL-2.1-or-later.txt
 
 LIB_DEPENDS=	libxkbcommon.so:x11/libxkbcommon
+RUN_DEPENDS?=	fcitx5-gtk-common>=${DISTVERSION}:textproc/fcitx5-gtk-common
+
+FLAVORS?=	gtk3 gtk2 gtk4
+FLAVOR?=	${FLAVORS:[1]}
+
+gtk2_PKGNAMESUFFIX=	2
+gtk3_PKGNAMESUFFIX=	3
+gtk4_PKGNAMESUFFIX=	4
 
 USES=		compiler:c++17-lang gettext-tools cmake gnome kde:5 pkgconfig xorg
 
@@ -20,10 +28,24 @@ USE_LDCONFIG=	yes
 
 USE_GITHUB=	yes
 GH_ACCOUNT=	fcitx
-USE_GNOME=	introspection glib20 gtk20 gtk30
+USE_GNOME=	cairo gdkpixbuf2 glib20 introspection
 USE_KDE=	ecm
 USE_XORG=	x11
 
-CMAKE_OFF=	ENABLE_GTK4_IM_MODULE
+CMAKE_ON?=	BUILD_ONLY_PLUGIN
+
+.if ${FLAVOR} == gtk3
+CMAKE_OFF+=	ENABLE_GTK2_IM_MODULE ENABLE_GTK4_IM_MODULE
+USE_GNOME+=	gtk30
+.elif ${FLAVOR} == gtk2
+CMAKE_OFF+=	ENABLE_GTK3_IM_MODULE ENABLE_GTK4_IM_MODULE
+USE_GNOME+=	gtk20
+.elif ${FLAVOR} == gtk4
+CMAKE_OFF+=	ENABLE_GTK2_IM_MODULE ENABLE_GTK3_IM_MODULE
+USE_GNOME+=	gtk40
+.endif
+
+PLIST?=		${PKGDIR}/pkg-plist.${FLAVOR}
+PLIST_SUB=	VER=${PORTVERSION}
 
 .include <bsd.port.mk>
diff --git a/textproc/fcitx5-gtk/pkg-plist b/textproc/fcitx5-gtk/pkg-plist.common
similarity index 58%
rename from textproc/fcitx5-gtk/pkg-plist
rename to textproc/fcitx5-gtk/pkg-plist.common
index 89fa71e9cb30..5668dd9548d9 100644
--- a/textproc/fcitx5-gtk/pkg-plist
+++ b/textproc/fcitx5-gtk/pkg-plist.common
@@ -5,14 +5,8 @@ lib/cmake/Fcitx5GClient/Fcitx5GClientConfigVersion.cmake
 lib/cmake/Fcitx5GClient/Fcitx5GClientTargets-%%CMAKE_BUILD_TYPE%%.cmake
 lib/cmake/Fcitx5GClient/Fcitx5GClientTargets.cmake
 lib/girepository-1.0/FcitxG-1.0.typelib
-lib/gtk-2.0/%%GTK2_VERSION%%/immodules/im-fcitx5.so
-lib/gtk-3.0/%%GTK3_VERSION%%/immodules/im-fcitx5.so
 lib/libFcitx5GClient.so
 lib/libFcitx5GClient.so.2
 lib/libFcitx5GClient.so.%%VER%%
 libdata/pkgconfig/Fcitx5GClient.pc
 share/gir-1.0/FcitxG-1.0.gir
-@postexec %%LOCALBASE%%/bin/gtk-query-immodules-3.0 --update-cache
-@postexec %%LOCALBASE%%/bin/gtk-query-immodules-2.0 --update-cache
-@postunexec %%LOCALBASE%%/bin/gtk-query-immodules-3.0 --update-cache
-@postunexec %%LOCALBASE%%/bin/gtk-query-immodules-2.0 --update-cache
diff --git a/textproc/fcitx5-gtk/pkg-plist.gtk2 b/textproc/fcitx5-gtk/pkg-plist.gtk2
new file mode 100644
index 000000000000..acaefd3e8eef
--- /dev/null
+++ b/textproc/fcitx5-gtk/pkg-plist.gtk2
@@ -0,0 +1,3 @@
+lib/gtk-2.0/%%GTK2_VERSION%%/immodules/im-fcitx5.so
+@postexec %%LOCALBASE%%/bin/gtk-query-immodules-2.0 --update-cache
+@postunexec %%LOCALBASE%%/bin/gtk-query-immodules-2.0 --update-cache
diff --git a/textproc/fcitx5-gtk/pkg-plist.gtk3 b/textproc/fcitx5-gtk/pkg-plist.gtk3
new file mode 100644
index 000000000000..8729fdc04a93
--- /dev/null
+++ b/textproc/fcitx5-gtk/pkg-plist.gtk3
@@ -0,0 +1,3 @@
+lib/gtk-3.0/%%GTK3_VERSION%%/immodules/im-fcitx5.so
+@postexec %%LOCALBASE%%/bin/gtk-query-immodules-3.0 --update-cache
+@postunexec %%LOCALBASE%%/bin/gtk-query-immodules-3.0 --update-cache
diff --git a/textproc/fcitx5-gtk/pkg-plist.gtk4 b/textproc/fcitx5-gtk/pkg-plist.gtk4
new file mode 100644
index 000000000000..8fad035ba08a
--- /dev/null
+++ b/textproc/fcitx5-gtk/pkg-plist.gtk4
@@ -0,0 +1 @@
+lib/gtk-4.0/%%GTK4_VERSION%%/immodules/libim-fcitx5.so