diff mbox series

[2/2] package/libgtk4: new package

Message ID 20230318193159.1418922-2-francois.perrad@gadz.org
State New
Headers show
Series [1/2] package/graphene: new package | expand

Commit Message

Francois Perrad March 18, 2023, 7:31 p.m. UTC
Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 DEVELOPERS                   |   1 +
 package/Config.in            |   1 +
 package/libgtk4/Config.in    | 106 +++++++++++++++++++++++++++++++++
 package/libgtk4/libgtk4.hash |   5 ++
 package/libgtk4/libgtk4.mk   | 110 +++++++++++++++++++++++++++++++++++
 5 files changed, 223 insertions(+)
 create mode 100644 package/libgtk4/Config.in
 create mode 100644 package/libgtk4/libgtk4.hash
 create mode 100644 package/libgtk4/libgtk4.mk
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 5000d7230..61e6e281c 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1059,6 +1059,7 @@  F:	package/dado/
 F:	package/ficl/
 F:	package/graphene/
 F:	package/janet/
+F:	package/libgtk4/
 F:	package/libtomcrypt/
 F:	package/libtommath/
 F:	package/libwpe/
diff --git a/package/Config.in b/package/Config.in
index 272ea7f4a..9eff213c0 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1612,6 +1612,7 @@  menu "Graphics"
 	source "package/libgta/Config.in"
 	source "package/libgtk2/Config.in"
 	source "package/libgtk3/Config.in"
+	source "package/libgtk4/Config.in"
 	source "package/libjxl/Config.in"
 	source "package/libmediaart/Config.in"
 	source "package/libmng/Config.in"
diff --git a/package/libgtk4/Config.in b/package/libgtk4/Config.in
new file mode 100644
index 000000000..cda183c8d
--- /dev/null
+++ b/package/libgtk4/Config.in
@@ -0,0 +1,106 @@ 
+comment "libgtk4 needs a toolchain w/ wchar, threads, C++, gcc >= 4.9"
+	depends on BR2_USE_MMU
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on !BR2_USE_WCHAR || !BR2_INSTALL_LIBSTDCPP || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
+		!BR2_TOOLCHAIN_HAS_THREADS
+
+comment "libgtk4 needs an OpenGL or an OpenGL-EGL/wayland backend"
+	depends on BR2_USE_MMU
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4
+	depends on !BR2_PACKAGE_HAS_LIBEGL_WAYLAND && !BR2_PACKAGE_HAS_LIBGL
+
+config BR2_PACKAGE_LIBGTK4
+	bool "libgtk4"
+	depends on BR2_USE_WCHAR # glib2
+	depends on BR2_TOOLCHAIN_HAS_THREADS # glib2
+	depends on BR2_USE_MMU # glib2
+	depends on BR2_INSTALL_LIBSTDCPP # pango
+	depends on BR2_TOOLCHAIN_HAS_SYNC_4 # pango -> harfbuzz
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # pango -> harfbuzz
+	depends on BR2_PACKAGE_HAS_LIBEGL_WAYLAND || BR2_PACKAGE_HAS_LIBGL
+	select BR2_PACKAGE_CAIRO
+	select BR2_PACKAGE_CAIRO_PS
+	select BR2_PACKAGE_CAIRO_PDF
+	select BR2_PACKAGE_CAIRO_SVG
+	select BR2_PACKAGE_GDK_PIXBUF
+	select BR2_PACKAGE_GRAPHENE
+	select BR2_PACKAGE_LIBEPOXY
+	select BR2_PACKAGE_LIBGLIB2
+	select BR2_PACKAGE_PANGO
+	select BR2_PACKAGE_TIFF
+	# At least one backend is required
+	select BR2_PACKAGE_LIBGTK4_BROADWAY if \
+		!(BR2_PACKAGE_LIBGTK4_X11 || BR2_PACKAGE_LIBGTK4_WAYLAND)
+	help
+	  The GTK version 4 graphical user interface library
+
+	  https://www.gtk.org/
+
+if BR2_PACKAGE_LIBGTK4
+
+config BR2_PACKAGE_LIBGTK4_BROADWAY
+	bool "Broadway GDK backend"
+	default y
+	  help
+	  This enables the Broadway backend for GDK, which provides
+	  support for displaying GTK+ applications in a web browser,
+	  using HTML5 and web sockets.
+
+	  For example, to run gtk4-demo on a target which IP address is
+	  192.168.0.1 and use it from a web browser, execute the
+	  following commands:
+
+	  $ broadwayd -a 192.168.0.1 -p 8080 :2 &
+	  $ export GDK_BACKEND=broadway
+	  $ export BROADWAY_DISPLAY=:2
+	  $ gtk4-demo
+
+	  Then open a web browser at address http://192.168.0.1:8080.
+	  Javascript and web sockets should be enabled.
+
+comment "Wayland GDK backend needs an OpenGL EGL backend provided by mesa3d w/ headers >= 3.17"
+	depends on !BR2_PACKAGE_MESA3D_OPENGL_EGL || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
+
+config BR2_PACKAGE_LIBGTK4_WAYLAND
+	bool "Wayland GDK backend"
+	default y
+	depends on BR2_PACKAGE_HAS_LIBEGL_WAYLAND
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17
+	select BR2_PACKAGE_WAYLAND
+	select BR2_PACKAGE_LIBXKBCOMMON
+	help
+	  This enables the Wayland backend for GDK.
+
+comment "X11 GDK backend needs an OpenGL provider"
+	depends on !BR2_PACKAGE_HAS_LIBGL
+
+config BR2_PACKAGE_LIBGTK4_X11
+	bool "X11 GDK backend"
+	default y
+	depends on BR2_PACKAGE_XORG7
+	depends on BR2_PACKAGE_HAS_LIBGL
+	select BR2_PACKAGE_XLIB_LIBXCURSOR
+	select BR2_PACKAGE_XLIB_LIBXI
+	select BR2_PACKAGE_XLIB_LIBXINERAMA
+	help
+	  This enables the X11 backend for GDK.
+
+config BR2_PACKAGE_LIBGTK4_GSTREAMER
+	bool "gstreamer support"
+	select BR2_PACKAGE_GSTREAMER1
+	select BR2_PACKAGE_GST1_PLUGINS_BASE
+	select BR2_PACKAGE_GST1_PLUGINS_BASE_LIB_OPENGL
+	select BR2_PACKAGE_GST1_PLUGINS_BAD
+	help
+	  Enable gstreamer support.
+
+config BR2_PACKAGE_LIBGTK4_DEMO
+	bool "Install libgtk4 demo/example programs"
+	select BR2_PACKAGE_SHARED_MIME_INFO
+	select BR2_PACKAGE_HICOLOR_ICON_THEME
+	help
+	  The GTK source base contains demo/exmaple programs.
+	  This option allows to install them to the target.
+
+endif
diff --git a/package/libgtk4/libgtk4.hash b/package/libgtk4/libgtk4.hash
new file mode 100644
index 000000000..8edafb3ca
--- /dev/null
+++ b/package/libgtk4/libgtk4.hash
@@ -0,0 +1,5 @@ 
+# From https://download.gnome.org/sources/gtk/4.10/gtk-4.10.1.sha256sum
+sha256  e8fcac04bc7715b9da667c911a5ee8f262e200d1d6a50adf23645ca8cfcd0311  gtk-4.10.1.tar.xz
+
+# Hash for license file:
+sha256  b7993225104d90ddd8024fd838faf300bea5e83d91203eab98e29512acebd69c  COPYING
diff --git a/package/libgtk4/libgtk4.mk b/package/libgtk4/libgtk4.mk
new file mode 100644
index 000000000..8f3d13046
--- /dev/null
+++ b/package/libgtk4/libgtk4.mk
@@ -0,0 +1,110 @@ 
+################################################################################
+#
+# libgtk4
+#
+################################################################################
+
+LIBGTK4_VERSION_MAJOR = 4.10
+LIBGTK4_VERSION = $(LIBGTK4_VERSION_MAJOR).1
+LIBGTK4_SOURCE = gtk-$(LIBGTK4_VERSION).tar.xz
+LIBGTK4_SITE = https://download.gnome.org/sources/gtk/$(LIBGTK4_VERSION_MAJOR)
+LIBGTK4_LICENSE = LGPL-2.0+
+LIBGTK4_LICENSE_FILES = COPYING
+LIBGTK4_CPE_ID_VENDOR = gnome
+LIBGTK4_CPE_ID_PRODUCT = gtk
+LIBGTK4_INSTALL_STAGING = YES
+
+LIBGTK4_DEPENDENCIES = host-pkgconf host-libgtk4 \
+	gdk-pixbuf graphene libepoxy libglib2 pango \
+	$(TARGET_NLS_DEPENDENCIES)
+
+LIBGTK4_CONF_OPTS = -Dbuild-tests=false
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_X11),y)
+LIBGTK4_DEPENDENCIES += xlib_libXcursor xlib_libXi xlib_libXinerama
+LIBGTK4_CONF_OPTS += -Dx11-backend=true
+else
+LIBGTK4_CONF_OPTS += -Dx11-backend=false
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_WAYLAND),y)
+LIBGTK4_DEPENDENCIES += wayland libxkbcommon
+LIBGTK4_CONF_OPTS += -Dwayland-backend=true
+else
+LIBGTK4_CONF_OPTS += -Dwayland-backend=false
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_BROADWAY),y)
+LIBGTK4_CONF_OPTS += -Dbroadway-backend=true
+else
+LIBGTK4_CONF_OPTS += -Dbroadway-backend=false
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_GSTREAMER),y)
+LIBGTK4_CONF_OPTS += -Dmedia-gstreamer=enabled
+LIBGTK4_DEPENDENCIES += gstreamer1 gst1-plugins-base gst1-plugins-bad
+else
+LIBGTK4_CONF_OPTS += -Dmedia-gstreamer=disabled
+endif
+
+ifeq ($(BR2_PACKAGE_CUPS),y)
+LIBGTK4_CONF_OPTS += -Dprint-cups=enabled
+LIBGTK4_DEPENDENCIES += cups
+else
+LIBGTK4_CONF_OPTS += -Dprint-cups=disabled
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK4_DEMO),y)
+LIBGTK4_CONF_OPTS += -Ddemos=true -Dbuild-examples=true
+LIBGTK4_DEPENDENCIES += hicolor-icon-theme shared-mime-info
+else
+LIBGTK4_CONF_OPTS += -Ddemos=false -Dbuild-examples=false
+endif
+
+define LIBGTK4_COMPILE_GLIB_SCHEMAS
+	$(HOST_DIR)/bin/glib-compile-schemas \
+		$(TARGET_DIR)/usr/share/glib-2.0/schemas
+endef
+LIBGTK4_POST_INSTALL_TARGET_HOOKS += LIBGTK4_COMPILE_GLIB_SCHEMAS
+
+# here, we build a native gtk4-update-icon-cache as host-libgtk4
+
+HOST_LIBGTK4_DEPENDENCIES = \
+	host-gdk-pixbuf \
+	host-libglib2 \
+	host-pkgconf
+
+HOST_LIBGTK4_CFLAGS = \
+	-I $(@D)/gtk \
+	`$(HOST_MAKE_ENV) $(PKG_CONFIG_HOST_BINARY) --cflags --libs gdk-pixbuf-2.0`
+
+define HOST_LIBGTK4_CONFIGURE_CMDS
+	echo "#define GETTEXT_PACKAGE \"gtk40\"" >> $(@D)/gtk/config.h
+	echo "#define GTK_LOCALEDIR \"/usr/share/locale\"" >> $(@D)/gtk/config.h
+	echo "#define HAVE_UNISTD_H 1" >> $(@D)/gtk/config.h
+	echo "#define HAVE_FTW_H 1" >> $(@D)/gtk/config.h
+endef
+
+define HOST_LIBGTK4_BUILD_CMDS
+	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
+		$(@D)/tools/updateiconcache.c $(@D)/gtk/gtkiconcachevalidator.c\
+		$(HOST_LIBGTK4_CFLAGS) \
+		-o $(@D)/tools/gtk4-update-icon-cache
+endef
+
+define HOST_LIBGTK4_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/tools/gtk4-update-icon-cache \
+		$(HOST_DIR)/bin/gtk4-update-icon-cache
+endef
+
+# Create icon-theme.cache for each of the icon directories/themes
+# It's not strictly necessary but speeds up lookups
+define LIBGTK4_UPDATE_ICON_CACHE
+	[ ! -d $(TARGET_DIR)/usr/share/icons ] || \
+		find $(TARGET_DIR)/usr/share/icons -maxdepth 1 -mindepth 1 -type d \
+			-exec $(HOST_DIR)/bin/gtk-update-icon-cache {} \;
+endef
+LIBGTK4_TARGET_FINALIZE_HOOKS += LIBGTK4_UPDATE_ICON_CACHE
+
+$(eval $(meson-package))
+$(eval $(host-generic-package))