# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=aws-c-s3
pkgver=0.7.4
pkgrel=0
pkgdesc="AWS C99 library implementation for communicating with the S3 service"
url="https://github.com/awslabs/aws-c-s3"
# s390x: aws-c-common
arch="all !s390x"
license="Apache-2.0"
makedepends="
	aws-c-auth-dev
	aws-c-cal-dev
	aws-c-common-dev
	aws-c-compression-dev
	aws-c-http-dev
	aws-c-io-dev
	aws-c-sdkutils-dev
	aws-checksums-dev
	cmake
	curl-dev
	s2n-tls-dev
	samurai
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-c-s3/archive/refs/tags/v$pkgver.tar.gz"
options="!check"  # The unit tests require an AWS account with S3 buckets set up in a particular way.

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$crossopts
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev
	amove usr/lib/aws-c-s3
}

sha512sums="
e2cc5f44f8b7a1179f4e9b16bd1ab74c069bd25b15cb825382c06545eb9f309f568d8b47f47daec3b1e8c18ece1ebd5a051eafc741c19490854290e2222fd1ed  aws-c-s3-0.7.4.tar.gz
"
