# Template file for 'sonic-visualiser'
pkgname="sonic-visualiser"
version="3.0.3"
revision=1
build_style="gnu-configure"
hostmakedepends="pkg-config capnproto-devel"
makedepends="qt5-devel qt5-svg-devel liblrdf-devel vamp-plugin-sdk-devel
 rubberband-devel libsndfile-devel libsamplerate-devel bzip2-devel sord-devel
 serd-devel libmad-devel liblo-devel jack-devel portaudio-devel fftw-devel
 liboggz-devel libfishsound-devel libid3tag-devel pulseaudio-devel capnproto-devel"
short_desc="Viewing and analysing the contents of music audio files"
maintainer="newbluemoon <blaumolch@mailbox.org>"
homepage="http://www.sonicvisualiser.org/"
license="GPL-2"
distfiles="https://code.soundsoftware.ac.uk/attachments/download/2246/${pkgname}-${version}.tar.gz"
checksum=bed25e6f88ddc110e4a59e4fed05be4ea026126369d50f17c896c7defef49f87

if [ -n "$CROSS_BUILD" ]; then
	hostmakedepends+=" qt5-qmake qt5-svg-devel"
	configure_args+=" lrdf_CFLAGS=-I${XBPS_CROSS_BASE}/usr/include/raptor2"
fi

post_extract() {
	# piper.capnp.c++ and piper.capnp.h are precompiled with capnproto 0.6.0
	# this leads to a version mismatch error with void’s newer version of capnproto
	# the source file piper.capnp is not included in the source tarball
	xbps-uhelper fetch "https://github.com/piper-audio/piper/raw/master/capnp/piper.capnp>piper-cpp/vamp-capnp/piper.capnp"
	capnp compile -o c++ piper-cpp/vamp-capnp/piper.capnp

	# don’t run target-built testing-binaries when cross building
	# on i686 1 out of 36 tests fails and compilation aborts
	if [ -n "$CROSS_BUILD" ] || [ "${XBPS_TARGET_MACHINE%%-musl}" = "i686" ]; then
		sed -i -e 's|QMAKE_POST_LINK = ./$${TARGET}||' test-svcore-base.pro
		sed -i -e 's|QMAKE_POST_LINK = ./$${TARGET}||' test-svcore-data-fileio.pro
		sed -i -e 's|QMAKE_POST_LINK = ./$${TARGET}||' test-svcore-data-model.pro
	fi
}

do_install() {
	vbin sonic-visualiser
	vbin piper-vamp-simple-server
	vbin vamp-plugin-load-checker
	vlicense COPYING
	vlicense deploy/linux/doc/${pkgname}/copyright
	vdoc README
	vdoc README.OSC
	vdoc CITATION
	vinstall icons/sv-icon.svg 644 usr/share/pixmaps
	vinstall icons/sv-icon-light.svg 644 usr/share/pixmaps
	vinstall deploy/linux/deb-skeleton/usr/share/applications/sonic-visualiser.desktop 644 usr/share/applications
}

