SUMMARY="Bauer stereophonic-to-binaural DSP VST plugin"
DESCRIPTION="The Bauer stereophonic-to-binaural DSP (bs2b) is designed to \
improve headphone listening of stereo audio records.
Recommended for headphone prolonged listening to disable superstereo fatigue.
"
HOMEPAGE="http://bs2b.sourceforge.net"
COPYRIGHT="2005 Boris Mikhaylov"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="svn://svn.code.sf.net/p/bs2b/code/trunk"
SOURCE_URI_2="svn+https://github.com/kxproject/kx-audio-driver/trunk/vst"
PATCHES="bs2b-2.1.0.patchset"

ARCHITECTURES="x86_gcc2 x86"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	bs2b$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libsndfile$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:autoreconf
	cmd:g++$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cd $sourceDir/libbs2b
	./autogen.sh
	./configure
	make

	# fix line endings
	sed -i 's/\r//' $sourceDir2/h/*.h
	sed -i 's/\r//' $sourceDir2/vstlib/*.h
	sed -i 's/\r//' $sourceDir2/vstgui/*.h

	cd $sourceDir/plugins/vst/src

	gcc -shared -o bs2b $sourceDir2/vstlib/audioeffect.cpp \
		$sourceDir2/vstlib/audioeffectx.cpp \
		bs2b_vst.cpp \
		main.cpp \
		-I$sourceDir2/h/ -I$sourceDir2/vstlib -I$sourceDir2/vstgui -I../../../libbs2b/src \
		../../../libbs2b/src/.libs/libbs2b.a
}

INSTALL()
{
	mkdir -p $addOnsDir/media/vstplugins
	cp $sourceDir/plugins/vst/src/bs2b $addOnsDir/media/vstplugins
}
