# -*- 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

name                        xmlsec
version                     1.3.2
revision                    2
checksums                   rmd160  101a0288c83cd0e0b5665063e4763748936be8d8 \
                            sha256  4003c56b3d356d21b1db7775318540fad6bfedaf5f117e8f7c010811219be3cf \
                            size    2437263

categories                  security textproc devel
license                     MIT
maintainers                 {mps @Schamschula} openmaintainer

description                 XML Security Library is a C library based on LibXML2.

long_description            {*}${description}. The library supports major XML security \
                            standards. XML Signature, XML Encryption, Canonical XML and \
                            Exclusive Canonical XML.

homepage                    https://www.aleksey.com/xmlsec/
master_sites                ${homepage}download/ \
                            ftp://ftp.xmlsoft.org/xmlsec/releases/
distname                    xmlsec1-${version}

depends_build               port:pkgconfig

depends_lib                 port:libxml2 \
                            port:libxslt \
                            port:libiconv \
                            port:libtool \
                            path:lib/pkgconfig/icu-uc.pc:icu \
                            port:zlib

patchfiles                  patch-src-dl.c.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/src/dl.c
}

configure.args              --disable-silent-rules \
                            --with-libxml=${prefix} \
                            --with-libxslt=${prefix}

# Add gcrypt support.
depends_lib-append          port:libgcrypt
configure.args-append       --with-gcrypt=${prefix}

# Add gnutls support.
depends_lib-append          path:lib/pkgconfig/gnutls.pc:gnutls
# Do not specify the path to gnutls or it will fail to find it, because
# it looks for the libgnutls-config script that gnutls no longer provides.
# Do not remove the equals sign or it will fail trying to find the
# libraries and headers in a directory called "yes".
configure.args-append       --with-gnutls=

# Add nss and nspr support.
depends_lib-append          port:nss port:nspr
configure.args-append       --with-nss --with-nspr
configure.ldflags-append    -L${prefix}/lib/nss -L${prefix}/lib/nspr
# nss is not universal.
universal_variant           no

# Add openssl support.
depends_lib-append          path:lib/libssl.dylib:openssl
# Do not specify the path to openssl or it will try to link with the
# static library instead of the dynamic one, and it will fail when
# openssl is installed universal.
# Do not remove the equals sign or it will fail trying to find the
# libraries and headers in a directory called "yes".
configure.args-append       --with-openssl=

test.run                    yes
test.target                 check

livecheck.type              regex
livecheck.url               ${homepage}download.html
livecheck.regex             {xmlsec1-([0-9.]+)\.}
