SUMMARY="A free and open source audio converter"
DESCRIPTION="fre:ac is a free and open source audio converter. It comes with \
an integrated tag editor and converts between various formats.

Features include:

- Support for MP3, MP4/AAC, Opus, FLAC and other formats
- Integrated player and tag editor
- Support for playlists, cue sheets and chapters
- Fast, multi-threaded conversion engine
- Ability to convert to multiple formats at once
- Can verify lossless input and output files
- Support for freedb/CDDB queries and submits
- Support for using command line codecs
- User interface available in 40+ languages
- Optional command line interface"
HOMEPAGE="https://freac.org/"
COPYRIGHT="2001-2022 Robert Kausch"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/enzo1982/freac/releases/download/v${portVersion}/freac-${portVersion}.tar.gz"
CHECKSUM_SHA256="8269c6c733f91bbca38027375c0afd424093ac64c621871f0fe30726d6c46248"
SOURCE_DIR="freac-${portVersion}"

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandBinDir=$prefix/bin
fi

PROVIDES="
	freac$secondaryArchSuffix = $portVersion
	app:freac = $portVersion
	cmd:freaccmd = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	boca$secondaryArchSuffix >= 1.0.6
	smooth$secondaryArchSuffix >= 0.9.6
	cmd:ffmpeg
	cmd:mpcdec
	cmd:mpcenc
	cmd:wavpack
	cmd:wvunpack
	lib:libsmooth_0.9$secondaryArchSuffix >= 0
	lib:libboca_1.0$secondaryArchSuffix >= 3
	lib:libcdio$secondaryArchSuffix
	lib:libcdio_cdda$secondaryArchSuffix
	lib:libcdio_paranoia$secondaryArchSuffix
	lib:libfaad$secondaryArchSuffix
	lib:libfdk_aac$secondaryArchSuffix
	lib:libFLAC$secondaryArchSuffix
	lib:libMAC$secondaryArchSuffix >= 8
	lib:libmp3lame$secondaryArchSuffix
	lib:libmp4v2$secondaryArchSuffix
	lib:libmpg123$secondaryArchSuffix
	lib:libogg$secondaryArchSuffix
	lib:libopus$secondaryArchSuffix
	lib:librubberband$secondaryArchSuffix
	lib:libsamplerate$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libspeex$secondaryArchSuffix
	lib:libvorbis$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	boca${secondaryArchSuffix}_devel >= 1.0.6
	smooth${secondaryArchSuffix}_devel >= 0.9.6
	devel:libboca_1.0$secondaryArchSuffix >= 3
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	make $jobArgs
}

INSTALL()
{
	make prefix="$prefix" bindir="$commandBinDir" libdir="$libDir" \
		includedir="$includeDir" datadir="$dataDir" install

	mkdir -p "$appsDir"
	mv "$commandBinDir"/freac "$appsDir"

	addAppDeskbarSymlink "$appsDir"/freac fre:ac
}
