SUMMARY="C Library API for Amazon S3"
DESCRIPTION="The libs3 project implements a complete C library API for \
Amazon S3. It is intended to be easy to use, comprehensive, and suitable \
for use from any C or C++ program."
HOMEPAGE="https://github.com/bji/libs3"
COPYRIGHT="2008 Bryan Ischo"
LICENSE="GNU GPL v3"
REVISION="2"
SOURCE_URI="http://archive.ubuntu.com/ubuntu/pool/main/libs/libs3/libs3_$portVersion.orig.tar.gz
	http://ftp.debian.org/debian/pool/main/libs/libs3/libs3_$portVersion.orig.tar.gz"
CHECKSUM_SHA256="c99857bfbcc9ff47742119bc32f391f38a24acf40cf49902ef3b18b1f0e8c16d"
PATCHES="libs3-$portVersion.patch"

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

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%.*}"

PROVIDES="
	libs3$secondaryArchSuffix = $portVersion
	cmd:s3$secondaryArchSuffix = $portVersion
	lib:libs3$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libs3${secondaryArchSuffix}_devel = $portVersion
	devel:libs3$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libs3$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libs3$secondaryArchSuffix \
	"$binDir"/s3 \
	"$libDir"/libs3.so.$libVersion

BUILD()
{
	make $jobArgs
}

INSTALL()
{
	install -d -m 755 $binDir $libDir $includeDir
	install -m 755 -t $binDir ./build/bin/s3
	install -m 755 ./build/lib/libs3.so.${libVersion%.*} $libDir/libs3.so.$libVersion
	ln -s $libDir/libs3.so.$libVersion $libDir/libs3.so.${libVersion%.*}
	install -m 644 -t $libDir ./build/lib/libs3.a
	install -m 644 -t $includeDir ./inc/libs3.h

	prepareInstalledDevelLib libs3

	packageEntries devel \
		$developDir
}
