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

github.setup            RetroShare libretroshare c54e0266e4483797c1d6bacee6f563979d683464
version                 2024.07.04
revision                0
categories              net devel security p2p
maintainers             {@barracuda156 gmail.com:vital.had} openmaintainer
license                 {AGPL-3 Apache-2 GPL-3 LGPL-3 MIT}
description             RetroShare is a decentralized, private, secure, cross-platform communication software.
long_description        {*}${description} RetroShare functionalities (file sharing, chat, messages, forums, channels…) \
                        are implemented under the hood by libretroshare which offer a documented C++ and JSON API. \
                        While RetroShare is an application on its own, libretroshare is meant to be used as part of other programs.
homepage                https://retroshare.cc
checksums               rmd160  f03f2e61f6c65135099f859611bd6c895d4ea5bc \
                        sha256  2cbe1c44e0e50f8c24e050a7049733fa0eba44ef5f2c5a4dd926ce9e8cf6817f \
                        size    1933162
github.tarball_from     archive

# getline, strnlen
# On <10.15 built-in libc++ has no support for std::filesystem
legacysupport.newest_darwin_requires_legacy 18
legacysupport.use_mp_libcxx                 yes

depends_lib-append      path:lib/pkgconfig/RapidJSON.pc:rapidjson \
                        port:bzip2 \
                        port:miniupnpc \
                        port:restbed \
                        port:sqlcipher \
                        port:zlib

set py_ver              3.11
set py_ver_nodot        [string map {. {}} ${py_ver}]

depends_build-append    path:bin/doxygen:doxygen \
                        bin:git:git \
                        port:pkgconfig \
                        port:python${py_ver_nodot}
git.cmd                 ${prefix}/bin/git

patchfiles              0001-Fix-CMakeLists-for-MacPorts.patch \
                        0002-rsdnsutils.patch

post-patch {
    reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/CMakeLists.txt
}

compiler.cxx_standard   2017
compiler.blacklist-append \
                        {clang < 1100}

# JSONAPI disabled until fixed: https://github.com/RetroShare/libretroshare/issues/149
configure.args-append   -DPython3_EXECUTABLE=${prefix}/bin/python${py_ver} \
                        -DRS_EXPORT_JNI_ONLOAD=OFF \
                        -DRS_JSON_API=OFF \
                        -DRS_LIBRETROSHARE_STANDALONE_INSTALL=ON \
                        -DRS_MINIUPNPC=ON \
                        -DRS_SQLCIPHER=ON \
                        -DRS_WARN_DEPRECATED=OFF

if {${os.platform} eq "darwin" && ${os.major} > 22} {
    # https://github.com/RetroShare/libretroshare/issues/122
    # https://trac.macports.org/ticket/68536
    patchfiles-append   0003-fix-xcode15.patch

    configure.args-append \
                        -DRS_XCODE15=ON
}
