# -*- 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           gitlab 1.0
PortGroup           qt4 1.0

gitlab.setup        openconnect openconnect-gui f210cb56fe561cd25b1b5bc12bf40c3966a03046
version             1.6.2
revision            0
categories          net aqua
maintainers         {i0ntempest @i0ntempest} openmaintainer
license             GPL-2+

description         GUI client for openconnect VPN
long_description    ${description}

checksums           rmd160  01b5d4d41aec7662a0e33819b134a639a201b907 \
                    sha256  7c1298a5cda8b204b90996362126230b7bfdbc071b62239121d7f8d43c228bd8 \
                    size    1182282

patch.pre_args-replace  -p0 -p1
patchfiles-append   0001-Qt4-use-plain-enum-for-Logger-MessageType-ComponentT.patch \
                    0002-Qt4-replace-QStandardPaths-QSysInfo-buildCpuArchitec.patch \
                    0003-Qt4-convert-new-style-connect-calls-to-SIGNAL-SLOT-m.patch \
                    0004-Qt4-add-WITH_QT4-CMake-build-path.patch \
                    0005-Qt4-locate-QtSingleApplication-by-fixed-path-not-fin.patch \
                    0006-Qt4-derive-QtSingleApplication-paths-from-qmake-loca.patch \
                    0007-Qt4-add-explicit-includes-that-were-only-reaching-us.patch \
                    0008-Qt4-replace-QComboBox-currentData-with-itemData-curr.patch \
                    0009-Qt4-replace-QFileSelector-QIcon-setIsMask-and-qsizet.patch \
                    0010-Qt4-drop-clearButtonEnabled-property-from-NewProfile.patch \
                    0011-Qt4-replace-QStringLiteral-setCurrentText-QLatin1Str.patch \
                    0012-Qt4-replace-QCommandLineParser-with-a-hand-rolled-fa.patch \
                    0013-Qt4-replace-QGuiApplication-applicationDisplayName.patch \
                    0014-Qt4-fix-QUrl-url-Q_OS_MACOS-and-seeded-qHash.patch \
                    0015-Qt4-version-gate-QApplication-setSetuidAllowed.patch \
                    0016-Qt4-connectslotsbyname-fix.patch

# Match the version used in spdlog
set libfmt_ver      12

cmake.prefix_path-append \
                    ${prefix}/lib/libfmt${libfmt_ver}/cmake

depends_build-append \
                    path:bin/pkg-config:pkgconfig
depends_lib-append  path:lib/pkgconfig/gnutls.pc:gnutls \
                    port:libfmt${libfmt_ver} \
                    port:openconnect \
                    port:qtsingleapplication-qt4 \
                    port:spdlog
depends_run         port:vpnc-scripts

use_parallel_build  no

cmake.install_prefix \
                    ${applications_dir}
cmake.build_type    Release

compiler.cxx_standard   2017

configure.args-append \
                    -DWITH_QT4=ON

post-patch {
    reinplace "s|\${output}/../etc/vpnc/vpnc-script|${prefix}/etc/vpnc-scripts/vpnc-script|g" CMake/Modules/FindOpenConnect.cmake
    reinplace "s|^\[\[:space:\]\]*fixup_bundle(.*||" ${worksrcpath}/src/CMakeLists.txt
}

post-destroot {
    file rename \
        ${destroot}${applications_dir}/LICENSE.txt \
        ${destroot}${applications_dir}/OpenConnect-GUI.app/Contents/Resources
}

notes "
Note, you may need to run the app as root.
"
