name       : openssl
version    : 3.3.2
release    : 53
source     :
    - https://github.com/openssl/openssl/releases/download/openssl-3.3.2/openssl-3.3.2.tar.gz : 2e8a40b01979afe8be0bbfb3de5dc1c6709fedb46d6c89c10da114ab5fc3d281
homepage   : https://www.openssl.org/
license    : OpenSSL
summary    : Cryptographic tools required by many packages
description: |
    The OpenSSL package contains management tools and libraries relating to cryptography. These are useful for providing cryptography functions to other packages, such as OpenSSH, email applications and web browsers (for accessing HTTPS sites).
component  :
    - system.base
    - devel : system.devel
emul32     : yes
avx2       : yes
builddeps  :
    - pkgconfig32(zlib)
    - glibc-32bit-devel
    - libgcc-32bit
setup      : |
    %patch -p1 -i $pkgfiles/0001-Use-OS-provided-copy-of-openssl.cnf-as-fallback.patch
    %patch -p1 -i $pkgfiles/0001-Fix-soname-dynamic-loading.patch
    %patch -p1 -i $pkgfiles/ca-dir.patch

    if [[ -z "${EMUL32BUILD}" ]]; then
        ./Configure --prefix=/usr --openssldir=/etc/ssl --libdir=lib64 shared zlib-dynamic enable-ktls enable-ec_nistp_64_gcc_128 linux-x86_64
    else
        ./Configure --prefix=/usr --openssldir=/etc/ssl --libdir=lib32 shared zlib-dynamic enable-ktls linux-x86
    fi
build      : |
    %make
install    : |
    %make install_sw install_ssldirs install_man_docs DESTDIR="$installdir" INSTALL_PREFIX="$installdir"

    # Stateless (kinda)
    install -dm755 $installdir/usr/share/defaults/etc/ssl
    mv $installdir/etc/ssl/openssl.cnf $installdir/usr/share/defaults/etc/ssl/openssl.cnf
    rm -v $installdir/etc/ssl/openssl.cnf.dist
