# Contributor: A. Wilcox <awilfox@adelielinux.org>
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=phonon
pkgver=4.10.1
pkgrel=0
pkgdesc="Qt library for playing multimedia files"
url="https://phonon.kde.org/"
arch="all"
license="LGPL-2.1-only OR LGPL-3.0-only"
depends=""
makedepends="cmake extra-cmake-modules pulseaudio-dev
	qt5-qtbase-dev qt5-qttools-dev"
subpackages="$pkgname-dev $pkgname-designer"
source="https://download.kde.org/stable/phonon/$pkgver/phonon-$pkgver.tar.xz"

build() {
	cd "$builddir"
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DPHONON_INSTALL_QT_EXTENSIONS_INTO_SYSTEM_QT=TRUE \
		-DWITH_GLIB2=TRUE \
		-DWITH_PulseAudio=TRUE \
		-DPHONON_BUILD_PHONON4QT5=TRUE \
		${CMAKE_CROSSOPTS}
	make
}

check() {
	cd "$builddir"
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

designer() {
	pkgdesc="$pkgdesc (Qt Designer plugin)"
	install_if="$pkgname=$pkgver-$pkgrel qt5-qttools"
	mkdir -p "$subpkgdir"/usr/lib/qt5/plugins/
	mv "$pkgdir"/usr/lib/qt5/plugins/designer \
		"$subpkgdir"/usr/lib/qt5/plugins/
	rmdir "$pkgdir"/usr/lib/qt5/plugins || true # Never mind
}

sha512sums="a1cc0960c587d09a2fb0f43ae82147df133c34cba7bf01f5720b4b27aca4dda1d83444e89e40fb2f25828d152f89ccfff56d2d4649007c57b7df9eca8c64c007  phonon-4.10.1.tar.xz"