# Template file for 'libime'
pkgname=libime
version=1.1.14
revision=1
build_style=cmake
build_helper=qemu
hostmakedepends="pkg-config gettext extra-cmake-modules python3"
makedepends="libfcitx5-devel boost-devel-minimal libboost_iostreams libzstd-devel"
short_desc="Library to support generic input method implementation"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="LGPL-2.1-or-later"
homepage="https://fcitx-im.org/wiki/Fcitx"
_lm_sc=lm_sc.arpa-20250113.tar.zst
_dict=dict-20250327.tar.zst
_table=table-20240108.tar.zst
distfiles="https://download.fcitx-im.org/fcitx5/libime/libime-${version}.tar.zst
 https://download.fcitx-im.org/data/${_lm_sc}
 https://download.fcitx-im.org/data/${_dict}
 https://download.fcitx-im.org/data/$_table"
checksum="d720088f8a687243116120fa9b3123e3a56a86c46f8e4cbe1f191cb5a2a0182a
 ee83ecf20d52e8bccdba4cf6cd57183d53c257713a5eb77ee3a63d50fc3796dd
 7ca6be4754c0d4c27ba7702c0dce651659bd2ca1faa5cbf2848d81a0053c8c13
 3e9d87b04a393f131723472c8eaa860dd23c378a3d4f6a9005513b2a95b3614b"
skip_extraction="
 ${_lm_sc}
 ${_dict}
 ${_table}"
CXXFLAGS="-D_LARGE_FILE_SOURCE=1 -D_FILE_OFFSET_BITS=64"

post_extract() {
	local _srcdistdir=${XBPS_SRCDISTDIR}/${pkgname}-${version}
	local _file
	for _file in ${skip_extraction}; do
		cp ${_srcdistdir}/${_file} data
	done
}

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

libime-migration_package() {
	short_desc+=" - migration tools"
	pkg_install() {
		vmove "usr/bin/libime_migrate_*"
	}
}

libime-utils_package() {
	short_desc+=" - utilities"
	pkg_install() {
		vmove usr/bin
	}
}

libime-devel_package() {
	short_desc+=" - development files"
	depends="boost-devel-minimal libboost_iostreams
	 libime-utils>=${version}_${revision}
	 libfcitx5-devel libime>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove "usr/lib/*.so"
	}
}
