# Maintainer: Anatol Pomozov

pkgname=s2n-tls
pkgver=1.3.47
pkgrel=1
pkgdesc='A C99 implementation of the TLS/SSL protocols that is designed to be simple, small, fast, and with security as a priority'
arch=(x86_64 aarch64)
url='https://github.com/aws/s2n-tls'
license=(Apache)
provides=(s2n) # upstream renamed the project from s2n to s2n-tls
conflicts=(s2n)
replaces=(s2n)
depends=(openssl gcc-libs)
makedepends=(cmake)
source=(s2n-tls-$pkgver.zip::https://github.com/aws/s2n-tls/archive/v$pkgver.zip)
sha256sums=('36ca0621cbd1b457e303ea5b574934a23a489848cffbd987d93902ab6826fab5')

build() {
  cd s2n-tls-$pkgver

  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON -DUNSAFE_TREAT_WARNINGS_AS_ERRORS=OFF \
      -S . -B build
  cmake --build build
}

check() {
  cd s2n-tls-$pkgver
  cmake --build build --target test
}

package() {
  cd s2n-tls-$pkgver

  cmake --build build --target install -- DESTDIR="$pkgdir/"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
