# Template file for 'fcitx5'
pkgname=fcitx5
version=5.1.19
revision=1
build_style=cmake
build_helper=qemu
configure_args="
 -DCMAKE_INSTALL_LIBDATADIR=/usr/lib${XBPS_TARGET_WORDSIZE}
 -DISOCODES_ISO639_JSON=/usr/share/iso-codes/json/iso_639-3.json
 -DUSE_SYSTEMD=OFF"
hostmakedepends="cldr-emoji-annotation pkg-config gettext doxygen
 extra-cmake-modules xkeyboard-config wayland-devel iso-codes"
makedepends="fmt-devel expat-devel enchant2-devel libxkbfile-devel
 dbus-devel pango-devel glib-devel libevent-devel xcb-util-wm-devel
 json-c++
 xcb-util-keysyms-devel xcb-util-devel xcb-imdkit-devel libxkbcommon-devel
 wayland-devel wayland-protocols gdk-pixbuf-devel json-c-devel libuv-devel"
depends="iso-codes"
short_desc="Flexible Context-aware Input Tool with eXtension - v5"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="LGPL-2.1-or-later"
homepage="https://fcitx-im.org/wiki/Fcitx"
_en_dict_ver=20121020
distfiles="https://download.fcitx-im.org/fcitx5/fcitx5/fcitx5-${version}.tar.zst
 https://download.fcitx-im.org/data/en_dict-${_en_dict_ver}.tar.gz"
checksum="b93f5df7bfb73d67c30ce2d33d11fb89ba8c6b95c17059135f02728c95b11ab1
 c44a5d7847925eea9e4d2d04748d442cd28dd9299a0b572ef7d91eac4f5a6ceb"

replaces="fcitx5-icons>=0 fcitx-libpinyin>=0 fcitx-libpinyin-qt5>=0
 libfcitx>=0 fcitx>=0 fcitx-devel>=0"
provides="fcitx-libpinyin-5_1 fcitx-5_1 libfcitx-5_1"
skip_extraction=en_dict-${_en_dict_ver}.tar.gz
lib32disabled=yes
CXXFLAGS="-D_LARGE_FILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"

# Warning: do NOT enable backtrace for musl, do NOT add libexecinfo-devel

post_extract() {
	local _distdir=${XBPS_SRCDISTDIR}/${pkgname}-${version}
	cp ${_distdir}/en_dict-${_en_dict_ver}.tar.gz src/modules/spell/
}

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

libfcitx5_package() {
	short_desc+=" - libraries"
	lib32disabled=yes
	pkg_install() {
		vmove "usr/lib/*.so.*"
	}
}

libfcitx5-devel_package() {
	depends="libfcitx5>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		vmove usr/share/fcitx5/testing
		vmove "usr/lib/fcitx5/libtest*"
	}
}

fcitx_package() {
	metapackage=yes
	depends="${sourcepkg}"
	short_desc+=" - transition"
}
