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

github.setup        hackerschoice gsocket 1.4.43 v
revision            0

categories          net
license             BSD
maintainers         {@barracuda156 macos-powerpc.org:barracuda}

description         Connect like there is no firewall, securely
long_description    {*}${description}
homepage            https://www.gsocket.io
checksums           rmd160  4d41aec0779374f90f5457fad22d2a7e6eeaf88c \
                    sha256  078977937b6233eea0d8cf653bbdf3049072270327b44e0bc9a4e44e4a56d92f \
                    size    223602
github.tarball_from archive

use_autoreconf      yes

depends_build-append \
                    port:zlib

depends_test-append port:bash \
                    port:curl \
                    path:libexec/coreutils/libstdbuf.so:coreutils \
                    port:gnetcat \
                    port:md5sha1sum \
                    port:openssh \
                    port:rsync \
                    port:socat

# https://github.com/hackerschoice/gsocket/pull/110
patchfiles-append   0001-Fix-for-missing-be64toh-htobe64-on-macOS.patch

# https://github.com/hackerschoice/gsocket/issues/111
patchfiles-append   0002-Fix-linking-on-macOS-needs-zlib.patch

# https://github.com/hackerschoice/gsocket/pull/114
patchfiles-append   0003-run_gs_tests.sh-fix-cp-syntax.patch

patchfiles-append   patch-tests.diff

post-patch {
    reinplace "s,@PREFIX@,${prefix},g" \
                    ${worksrcpath}/configure.ac ${worksrcpath}/tests/run_gs_tests.sh
}

# --enable-static=no breaks linking test binaries:
# https://github.com/hackerschoice/gsocket/issues/112
configure.args-append \
                    --enable-tests=yes \
                    --includedir=${prefix}/include \
                    --libdir=${prefix}/lib \
                    --prefix=${prefix}

test.env-append     SH=${prefix}/bin/bash
test.run            yes
test.dir            ${worksrcpath}/tests
test.cmd            ./run_all_tests.sh
test.target
