SUMMARY="A command line utility to do audio format conversions"
DESCRIPTION="SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility \
that can convert various formats of computer audio files in to other formats.\
It can also apply various effects to these sound files, and, as an added \
bonus, SoX can play and record audio files on most platforms."
HOMEPAGE="http://sox.sourceforge.net"
COPYRIGHT="1991-2015 Lance Norskog"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://downloads.sf.net/sox/sox-$portVersion.tar.bz2"
CHECKSUM_SHA256="81a6956d4330e75b5827316e44ae381e6f1e8928003c6aa45896da9041ea149c"
PATCHES="sox-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

libVersion="3.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	sox$secondaryArchSuffix = $portVersion compat >= 1
	cmd:play$secondaryArchSuffix = $portVersion
	cmd:rec$secondaryArchSuffix = $portVersion
	cmd:sox$secondaryArchSuffix = $portVersion
	cmd:soxi$secondaryArchSuffix = $portVersion
	lib:libsox$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libao$secondaryArchSuffix
	lib:libflac$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libid3tag$secondaryArchSuffix
	lib:libmad$secondaryArchSuffix
	lib:libmagic$secondaryArchSuffix
	lib:libmp3lame$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
#	lib:libopus$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	lib:libwavpack$secondaryArchSuffix
	"

PROVIDES_devel="
	sox${secondaryArchSuffix}_devel = $portVersion
	devel:libsox$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	sox${secondaryArchSuffix} == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libao$secondaryArchSuffix
	devel:libflac$secondaryArchSuffix
	devel:libid3tag$secondaryArchSuffix
	devel:libmad$secondaryArchSuffix
	devel:libmagic$secondaryArchSuffix
	devel:libmp3lame$secondaryArchSuffix
	devel:libogg$secondaryArchSuffix
#	devel:libopus$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libsndfile$secondaryArchSuffix
	devel:libvorbis$secondaryArchSuffix
	devel:libwavpack$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage sox$secondaryArchSuffix \
	"$libDir"/libsox.so.$libVersion

BUILD()
{
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLibs libsox
	fixPkgconfig

	packageEntries devel \
		"$developDir"
}
