SUMMARY="A C++ library and command line utility to manage image metadata"
DESCRIPTION="Exiv2 provides fast and easy read and write access to the Exif, \
IPTC and XMP metadata of images in various formats. Exiv2 is available as \
free software and with a commercial license, and is used in many projects."
HOMEPAGE="https://www.exiv2.org/"
COPYRIGHT="2004-2013 Andreas Huggel
	2009 Brad Schick"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/Exiv2/exiv2/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="6398bc743c32b85b2cb2a604273b8c90aa4eb0fd7c1700bf66cbb2712b4f00c1"
PATCHES="exiv2-$portVersion.patchset"

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

PROVIDES="
	exiv2$secondaryArchSuffix = $portVersion
	cmd:exiv2$secondaryArchSuffix = $portVersion
	lib:libexiv2$secondaryArchSuffix = $portVersion
	lib:libexiv2_xmp$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libgettextpo$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	exiv2${secondaryArchSuffix}_devel = $portVersion
	devel:libexiv2${secondaryArchSuffix} = $portVersion
	devel:libexiv2_xmp${secondaryArchSuffix} = $portVersion
	"
REQUIRES_devel="
	exiv2$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libexpat$secondaryArchSuffix
	devel:libgettextlib$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:gettext
	cmd:grep
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

BUILD()
{
	export CXXFLAGS="-D_BSD_SOURCE"
	export LDFLAGS="-lbsd -lnetwork"

	mkdir -p build
	cd build
	cmake .. $cmakeDirArgs \
		-DEXIV2_ENABLE_CURL=ON \
		-DEXIV2_ENABLE_VIDEO=ON \
		-DEXIV2_BUILD_SAMPLES=OFF

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libexiv2 libexiv2-xmp
	fixPkgconfig

	sed -i "s|.self/$relativeLibDir|.self/$relativeDevelopLibDir|" $libDir/cmake/exiv2/exiv2Config-noconfig.cmake
	sed -i "s|/include|/$relativeIncludeDir|" $libDir/cmake/exiv2/exiv2Config.cmake

	packageEntries devel \
		$developDir \
		$libDir/cmake
}
