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

github.setup                eiskaltdcpp eiskaltdcpp 34d416d9e32d4c1fd21e0438c1baa268b5cbf2df
version                     2.4.2-github-2024.04.01
revision                    0
epoch                       1
categories                  net p2p www
license                     GPL-3
maintainers                 {@barracuda156 gmail.com:vital.had} openmaintainer
description                 Direct Connect protocols file sharing
long_description            EiskaltDC++ is a cross-platform program that uses the Direct Connect (DC aka NMDC) and Advanced Direct Connect (ADC) protocols. \
                            It is compatible with DC++, AirDC++, FlylinkDC++ and other DC clients. EiskaltDC++ also interoperates with all common DC hub software.

checksums                   rmd160  d8807f1dc3a47c5d037d152e36ed487adc92930a \
                            sha256  2f68f907653ea844e4dd73a356a07901a619ba6825e9b23b22b9890256983019 \
                            size    5904769
github.tarball_from         archive

patchfiles-append           patch-CMakeLists.diff

# https://github.com/eiskaltdcpp/eiskaltdcpp/pull/511
patchfiles-append           0001-Minor-fix-to-CLIENT_DATA_DIR-for-macOS.patch

depends_build-append        port:gettext \
                            port:git
depends_lib-append          port:bzip2 \
                            port:gettext-runtime \
                            port:jsoncpp \
                            port:libiconv \
                            port:libidn2 \
                            port:miniupnpc \
                            path:lib/pkgconfig/pango.pc:pango \
                            port:pcre2 \
                            port:sqlite3 \
                            port:zlib

# https://github.com/eiskaltdcpp/eiskaltdcpp/issues/508
conflicts_build             libunwind

configure.args-append       -DBUILD_STATIC=OFF \
                            -DCHECK_GTK_DEPRECATED=OFF \
                            -DDBUS_NOTIFY=OFF \
                            -DENABLE_STACKTRACE=OFF \
                            -DGETTEXT_SEARCH_PATH=${prefix}/bin \
                            -DHAIKU_PKG=OFF \
                            -DINSTALL_RUNTIME_PATH=ON \
                            -DJSONRPC_DAEMON=ON \
                            -DLOCAL_ASPELL_DATA=OFF \
                            -DLOCAL_JSONCPP=OFF \
                            -DLUA_SCRIPT=OFF \
                            -DNO_UI_DAEMON=OFF \
                            -DPERL_REGEX=ON \
                            -DUSE_ASPELL=OFF \
                            -DUSE_CCACHE=OFF \
                            -DUSE_CLI_JSONRPC=ON \
                            -DUSE_CLI_XMLRPC=OFF \
                            -DUSE_GTK=OFF \
                            -DUSE_GTK3=OFF \
                            -DUSE_IDN2=ON \
                            -DUSE_JS=OFF \
                            -DUSE_LIBCANBERRA=OFF \
                            -DUSE_LIBGNOME2=OFF \
                            -DUSE_LIBNOTIFY=OFF \
                            -DUSE_MINIUPNP=ON \
                            -DUSE_PROGRESS_BARS=ON \
                            -DUSE_QT=OFF \
                            -DUSE_QT_QML=OFF \
                            -DUSE_QT5=OFF \
                            -DUSE_XATTR=OFF \
                            -DWITH_DEV_FILES=ON \
                            -DWITH_DHT=ON \
                            -DWITH_EMOTICONS=ON \
                            -DWITH_EXAMPLES=OFF \
                            -DWITH_LUASCRIPTS=OFF \
                            -DWITH_SOUNDS=ON \
                            -DXMLRPC_DAEMON=OFF

compiler.cxx_standard       2014

variant qt4 conflicts qt5 description "Build with Qt4 GUI" {
    PortGroup               qt4 1.0

    # https://github.com/eiskaltdcpp/eiskaltdcpp/issues/501
    patchfiles-append       patch-mac-qt4.diff

    configure.args-replace  -DUSE_QT=OFF -DUSE_QT=ON
}

variant qt5 conflicts qt4 description "Build with Qt5 GUI" {
    PortGroup               qt5 1.0

    qt5.depends_component   qtmultimedia qttools

    configure.args-replace  -DUSE_QT5=OFF -DUSE_QT5=ON
}

if {${os.platform} eq "darwin" && ${os.major} < 20} {
    default_variants-append +qt4
} else {
    default_variants-append +qt5
}

post-destroot {
    xinstall -d ${destroot}${applications_dir}/${name}
    move ${destroot}${prefix}/${name}.app ${destroot}${applications_dir}/${name}
    # FIXME: this builds fine but does not run:
    # move ${destroot}${prefix}/eiskaltdcpp-daemon.app ${destroot}${applications_dir}/${name}
}
