SUMMARY="A multi-platform toolkit for creating graphical user interfaces"
DESCRIPTION="GTK is a multi-platform toolkit for creating graphical user \
interfaces. Offering a complete set of widgets, GTK is suitable for projects \
ranging from small one-off projects to complete application suites."
HOMEPAGE="https://www.gtk.org"
COPYRIGHT="GNOME Desktop"
LICENSE="GNU LGPL v2"
REVISION="6"
SOURCE_URI="https://ftp.gnome.org/pub/gnome/sources/gtk+/3.24/gtk+-$portVersion.tar.xz"
CHECKSUM_SHA256="ba75bfff320ad1f4cfbee92ba813ec336322cc3c660d406aad014b07087a3ba9"
SOURCE_DIR="gtk+-$portVersion"
PATCHES="gtk3-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	gtk3$secondaryArchSuffix = $portVersion compat >= 3
	cmd:gtk_builder_tool$secondaryArchSuffix
	cmd:gtk_encode_symbolic_svg$secondaryArchSuffix
	cmd:gtk_launch$secondaryArchSuffix
	cmd:gtk_query_immodules_3.0$secondaryArchSuffix
	cmd:gtk_query_settings$secondaryArchSuffix
	cmd:gtk_update_icon_cache$secondaryArchSuffix
	cmd:gtk3_demo_application$secondaryArchSuffix
	cmd:gtk3_demo$secondaryArchSuffix
	cmd:gtk3_icon_browser$secondaryArchSuffix
	cmd:gtk3_widget_factory$secondaryArchSuffix
	lib:libgailutil_3$secondaryArchSuffix
	lib:libgdk_3$secondaryArchSuffix = 3.2400.10 compat >= 1
	lib:libgtk_3$secondaryArchSuffix = 3.2400.10 compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	haiku_svg_icon_theme
	shared_mime_info$secondaryArchSuffix
	libepoxy${secondaryArchSuffix}
	pango$secondaryArchSuffix
	atk$secondaryArchSuffix
	gdk_pixbuf$secondaryArchSuffix
	xcairo$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libfribidi$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libharfbuzz$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libX11$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	gtk3${secondaryArchSuffix}_devel
	devel:libgtk_3$secondaryArchSuffix = 3.2400.10 compat >= 2
	devel:libgdk_3$secondaryArchSuffix = 3.2400.10 compat >= 2
	"
REQUIRES_devel="
	gtk3$secondaryArchSuffix == $portVersion base
	pango${secondaryArchSuffix}_devel
	atk${secondaryArchSuffix}_devel
	gdk_pixbuf${secondaryArchSuffix}_devel
	xcairo${secondaryArchSuffix}_devel
	devel:libglib_2.0$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libepoxy$secondaryArchSuffix
	devel:libX11$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	pango${secondaryArchSuffix}_devel
	atk${secondaryArchSuffix}_devel
	gdk_pixbuf${secondaryArchSuffix}_devel
	xcairo${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libepoxy$secondaryArchSuffix
	devel:libX11$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:which
	"

BUILD()
{
	runConfigure ./configure \
		--disable-gtk-doc --with-included-immodules=xim

	# build once, this will fail
	make -C testsuite clean
	make $jobArgs || true

	# patch disable some things in typefuncs.inc
	sed -i '/gdk_x11_device_manager_xi2_get_type/s@^@//@' gtk/gtktypefuncs.inc
	sed -i '/gdk_x11_device_xi2_get_type/s@^@//@' gtk/gtktypefuncs.inc
	sed -i '/gdk_x11_gl_context_get_type/s@^@//@' gtk/gtktypefuncs.inc

	# now build with the patched files
	make $jobArgs
}

INSTALL()
{

	make install

	rm $libDir/*.la

	fixPkgconfig
	prepareInstalledDevelLibs \
		libgdk-3 \
		libgtk-3

	packageEntries devel \
		$developDir
}
