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

name                    nxcomp
version                 3.5.99.22
checksums               rmd160  33db4dcc1d54e956f875b5531637ef2123b154f4 \
                        sha256  0c411aae869675a0d1803e629592ce1c4ade598611e5dcc444696494b92a8e4e \
                        size    740152

# strndup
legacysupport.newest_darwin_requires_legacy 10

categories              net
license                 GPL-2

maintainers             {ionic @Ionic} openmaintainer

description             nxcomp is the X compression library by NX
long_description        nxcomp is a library compressing X commands to be passed over network \
                        for use with the X2Go suite.

homepage                https://wiki.x2go.org/doku.php/wiki:libs:nx-libs
master_sites            https://code.x2go.org/releases/source/nx-libs/
distname                nx-libs-${version}-lite
worksrcdir              nx-libs-${version}
patch.dir               ${workpath}/${worksrcdir}
worksrcdir              ${worksrcdir}/${subport}

universal_variant       yes

# We are patching Makefile.am.
use_autoreconf          yes
# https://trac.macports.org/wiki/WimplicitFunctionDeclaration#strchr
configure.checks.implicit_function_declaration.whitelist-append strchr

depends_build-append    path:bin/pkg-config:pkgconfig

configure.args-append   --disable-silent-rules

post-configure {
    # Avoid errors like
    # In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/include/c++/v1/ostream:142:
    # ../version:1:1: error: expected unqualified-id
    # 3.5.99.22
    # https://github.com/ArcticaProject/nx-libs/issues/1086
    # The VERSION file must not be moved until after the configure phase.
    move ${worksrcpath}/VERSION ${worksrcpath}/VERSION.txt
}


if {${name} eq ${subport}} {
    revision            3

    depends_lib-append  port:libpng \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:zlib \
                        port:xorg-xorgproto

    patchfiles-append   bind.patch

    livecheck.url       [lindex ${master_sites} 0]
    livecheck.regex     nx-libs-(\[0-9\]+(\\.\[0-9\]+)+(-\[0-9\]+)?)-lite
} else {
    livecheck.type      none
}

subport nxproxy {
    revision            1

    description         nxproxy is a compressing proxy for X
    long_description    nxproxy is a library compressing X commands to be passed over network \
                        for use with the X2Go suite.

    installs_libs       no

    depends_lib-append  port:nxcomp

    patchfiles-append   patch-nxproxy_src_Makefile.am-use-system-libXcomp.diff

    configure.cppflags-append   -I${prefix}/include/nx
}
