SUMMARY="Library for recording CD/DVD/BD media"
DESCRIPTION="libburn is a library that can record preformatted data onto CD \
(including Audio CD), DVD and Blu-ray discs (BD) optical media. It also offers \
a facility for reading data blocks from optical media."
HOMEPAGE="https://dev.lovelyhq.com/libburnia"
COPYRIGHT="2006-2016 Mario Danic and Thomas Schmitt"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="http://files.libburnia-project.org/releases/libburn-$portVersion.tar.gz"
CHECKSUM_SHA256="3e81a2e359376c38d96239a9c9967be715f706d150d89c337de0fc85ecb79da6"
PATCHES="libburn-$portVersion.patchset"

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

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

PROVIDES="
	libburn$secondaryArchSuffix = $portVersion compat >= 1
	cmd:cdrskin$commandSuffix
	lib:libburn$secondaryArchSuffix = 4.101.0 compat >= 4
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libburn${secondaryArchSuffix}_devel = $portVersion compat >= 1
	devel:libburn$secondaryArchSuffix = 4.101.0 compat >= 4
	"
REQUIRES_devel="
	libburn$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:autoreconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

PATCH()
{
	sed \
		-e "s,\
ftp://ftp.berlios.de/pub/cdrecord/alpha,\
http://sourceforge.net/projects/cdrtools/files/alpha," \
		-e "s,\
ftp://ftp.berlios.de/pub/cdrecord/,\
http://sourceforge.net/projects/cdrtools/files/," \
		-e "s,\
http://cdrecord.berlios.de/private/cdrecord.html,\
http://cdrtools.sourceforge.net/private/cdrecord.html," \
		-e "s,\
http://cdrecord.berlios.de/old/private/cdrecord.html,\
http://cdrtools.sourceforge.net/private/cdrecord.html," \
		-e "s,\
http://cdrecord.berlios.de/old/private/man/cdrecord-2.0.html,\
http://cdrtools.sourceforge.net/private/man/cdrecord/cdrecord.1.html," \
		-i \
	cdrskin/wiki_plain.txt \
	cdrskin/cdrskin_eng.html \
	cdrskin/cdrskin.c \
	cdrskin/README \
	doc/mediainfo.txt \
	doc/cdtext.txt
}

BUILD()
{
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure --bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool file
	rm $libDir/libburn.la

	prepareInstalledDevelLib libburn
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
