# Template file for 'biblioteq'
pkgname=biblioteq
version=2026.06.07
revision=1
build_style=qmake
build_helper=qmake6
hostmakedepends="qt6-tools qt6-base"
makedepends="libpqxx-devel qt6-base-devel poppler-cpp-devel poppler-qt6-devel
 sqlite-devel yaz-devel"
depends="qt6-plugin-sqlite"
short_desc="Professional cataloging and library management suite"
maintainer="Rutpiv <roger_freitas@live.com>"
license="BSD-3-Clause"
homepage="https://textbrowser.github.io/biblioteq/"
distfiles="https://github.com/textbrowser/biblioteq/archive/${version}.tar.gz"
checksum=073e19dea154e1440a0bd93c35f8b8e7903187d83a7fd03944da17335e1f6012
conf_files="/etc/biblioteq.conf"

# Set the appropriate build helper and dependencies based on architecture
case "$XBPS_TARGET_MACHINE" in
	ppc*) configure_file="biblioteq.powerpc.pro" ;;
	*)    configure_file="biblioteq.pro" ;;
esac

pre_configure() {
	configure_args="-o Makefile ${configure_file}"

	# Set paths for cross-compiling without export
	if [ "$CROSS_BUILD" ]; then
		vsed -i biblioteq-source.pro -e "s|/usr/include|${XBPS_CROSS_BASE}/usr/include|g"
	fi
}

post_build() {
	# Fix the program .desktop file.
	vsed -i Distributions/biblioteq.desktop \
		-e "s|Exec=/opt/biblioteq/biblioteq.sh|Exec=biblioteq|" \
		-e "s|Icon=/opt/biblioteq/book.png|Icon=biblioteq.png|"
}

do_install() {
	# Translations must be in the same directory as BiblioteQ (executable)
	vinstall BiblioteQ 755 usr/lib/BiblioteQ
	vcopy Translations usr/lib/BiblioteQ

	vinstall Icons/book.png 644 /usr/share/pixmaps/ biblioteq.png
	vinstall Distributions/biblioteq.desktop 644 /usr/share/applications/
	vconf biblioteq.conf
	vlicense LICENSE

	# Use upstream launcher script to set --configuration-file
	vbin biblioteq.sh biblioteq
}
