pkgname=openssl
pkgver=3.5.2
pkgdesc='The Open Source toolkit for Secure Sockets Layer and Transport Layer Security'
arch=('x86_64')
homepage='https://www.openssl.org'
license=('Apache-2.0')
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://www.openssl.org/source/${sources[0]}")
md5sums=("890fc59f86fc21b5e4d1c031a698dbde")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  ./config --prefix=/usr         \
           --openssldir=/etc/ssl \
           --libdir=lib          \
           shared                \
           zlib-dynamic
  make
}

src_check() {
  leaf_record_message "30-test_afalg.t is known to fail if no \`CONFIG_CRYPTO_USER_API_SKCIPHER\`. See LFS handbook."
  HARNESS_JOBS=${PARALLEL_JOBS} make test
}

src_install() {
  sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
  make DESTDIR="${pkgdir}" MANSUFFIX=ssl install
  mv -v "${pkgdir}/usr/share/doc/openssl" "${pkgdir}/usr/share/doc/openssl-${pkgver}"
  install -D -m644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}

