# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           cmake 1.1
PortGroup           compiler_blacklist_versions 1.0
PortGroup           github 1.0
PortGroup           legacysupport 1.1

github.setup        nih-at libzip 1.11.4 v
revision            0

checksums           rmd160  15a725b29600dc5eb3a0256cd05fb5662c8c8620 \
                    sha256  8a247f57d1e3e6f6d11413b12a6f28a9d388de110adc0ec608d893180ed7097b \
                    size    793340

categories          archivers
license             BSD
maintainers         nomaintainer
description         libzip is a C library for reading, creating, and modifying zip archives
long_description    {*}${description}. \
                    Files can be added from data buffers, files, or compressed data  \
                    copied directly from other zip archives. Changes made without \
                    closing the archive can be reverted.
homepage            https://libzip.org/
# For some reason downloading from the website is unreliable.
# Use releases from GitHub repo, they are identical to xz sources from the website.
# master_sites        ${homepage}download/
github.tarball_from releases
use_xz              yes

depends_build-append \
                    path:libexec/coreutils/libstdbuf.so:coreutils
depends_lib-append  port:bzip2 \
                    port:zlib

configure.args-append \
                    -DENABLE_COMMONCRYPTO:Bool=OFF \
                    -DENABLE_GNUTLS:Bool=OFF \
                    -DENABLE_MBEDTLS:Bool=OFF \
                    -DENABLE_OPENSSL:Bool=OFF

# zip.h: error: wrong number of arguments specified for ‘deprecated’ attribute
compiler.blacklist-append *gcc-4.0 *gcc-4.2 {clang < 421}

variant gnutls conflicts mbedtls openssl description {install gnutls crypto support} {
    configure.args-replace \
                    -DENABLE_GNUTLS:Bool=OFF \
                    -DENABLE_GNUTLS:Bool=ON

    depends_lib-append  \
                    path:lib/pkgconfig/gnutls.pc:gnutls \
                    port:nettle
}

variant mbedtls conflicts gnutls openssl description {install mbedtls crypto support} {
    configure.args-replace \
                    -DENABLE_MBEDTLS:Bool=OFF \
                    -DENABLE_MBEDTLS:Bool=ON

    depends_lib-append  \
                    port:mbedtls
}

variant openssl conflicts gnutls mbedtls description {install openssl crypto support} {
    configure.args-replace \
                    -DENABLE_OPENSSL:Bool=OFF \
                    -DENABLE_OPENSSL:Bool=ON

    depends_lib-append  \
                    port:openssl
}
