# Template file for 'fcitx5-gtk'
pkgname=fcitx5-gtk
version=5.0.21
revision=1
build_style=cmake
build_helper=gir
configure_args="$(vopt_bool gir ENABLE_GIR)"
hostmakedepends="cldr-emoji-annotation pkg-config gettext doxygen
 extra-cmake-modules glib-devel"
makedepends="libfcitx5-devel libglib-devel fmt-devel
 gtk+-devel gtk+3-devel gtk4-devel"
short_desc="Fcitx v5 - GTK common"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="LGPL-2.1-or-later"
homepage="https://fcitx-im.org/wiki/Fcitx"
distfiles="https://download.fcitx-im.org/fcitx5/fcitx5-gtk/fcitx5-gtk-${version}.tar.xz"
checksum=12375289971e5b95d358238f7737cc97d05a27874b33af7019e8599b924e2011
lib32disabled=yes

build_options="gir"
build_options_default="gir"

post_configure() {
	find build -name cmake_install.cmake -exec \
		sed -i -e 's,"//\+usr,"/usr,' {} +
}

post_install() {
	sed -i '/prefix=/!s,/usr,${exec_prefix},' \
		"${DESTDIR}/usr/lib/pkgconfig"/*.pc
	sed -i '/INTERFACE_INCLUDE_DIRECTORIES/s,/usr,${_IMPORT_PREFIX},g' \
		"${DESTDIR}/usr/lib/cmake"/*/*Targets.cmake
}

fcitx5-gtk+2_package() {
	short_desc="${short_desc% common}+2 IM Modules"
	lib32disabled=yes
	pkg_install() {
		vmove usr/lib/gtk-2.0
	}
}

fcitx5-gtk+3_package() {
	short_desc="${short_desc% common}+3 IM Modules"
	lib32disabled=yes
	pkg_install() {
		vmove usr/lib/gtk-3.0
	}
}

fcitx5-gtk4_package() {
	short_desc="${short_desc% common}4 IM Modules"
	lib32disabled=yes
	pkg_install() {
		vmove usr/lib/gtk-4.0
	}
}

fcitx5-gtk-devel_package() {
	short_desc="${short_desc%common}- development files"
	depends="fcitx5-gtk>=${version}_${revision} libglib-devel"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		if [ "$build_option_gir" ]; then
			vmove usr/share/gir-1.0
		fi
	}
}
