SUMMARY="C++ interface for GTK 3"
DESCRIPTION="gtkmm is the official C++ interface for the popular GUI library \
GTK. Highlights include typesafe callbacks, and a comprehensive set of widgets \
that are easily extensible via inheritance."
HOMEPAGE="https://www.gtkmm.org/en/"
COPYRIGHT="2021 The gtkmm Development Team"
LICENSE="GNU LGPL v2.1
	GNU GPL v2"
REVISION="2"
SOURCE_URI="http://ftp.gnome.org/pub/GNOME/sources/gtkmm/${portVersion%.*}/gtkmm-$portVersion.tar.xz"
CHECKSUM_SHA256="856333de86689f6a81c123f2db15d85db9addc438bc3574c36f15736aeae22e6"
SOURCE_DIR="gtkmm-$portVersion"

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

libVersion="1.1.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
apiVersion="3.0"

PROVIDES="
	gtkmm3$secondaryArchSuffix = $portVersion
	lib:libgtkmm_$apiVersion$secondaryArchSuffix = $libVersionCompat
	lib:libgdkmm_$apiVersion$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libatkmm_1.6$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libglibmm_2.4$secondaryArchSuffix
	lib:libgtk_3$secondaryArchSuffix
	lib:libgdk_pixbuf_2.0$secondaryArchSuffix
	lib:libcairomm_1.0$secondaryArchSuffix
	lib:libpangomm_1.4$secondaryArchSuffix
	lib:libsigc_2.0$secondaryArchSuffix
	"

PROVIDES_devel="
	gtkmm3${secondaryArchSuffix}_devel = $portVersion
	devel:libgtkmm_$apiVersion$secondaryArchSuffix = $libVersionCompat
	devel:libgdkmm_$apiVersion$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	gtkmm3$secondaryArchSuffix == $portVersion base
	devel:libatkmm_1.6$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libgtk_3$secondaryArchSuffix
	devel:libcairomm_1.0$secondaryArchSuffix
	devel:libpangomm_1.4$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libatkmm_1.6$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libgtk_3$secondaryArchSuffix
	devel:libcairomm_1.0$secondaryArchSuffix
	devel:libpangomm_1.4$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:meson
	cmd:ninja
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage gtkmm3$secondaryArchSuffix \
	"$libDir"/libgtkmm-$apiVersion.so.$libVersion

BUILD()
{
	meson build --buildtype=debugoptimized \
		--prefix=$prefix --includedir=$includeDir \
		--libdir=$libDir --datadir=$dataDir --bindir=$binDir \
		-Dmaintainer-mode=false -Dbuild-demos=false

	ninja $jobArgs -C build
}

INSTALL()
{
	ninja -C build install

	rm -rf $libDir/*.la

	mkdir -p $developLibDir
	mv $libDir/gtkmm-$apiVersion/include/*.h $includeDir/gtkmm-$apiVersion
	mv $libDir/gdkmm-$apiVersion/include/*.h $includeDir/gtkmm-$apiVersion
	mv $libDir/gtkmm-$apiVersion/ $developLibDir
	rm -rf $libDir/{gtkmm,gdkmm}-$apiVersion

	prepareInstalledDevelLibs \
		libgtkmm-$apiVersion

	fixPkgconfig

	sed -i -e 's|-I${libdir}/gtkmm-$apiVersion/include||' \
		$developLibDir/pkgconfig/gtkmm-$apiVersion.pc
	sed -i -e 's|-I${libdir}/gdkmm-$apiVersion/include||' \
		$developLibDir/pkgconfig/gdkmm-$apiVersion.pc

	packageEntries devel \
		$developDir
}
