# Template file for 'gnucash'
pkgname=gnucash
version=5.9
revision=2
build_style=cmake
make_check_target=check
configure_args="-DWITH_PYTHON=1 -DCOMPILE_GSCHEMAS=OFF"
hostmakedepends="pkg-config guile python3-setuptools libxslt perl gettext swig"
makedepends="aqbanking-devel icu-devel boost-devel gc-devel glib-devel gtest-devel guile-devel
 gwenhywfar-devel ktoblzcheck-devel libofx-devel libsecret-devel
 libxslt-devel libwebkit2gtk41-devel python3-devel gwenhywfar-gtk3 tzdata
 libdbi-devel libdbi-drivers-devel"
depends="dconf guile perl"
short_desc="Financial-accounting software"
maintainer="ManfredU <mu@usselmann.it>"
license="GPL-2.0-or-later"
homepage="http://www.gnucash.org"
changelog="https://raw.githubusercontent.com/Gnucash/gnucash/stable/NEWS"
distfiles="https://github.com/Gnucash/gnucash/releases/download/${version}/gnucash-${version}.tar.gz"
checksum=35375b2b1affe2a7e46becefb9e1205f432262c6ed0c7baa72f41b3b13f7235d

pycompile_dirs="usr/share/gnucash/python"
conf_files="/etc/gnucash/environment"
nocross="fails to compile guile code when cross-compiling"

CXXFLAGS="-Wno-error"
CFLAGS="-Wno-error"
export LC_ALL="C"

if [ "$XBPS_TARGET_ENDIAN" = "be" ]; then
	broken="Segmentation fault"
fi

post_install() {
	vdoc "${FILESDIR}/README.voidlinux"
	# startup fails in scheme code when the locale is set to anything else on musl
	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		vsed -i ${DESTDIR}/usr/share/applications/gnucash.desktop \
			-e 's/Exec=gnucash/Exec=env LANG=C gnucash/'
	fi
	# Delete the gnucash-valgrind executable because the source files
	# are not included with the package and the executable is hardlinked
	# to the location that it was built at.
	rm -f "${DESTDIR}/usr/bin/gnucash-valgrind"
}

gnucash-devel_package() {
	short_desc+=" - development files"
	depends="gnucash>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
	}
}
