SUMMARY="A high quality MPEG Audio Layer III (MP3) encoder"
DESCRIPTION="
Following the great history of GNU naming, LAME originally stood for LAME \
Ain't an Mp3 Encoder. LAME started life as a GPL'd patch against the dist10 \
ISO demonstration source, and thus was incapable of producing an mp3 stream or \
even being compiled by itself. But in May 2000, the last remnants of the ISO \
source code were replaced, and now LAME is the source code for a fully LGPL'd \
MP3 encoder, with speed and quality to rival and often surpass all commercial \
competitors.
"
HOMEPAGE="http://lame.sourceforge.net/" 
SRC_URI="http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz"
CHECKSUM_SHA256="24346b4158e4af3bd9f2e194bb23eb473c75fb7377011523353196b19b9a23ff"
LICENSE="GNU LGPL v2"
COPYRIGHT="1998-2012 Mike Cheng et al."
REVISION="2"
ARCHITECTURES="x86 x86_gcc2"

PROVIDES="
	lame = $portVersion compat >= 1
	cmd:lame = $portVersion compat >= 1
	lib:libmp3lame = $portVersion compat >= 0.0.0
	"
REQUIRES="
	haiku >= $haikuVersion
	lib:libiconv
	"
BUILD_REQUIRES="
	haiku_devel >= $haikuVersion
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc${secondaryArchSuffix}
	cmd:ld${secondaryArchSuffix}
	cmd:libtoolize
	cmd:make
	cmd:m4
	cmd:sed
	devel:libiconv
	"
	
PATCHES="lame-3.99.5.patch"

BUILD()
{
	mkdir -p m4
# configure checks for gtk, but they didn't include the gtk.m4 so we need to.
	cp $portDir/additional-files/gtk.m4 m4/gtk.m4 
	cp `aclocal --print-ac-dir`/iconv.m4 m4/iconv.m4
	cp $portDir/additional-files/lib-link.m4 m4/lib-link.m4
	cp $portDir/additional-files/lib-ld.m4 m4/lib-ld.m4
	cp $portDir/additional-files/lib-prefix.m4 m4/lib-prefix.m4		

	sed -i 's/AM_C_PROTOTYPES//' configure.in
	sed -i 's/AUTOMAKE_OPTIONS = foreign $(top_srcdir)\/ansi2knr//' \
		libmp3lame/i386/Makefile.am
	sed -i 's/AUTOMAKE_OPTIONS = foreign ansi2knr//' \
		doc/man/Makefile.am
	sed -i 's/AUTOMAKE_OPTIONS = foreign ansi2knr//' \
		doc/html/Makefile.am
	sed -i 's/HAVE_SNDFILE="yes"/HAVE_SNDFILE="no"/g' configure.in
	sed -i 's/PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.2, HAVE_SNDFILE="no", HAVE_SNDFILE="no")/HAVE_SNDFILE="no"/' configure.in
	sed -i 's/@SNDFILE_CFLAGS@/-ffast-math/g' frontend/*
	sed -i 's/@SNDFILE_LIBS@/-ffast-math/g' frontend/*	

	libtoolize --force --copy --install
	aclocal -I m4
	automake
	autoconf
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	# prepare devel/lib
	prepareInstalledDevelLibs libmp3lame
	fixPkgconfig
	
	# devel package
	packageEntries devel \
		$developDir
}

# ----- devel package -------------------------------------------------------

PROVIDES_devel="
	lame_devel = $portVersion
	devel:libmp3lame = 0.0.0 compat >= 0
	"
REQUIRES_devel="
	lame == $portVersion base
	"
