# -*- 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           github 1.0
PortGroup           legacysupport 1.1

github.setup        ndilieto uacme 1.7.6 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball

categories          security
license             GPL-3+
platforms           any

maintainers         {gmail.com:lmkrawiec @lmkra} \
                    openmaintainer

description         ACMEv2 client written in plain C with minimal dependencies
long_description    lightweight client for the RFC8555 ACMEv2 protocol, \
                    written in plain C with minimal dependencies \
                    (libcurl and OpenSSL).

checksums           rmd160  25b45f340ae07a6f81ea13b56f5d8a72a5b51bb7 \
                    sha256  2018fef8d4ff14b361ab565b0f645ad36afa5cd778cdc500bc4501922bb4346b \
                    size    263663

depends_build-append \
                    port:asciidoc
# dependencies of autoreconf
depends_build-append \
                    port:pkgconfig \
                    port:autoconf \
                    port:automake

depends_lib-append  port:curl \
                    port:libev \
                    port:openssl

configure.args      --with-libcurl=${prefix} \
                    --with-openssl=${prefix} \
                    --without-mbedtls \
                    --without-gnutls

compiler.c_standard 1999

platform darwin {
    # ualpn does not build on Darwin because Darwin does not implement unnamed
    # semaphores
    # https://github.com/ndilieto/uacme/issues/49
    configure.args-append \
                    --without-ualpn
    depends_lib-delete \
                    port:libev

    legacysupport.newest_darwin_requires_legacy 16
}

use_autoreconf      yes
autoreconf.args     -fvi

pre-configure {
    # uacme build system tries to fetch its version from `git describe` command output.
    # Since we're not building within a git repository, we need to explicitly
    # provide version number in .tarball-version file
    set fd [open ${worksrcpath}/.tarball-version "w"]
    puts $fd ${version}
    close $fd
}