# Template file for 'libaccounts-qt'
pkgname=libaccounts-qt
version=1.17
revision=1
build_style=qmake
configure_args="LIBDIR=/usr/lib .."
hostmakedepends="pkg-config doxygen qt5-qmake qt5-host-tools
 qt6-base"
makedepends="libaccounts-glib-devel qt5-devel qt6-base-devel"
short_desc="Client library to the accounts database"
maintainer="John Rowley <enterthevoid@codesector.co>"
license="LGPL-2.1-only"
homepage="https://gitlab.com/accounts-sso/libaccounts-qt"
distfiles="${homepage}/-/archive/VERSION_${version}/libaccounts-qt-VERSION_${version}.tar.gz"
checksum=6ed3e976133962c1c88f6c66928ba0d0a17a570843577d31e783dc891659e5d8

post_extract() {
	mkdir -p build-qt5 build-qt6
}

pre_configure() {
	build_wrksrc=build-qt5
}

post_configure() {
	build_wrksrc="build-qt6"
	QT=qt6
	do_configure
}

do_build() {
	make -C build-qt5 ${make_jobs}
	make -C build-qt6 ${make_jobs}
}

do_install() {
	make -C build-qt5 install DESTDIR=${DESTDIR} PREFIX=/usr \
		INSTALL_ROOT=${DESTDIR} STRIP=true
	make -C build-qt6 install DESTDIR=${DESTDIR} PREFIX=/usr \
		INSTALL_ROOT=${DESTDIR} STRIP=true
}

libaccounts-qt5_package() {
	short_desc+=" - Qt5"
	pkg_install() {
		vmove "usr/lib/libaccounts-qt5.so.*"
	}
}

libaccounts-qt6_package() {
	short_desc+=" - Qt6"
	pkg_install() {
		vmove "usr/lib/libaccounts-qt6.so.*"
	}
}

libaccounts-qt5-devel_package() {
	short_desc+=" - Qt5 - development files"
	depends="qt5-devel libaccounts-qt5>=${version}_${revision}"
	pkg_install() {
		vmove usr/include/accounts-qt5
		vmove usr/lib/libaccounts-qt5.so
		vmove usr/lib/cmake/AccountsQt5
		vmove usr/lib/pkgconfig/accounts-qt5.pc
	}
}

libaccounts-qt6-devel_package() {
	short_desc+=" - Qt6 - development files"
	depends="qt6-base-devel libaccounts-qt6>=${version}_${revision}"
	pkg_install() {
		vmove usr/include/accounts-qt6
		vmove usr/lib/libaccounts-qt6.so
		vmove usr/lib/cmake/AccountsQt6
		vmove usr/lib/pkgconfig/accounts-qt6.pc
		vmove usr/share/doc
	}
}
