diff mbox

[v4,1/3] libgtk3: new package

Message ID 1406856828-17350-2-git-send-email-hadrien.boutteville@gmail.com
State Superseded
Headers show

Commit Message

Hadrien Boutteville Aug. 1, 2014, 1:33 a.m. UTC
Signed-off-by: Hadrien Boutteville <hadrien.boutteville@gmail.com>
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
Changes v1 -> v2:
  - add a patch to remove atk-bridge support, so we no longer need
    at-spi2-core and at-spi2-atk.
  - change the way we check for introspection to fix autoreconf error
    (Eric)
  - remove unnecessary extra definitions

Changes v3 -> v4:
  - fix typo and formatting (Thomas)
  - add missing description + SoB in no-gtk-doc patch (Thomas)
---
 package/Config.in                                  |   1 +
 package/libgtk3/Config.in                          |  46 +++++++
 package/libgtk3/libgtk3-0001-no-gtk-doc.patch      |  25 ++++
 .../libgtk3-0002-fix-introspection-check.patch     |  28 +++++
 .../libgtk3/libgtk3-0003-disable-atk-bridge.patch  |  45 +++++++
 package/libgtk3/libgtk3.mk                         | 136 +++++++++++++++++++++
 6 files changed, 281 insertions(+)
 create mode 100644 package/libgtk3/Config.in
 create mode 100644 package/libgtk3/libgtk3-0001-no-gtk-doc.patch
 create mode 100644 package/libgtk3/libgtk3-0002-fix-introspection-check.patch
 create mode 100644 package/libgtk3/libgtk3-0003-disable-atk-bridge.patch
 create mode 100644 package/libgtk3/libgtk3.mk

Comments

Thomas Petazzoni Aug. 3, 2014, 9:35 a.m. UTC | #1
Hadrien,

On Fri,  1 Aug 2014 03:33:46 +0200, Hadrien Boutteville wrote:
> Signed-off-by: Hadrien Boutteville <hadrien.boutteville@gmail.com>
> Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>

Thanks. Unfortunately, it still does not build here:

Making all in gtk
  CCLD     extract-strings
  GEN      stamp-gtktypebuiltins.h
  GEN      stamp-gtkprivatetypebuiltins.h
  GEN      stamp-gtkmarshalers.h
  GEN      stamp-icons
  GEN      gtkdbusgenerated.c
  GEN      gtkdbusgenerated.h
/usr/bin/ld: skipping incompatible /home/test/outputs/gtk3/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libintl.so when searching for -lintl
/usr/bin/ld: skipping incompatible /home/test/outputs/gtk3/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libintl.a when searching for -lintl
/usr/bin/ld: cannot find -lintl
collect2: ld returned 1 exit status
make[4]: *** [extract-strings] Error 1
make[4]: *** Waiting for unfinished jobs....
/home/test/outputs/gtk3/host/usr/bin/glib-mkenums: gtktextview.h:59: Failed to parse `  /*< private >*/ '
/home/test/outputs/gtk3/host/usr/bin/glib-mkenums: gtktextview.h:61: Failed to parse `  /*< public >*/ '
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [/home/test/outputs/gtk3/build/libgtk3-3.12.2/.stamp_built] Error 2
make: *** [_all] Error 2

With the following configuration:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2014.05-rc1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_14=y
BR2_TOOLCHAIN_EXTERNAL_LARGEFILE=y
BR2_TOOLCHAIN_EXTERNAL_INET_IPV6=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_PACKAGE_XORG7=y
BR2_PACKAGE_LIBGTK3=y
BR2_PACKAGE_LIBGTK3_DEMO=y
BR2_PACKAGE_LIBGTK3_TESTS=y

Thomas
Thomas Petazzoni Aug. 3, 2014, 10:15 a.m. UTC | #2
Hello,

On Sun, 3 Aug 2014 11:35:35 +0200, Thomas Petazzoni wrote:

> Making all in gtk
>   CCLD     extract-strings
>   GEN      stamp-gtktypebuiltins.h
>   GEN      stamp-gtkprivatetypebuiltins.h
>   GEN      stamp-gtkmarshalers.h
>   GEN      stamp-icons
>   GEN      gtkdbusgenerated.c
>   GEN      gtkdbusgenerated.h
> /usr/bin/ld: skipping incompatible /home/test/outputs/gtk3/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libintl.so when searching for -lintl
> /usr/bin/ld: skipping incompatible /home/test/outputs/gtk3/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libintl.a when searching for -lintl
> /usr/bin/ld: cannot find -lintl
> collect2: ld returned 1 exit status
> make[4]: *** [extract-strings] Error 1
> make[4]: *** Waiting for unfinished jobs....
> /home/test/outputs/gtk3/host/usr/bin/glib-mkenums: gtktextview.h:59: Failed to parse `  /*< private >*/ '
> /home/test/outputs/gtk3/host/usr/bin/glib-mkenums: gtktextview.h:61: Failed to parse `  /*< public >*/ '
> make[3]: *** [all-recursive] Error 1
> make[2]: *** [all] Error 2
> make[1]: *** [/home/test/outputs/gtk3/build/libgtk3-3.12.2/.stamp_built] Error 2
> make: *** [_all] Error 2

I've done a little bit more investigation. The problem comes from the
fact that the extract-strings program is built for the host, but using
target cflags/ldflags. The gtk3 configure.ac script has provisions to
specify a PKG_CONFIG_FOR_BUILD, but in the case of Buildroot, our
PKG_CONFIG_FOR_BUILD is just $(HOST_DIR)/usr/bin/pkg-config, but with
several environment variables to adjust its behavior (because by
default, $(HOST_DIR)/usr/bin/pkg-config is cross and returns values for
target libraries).

So, I tried something like:

LIBGTK3_CONF_ENV += \
	ac_cv_path_PKG_CONFIG_FOR_BUILD='$(HOST_CONFIGURE_OPTS) $(HOST_PKG_CONFIG_BINARY)'

but it didn't work as the autoconf code does not expect the command to
have multiple, space-separated, tokens.

I've already tried to override GLIB_CFLAGS_FOR_BUILD and
GLIB_LIBS_FOR_BUILD with no luck.

So, right now, I am wondering if we should provide a
$(HOST_DIR)/usr/bin/host-pkg-config that has built-in all the necessary
environment variables to return values appropriate for host libraries.

Any other suggestion?

Best regards,

Thomas
Eric Le Bihan Aug. 3, 2014, 10:22 p.m. UTC | #3
Hi All!
On Sun, Aug 03, 2014 at 12:15:47PM +0200, Thomas Petazzoni wrote:
> Hello,
>
> On Sun, 3 Aug 2014 11:35:35 +0200, Thomas Petazzoni wrote:
>
> > Making all in gtk
> >   CCLD     extract-strings
> >   GEN      stamp-gtktypebuiltins.h
> >   GEN      stamp-gtkprivatetypebuiltins.h
> >   GEN      stamp-gtkmarshalers.h
> >   GEN      stamp-icons
> >   GEN      gtkdbusgenerated.c
> >   GEN      gtkdbusgenerated.h
> > /usr/bin/ld: skipping incompatible /home/test/outputs/gtk3/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libintl.so when searching for -lintl
> > /usr/bin/ld: skipping incompatible /home/test/outputs/gtk3/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libintl.a when searching for -lintl
> > /usr/bin/ld: cannot find -lintl
> > collect2: ld returned 1 exit status
> > make[4]: *** [extract-strings] Error 1
> > make[4]: *** Waiting for unfinished jobs....
> > /home/test/outputs/gtk3/host/usr/bin/glib-mkenums: gtktextview.h:59: Failed to parse `  /*< private >*/ '
> > /home/test/outputs/gtk3/host/usr/bin/glib-mkenums: gtktextview.h:61: Failed to parse `  /*< public >*/ '
> > make[3]: *** [all-recursive] Error 1
> > make[2]: *** [all] Error 2
> > make[1]: *** [/home/test/outputs/gtk3/build/libgtk3-3.12.2/.stamp_built] Error 2
> > make: *** [_all] Error 2
>
> I've done a little bit more investigation. The problem comes from the
> fact that the extract-strings program is built for the host, but using
> target cflags/ldflags. The gtk3 configure.ac script has provisions to
> specify a PKG_CONFIG_FOR_BUILD, but in the case of Buildroot, our
> PKG_CONFIG_FOR_BUILD is just $(HOST_DIR)/usr/bin/pkg-config, but with
> several environment variables to adjust its behavior (because by
> default, $(HOST_DIR)/usr/bin/pkg-config is cross and returns values for
> target libraries).
>
> So, I tried something like:
>
> LIBGTK3_CONF_ENV += \
> 	ac_cv_path_PKG_CONFIG_FOR_BUILD='$(HOST_CONFIGURE_OPTS) $(HOST_PKG_CONFIG_BINARY)'
>
> but it didn't work as the autoconf code does not expect the command to
> have multiple, space-separated, tokens.
>
> I've already tried to override GLIB_CFLAGS_FOR_BUILD and
> GLIB_LIBS_FOR_BUILD with no luck.
>
> So, right now, I am wondering if we should provide a
> $(HOST_DIR)/usr/bin/host-pkg-config that has built-in all the necessary
> environment variables to return values appropriate for host libraries.
>
That's the solution I had chosen in my version [1]:

+HOST_LIBGTK3_DEPENDENCIES = host-libglib2 host-libpng host-gdk-pixbuf
+HOST_LIBGTK3_CFLAGS = $(shell $(HOST_DIR)/usr/bin/pkg-config-native \
+ --cflags --libs gdk-pixbuf-2.0)
+
+define HOST_LIBGTK3_INSTALL_PKG_CONFIG_NATIVE
+ $(RM) -f $(HOST_DIR)/usr/bin/pkg-config-native
+ echo -e '#!/bin/sh\n' \
+
'PKG_CONFIG_LIBDIR=$(HOST_DIR)/usr/lib/pkgconfig:$(HOST_DIR)/usr/share/pkgconfig
' \
+ '$(HOST_DIR)/usr/bin/pkgconf $$@' >> $(HOST_DIR)/usr/bin/pkg-config-native
+ chmod +x $(HOST_DIR)/usr/bin/pkg-config-native
+endef
+
+HOST_LIBGTK3_PRE_CONFIGURE_HOOKS += HOST_LIBGTK3_INSTALL_PKG_CONFIG_NATIVE

This hook could easily be moved to package/pkgconf/pkgconf.mk and added to
HOST_PKGCONF_POST_INSTALL_HOOKS. If "host-pkg-config" is preferred over
"pkg-config-native", I can provide a patch using this name.

Best regards,

ELB

[1] https://github.com/elebihan/buildroot/commit/54a0ad6a18481e2db24c6f8f1d0b130b2a830b18
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index 8e1c391..853851f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -610,6 +610,7 @@  menu "Graphics"
 	source "package/libgeotiff/Config.in"
 	source "package/libglade/Config.in"
 	source "package/libgtk2/Config.in"
+	source "package/libgtk3/Config.in"
 	source "package/libpng/Config.in"
 	source "package/libqrencode/Config.in"
 	source "package/libraw/Config.in"
diff --git a/package/libgtk3/Config.in b/package/libgtk3/Config.in
new file mode 100644
index 0000000..47b1ac1
--- /dev/null
+++ b/package/libgtk3/Config.in
@@ -0,0 +1,46 @@ 
+config BR2_PACKAGE_LIBGTK3
+	bool "libgtk3"
+	select BR2_PACKAGE_ATK
+	select BR2_PACKAGE_CAIRO
+	select BR2_PACKAGE_CAIRO_PS
+	select BR2_PACKAGE_CAIRO_PDF
+	select BR2_PACKAGE_CAIRO_SVG
+	select BR2_PACKAGE_LIBGLIB2
+	select BR2_PACKAGE_PANGO
+	select BR2_PACKAGE_GDK_PIXBUF
+	select BR2_PACKAGE_FONTCONFIG
+	select BR2_PACKAGE_XLIB_LIBX11
+	select BR2_PACKAGE_XLIB_LIBXEXT
+	select BR2_PACKAGE_XLIB_LIBXRENDER
+	select BR2_PACKAGE_XLIB_LIBXI # required for building X11 backend
+	depends on BR2_PACKAGE_XORG7
+	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
+	help
+	  The GTK+ version 3 graphical user interface library
+
+	  http://www.gtk.org/
+
+if BR2_PACKAGE_LIBGTK3
+
+config BR2_PACKAGE_LIBGTK3_DEMO
+	bool "Install libgtk3 demo program"
+	help
+	  The GTK+ source base contains demo programs. This
+	  option allows to install this program to the target.
+
+config BR2_PACKAGE_LIBGTK3_TESTS
+	bool "Install libgtk3 tests"
+	help
+	  The GTK+ source base contains tests. This option
+	  allows to install them to the target.
+
+endif
+
+comment "libgtk3 needs a toolchain w/ wchar, threads, C++"
+	depends on BR2_USE_MMU
+	depends on BR2_PACKAGE_XORG7
+	depends on !BR2_USE_WCHAR || !BR2_INSTALL_LIBSTDCPP || \
+		!BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/libgtk3/libgtk3-0001-no-gtk-doc.patch b/package/libgtk3/libgtk3-0001-no-gtk-doc.patch
new file mode 100644
index 0000000..926a263
--- /dev/null
+++ b/package/libgtk3/libgtk3-0001-no-gtk-doc.patch
@@ -0,0 +1,25 @@ 
+Same patch as for systemd in commit
+7144f2f04b705538a893e538a6b851f536f433b6:
+
+Fix deactivation of gtk-doc
+
+The tarball contains the Makefile for building documentation with gtk-doc,
+Unfortunately the AM_CONDITIONAL variable is not the correct one, which
+results in an error when running autoreconf.
+
+This patch fixes this issue.
+
+Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
+Signed-off-by: Hadrien Boutteville <hadrien.boutteville@gmail.com>
+
+--- a/gtk-doc.make
++++ b/gtk-doc.make
+@@ -267,7 +267,7 @@
+ #
+ # Require gtk-doc when making dist
+ #
+-if HAVE_GTK_DOC
++if ENABLE_GTK_DOC
+ dist-check-gtkdoc: docs
+ else
+ dist-check-gtkdoc:
diff --git a/package/libgtk3/libgtk3-0002-fix-introspection-check.patch b/package/libgtk3/libgtk3-0002-fix-introspection-check.patch
new file mode 100644
index 0000000..5b56b3a
--- /dev/null
+++ b/package/libgtk3/libgtk3-0002-fix-introspection-check.patch
@@ -0,0 +1,28 @@ 
+Fix HAVE_INTROSPECTION does not appear in AM_CONDITIONAL
+
+During autoreconf GOBJECT_INTROSPECTION_CHECK could not be resolve because we
+don't have introspection which provides its custom m4 macro. Reconfigure fails
+with:
+
+gdk/Makefile.am:196: error: HAVE_INTROSPECTION does not appear in AM_CONDITIONAL
+gtk/Makefile.am:1347: error: HAVE_INTROSPECTION does not appear in AM_CONDITIONAL
+
+We avoid to add a copy of introspection.m4 in the m4 directory of libgtk3 by
+adding a check, as performed in Systemd.
+
+Signed-off-by: Hadrien Boutteville <hadrien.boutteville@gmail.com>
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -1621,7 +1621,10 @@
+ # GObject introspection
+ ##################################################
+ 
+-GOBJECT_INTROSPECTION_CHECK(introspection_required_version)
++m4_ifdef([GOBJECT_INTROSPECTION_CHECK],
++         [GOBJECT_INTROSPECTION_CHECK(introspection_required_version)],
++         [AM_CONDITIONAL([HAVE_INTROSPECTION], [false])
++          enable_introspection=no])
+ 
+ ##################################################
+ # colord module
diff --git a/package/libgtk3/libgtk3-0003-disable-atk-bridge.patch b/package/libgtk3/libgtk3-0003-disable-atk-bridge.patch
new file mode 100644
index 0000000..30ff92d
--- /dev/null
+++ b/package/libgtk3/libgtk3-0003-disable-atk-bridge.patch
@@ -0,0 +1,45 @@ 
+Remove atk-bridge support.
+
+atk-bridge doesn't seem useful for now in Buildroot and requires to
+add two new packages just for it: at-spi2-core and at-spi2-atk.
+
+Signed-off-by: Hadrien Boutteville <hadrien.boutteville@gmail.com>
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -1349,11 +1349,7 @@
+ # Check for Accessibility Toolkit flags
+ ########################################
+ 
+-if test x$enable_x11_backend = xyes; then
+-   ATK_PACKAGES="atk atk-bridge-2.0"
+-else
+-   ATK_PACKAGES="atk"
+-fi
++ATK_PACKAGES="atk"
+ 
+ PKG_CHECK_MODULES(ATK, $ATK_PACKAGES)
+ 
+--- a/gtk/a11y/gtkaccessibility.c
++++ b/gtk/a11y/gtkaccessibility.c
+@@ -37,10 +37,6 @@
+ #include <gtk/gtkcombobox.h>
+ #include <gtk/gtkaccessible.h>
+ 
+-#ifdef GDK_WINDOWING_X11
+-#include <atk-bridge.h>
+-#endif
+-
+ static gboolean gail_focus_watcher      (GSignalInvocationHint *ihint,
+                                          guint                  n_param_values,
+                                          const GValue          *param_values,
+@@ -987,9 +983,5 @@
+   _gtk_accessibility_override_atk_util ();
+   do_window_event_initialization ();
+ 
+-#ifdef GDK_WINDOWING_X11
+-  atk_bridge_adaptor_init (NULL, NULL);
+-#endif
+-
+   atk_misc_instance = g_object_new (GTK_TYPE_MISC_IMPL, NULL);
+ }
diff --git a/package/libgtk3/libgtk3.mk b/package/libgtk3/libgtk3.mk
new file mode 100644
index 0000000..62aacd5
--- /dev/null
+++ b/package/libgtk3/libgtk3.mk
@@ -0,0 +1,136 @@ 
+################################################################################
+#
+# libgtk3
+#
+################################################################################
+
+LIBGTK3_VERSION_MAJOR = 3.12
+LIBGTK3_VERSION = $(LIBGTK3_VERSION_MAJOR).2
+LIBGTK3_SOURCE = gtk+-$(LIBGTK3_VERSION).tar.xz
+LIBGTK3_SITE = http://ftp.gnome.org/pub/gnome/sources/gtk+/$(LIBGTK3_VERSION_MAJOR)
+LIBGTK3_LICENSE = LGPLv2+
+LIBGTK3_LICENSE_FILES = COPYING
+LIBGTK3_INSTALL_STAGING = YES
+LIBGTK3_AUTORECONF = YES
+
+LIBGTK3_CONF_ENV = \
+	ac_cv_path_GTK_UPDATE_ICON_CACHE=$(HOST_DIR)/usr/bin/gtk-update-icon-cache \
+	ac_cv_path_GDK_PIXBUF_CSOURCE=$(HOST_DIR)/usr/bin/gdk-pixbuf-csource
+
+LIBGTK3_CONF_OPT = --disable-glibtest \
+	--enable-explicit-deps=no \
+	--enable-gtk2-dependency \
+	--disable-debug \
+	--disable-introspection
+
+LIBGTK3_DEPENDENCIES = host-pkgconf host-libgtk3 libglib2 cairo pango atk \
+	gdk-pixbuf
+
+# Xorg dependencies
+LIBGTK3_CONF_OPT += --with-x \
+	--enable-x11-backend \
+	--x-includes=$(STAGING_DIR)/usr/include/X11 \
+	--x-libraries=$(STAGING_DIR)/usr/lib
+LIBGTK3_DEPENDENCIES += fontconfig xlib_libX11 xlib_libXext xlib_libXrender \
+		xlib_libXi
+
+ifeq ($(BR2_PACKAGE_XLIB_LIBXINERAMA),y)
+LIBGTK3_CONF_OPT += --enable-xinerama
+LIBGTK3_DEPENDENCIES += xlib_libXinerama
+else
+LIBGTK3_CONF_OPT += --disable-xinerama
+endif
+
+ifeq ($(BR2_PACKAGE_XLIB_LIBXRANDR),y)
+LIBGTK3_CONF_OPT += --enable-xrandr
+LIBGTK3_DEPENDENCIES += xlib_libXrandr
+else
+LIBGTK3_CONF_OPT += --disable-xrandr
+endif
+
+ifeq ($(BR2_PACKAGE_XLIB_LIBXCURSOR),y)
+LIBGTK3_DEPENDENCIES += xlib_libXcursor
+endif
+
+ifeq ($(BR2_PACKAGE_XLIB_LIBXFIXES),y)
+LIBGTK3_CONF_OPT += --enable-xfixes
+LIBGTK3_DEPENDENCIES += xlib_libXfixes
+else
+LIBGTK3_CONF_OPT += --disable-xfixes
+endif
+
+ifeq ($(BR2_PACKAGE_XLIB_LIBXCOMPOSITE),y)
+LIBGTK3_CONF_OPT += --enable-xcomposite
+LIBGTK3_DEPENDENCIES += xlib_libXcomposite
+else
+LIBGTK3_CONF_OPT += --disable-xcomposite
+endif
+
+ifeq ($(BR2_PACKAGE_XLIB_LIBXDAMAGE),y)
+LIBGTK3_CONF_OPT += --enable-xdamage
+LIBGTK3_DEPENDENCIES += xlib_libXdamage
+else
+LIBGTK3_CONF_OPT += --disable-xdamage
+endif
+
+ifeq ($(BR2_PACKAGE_XLIB_LIBXKBFILE),y)
+LIBGTK3_CONF_OPT += --enable-xkb
+LIBGTK3_DEPENDENCIES += xlib_libxkbfile
+else
+LIBGTK3_CONF_OPT += --disable-xkb
+endif
+
+ifeq ($(BR2_PACKAGE_CUPS),y)
+LIBGTK3_CONF_OPT += --enable-cups
+LIBGTK3_DEPENDENCIES += cups
+else
+LIBGTK3_CONF_OPT += --disable-cups
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK3_DEMO),)
+define LIBGTK3_POST_INSTALL_TWEAKS
+	rm -rf $(TARGET_DIR)/usr/bin/gtk3-demo \
+		$(TARGET_DIR)/usr/bin/gtk3-demo-application
+endef
+
+LIBGTK3_POST_INSTALL_TARGET_HOOKS += LIBGTK3_POST_INSTALL_TWEAKS
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK3_TESTS),y)
+LIBGTK3_CONF_OPT += --enable-installed-tests
+else
+LIBGTK3_CONF_OPT += --disable-installed-tests
+endif
+
+# We do not build a full version of libgtk3 for the host, because that
+# requires compiling Cairo, Pango, ATK and X.org for the host.
+# Therefore, we hack the build to only build gdk-pixbuf-from-source and
+# gtk-update-icon-cache, which are the host tools needed to build Gtk
+# for the target.
+
+HOST_LIBGTK3_DEPENDENCIES = host-libglib2 host-libpng host-gdk-pixbuf
+
+HOST_LIBGTK3_CFLAGS = \
+	$(shell $(HOST_CONFIGURE_OPTS) $(PKG_CONFIG_HOST_BINARY) \
+		--cflags --libs gdk-pixbuf-2.0)
+
+define HOST_LIBGTK3_CONFIGURE_CMDS
+	echo "#define GETTEXT_PACKAGE \"gtk30\"" >> $(@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_LIBGTK3_BUILD_CMDS
+	$(HOSTCC) $(HOST_CFLAGS) $(HOST_LDFLAGS) \
+		$(@D)/gtk/updateiconcache.c \
+		$(HOST_LIBGTK3_CFLAGS) \
+		-o $(@D)/gtk/gtk-update-icon-cache
+endef
+
+define HOST_LIBGTK3_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/gtk/gtk-update-icon-cache \
+		$(HOST_DIR)/usr/bin/gtk-update-icon-cache
+endef
+
+$(eval $(autotools-package))
+$(eval $(host-autotools-package))