SUMMARY="A library for solving packages and reading repositories"
DESCRIPTION="A Library for solving packages and reading repositories."
LICENSE="BSD (3-clause)"
COPYRIGHT="2007-2013, Novell Inc."
HOMEPAGE="http://github.com/openSUSE/libsolv"
srcGitRev="da2650933f85f5a30d8146bfb22af53d2620d0c7"
SOURCE_URI="https://github.com/weinhold/libsolv/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="79aa7772bfe403f003e8063480ddc3d4f491b3f5d7b8cace610605fba3318150"
SOURCE_FILENAME="$portVersionedName.tar.gz"
REVISION="1"
ARCHITECTURES="x86_gcc2 x86 x86_64 ppc arm"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	libsolv$secondaryArchSuffix = $portVersion
	lib:libsolv$secondaryArchSuffix = $portVersion
	lib:libsolvext$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
BUILD_REQUIRES="
	devel:libexpat$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:sed
	"

SOURCE_DIR="libsolv-$srcGitRev"

PATCH()
{
	sed -i 's,${CMAKE_INSTALL_PREFIX}/bin',$binDir, CMakeLists.txt
	sed -i 's,${CMAKE_INSTALL_PREFIX}/include',$includeDir, \
		src/CMakeLists.txt ext/CMakeLists.txt
}

BUILD()
{
	rm -rf build
	mkdir build
	cd build
	cmake -DCMAKE_INSTALL_PREFIX:PATH=$prefix -DLIB=$relativeLibDir ..
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	# set up the develop directory correctly
	prepareInstalledDevelLibs libsolv libsolvext

	# move cmake files
	mkdir -p $dataDir
	mv $prefix/share/cmake $dataDir
	rmdir $prefix/share

	# We don't want the executables.
	rm -r $prefix/bin

	# devel package
	packageEntries devel \
		$dataDir \
		$developDir
}

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

PROVIDES_devel="
	libsolv${secondaryArchSuffix}_devel = $portVersion
	devel:libsolv${secondaryArchSuffix} = $portVersion
	devel:libsolvext${secondaryArchSuffix} = $portVersion
	"
REQUIRES_devel="
	libsolv${secondaryArchSuffix} == $portVersion base
	"
