# -*- 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                 fuse 1.0
PortGroup                 github 1.0
PortGroup                 cmake 1.1
PortGroup                 boost 1.0

github.setup              cryfs cryfs 0.11.4
revision                  3
github.tarball_from       releases

license                   LGPL-3

categories                fuse net
platforms                 darwin

maintainers               {@jolan78 gmail.com:jolan78} openmaintainer

description               Cryptographic filesystem for the cloud
long_description          CryFS encrypts your files, so you can safely store them anywhere.\
                          It works well together with cloud services like Dropbox, iCloud,\
                          OneDrive and others

homepage                  https://www.cryfs.org/

checksums                 rmd160  dc9eb50bad04492bb7b610066661492384665d76 \
                          sha256  6caca6276ce5aec40bf321fd0911b0af7bcffc44c3cb82ff5c5af944d6f75a45 \
                          size    10420289

extract.mkdir             yes

# This has to match the version of libfmt used by spdlog.
# See https://trac.macports.org/ticket/68248
set libfmt_ver            10
set python_branch         3.13
set python_version        [string map {. ""} ${python_branch}]
patchfiles                gitversion_python3_fix.diff
post-patch {
    reinplace "s|@@PYTHONBIN@@|${prefix}/bin/python${python_branch}|g" ${worksrcpath}/src/gitversion/gitversion.cmake
}

boost.version             1.81

depends_build-append      path:lib/libssl.dylib:openssl \
                          port:range-v3 \
                          port:python${python_version}

depends_lib-append        port:curl \
                          port:spdlog \
                          port:libomp \
                          port:libfmt${libfmt_ver}

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

cmake.build_type          Release
universal_variant         no

compiler.cxx_standard     2014
compiler.thread_local_storage \
                          yes

configure.args-append     -DBoost_USE_MULTITHREADED=on \
                          -DBoost_USE_STATIC_LIBS=off \
                          -DCRYFS_UPDATE_CHECKS=off \
                          -DDEPENDENCY_CONFIG=${worksrcpath}/cmake-utils/DependenciesFromLocalSystem.cmake

variant fs_link description "Link ${name} to a .fs bundle in /Library/Filesystems" {
    post-destroot {
        set dir /Library/Filesystems/${name}.fs/Contents/Resources
        xinstall -d ${destroot}${dir}
        ln -s ${prefix}/bin/${name} ${destroot}${dir}/mount_${name}
    }

    destroot.violate_mtree \
                        yes

    notes-append "
        With +fs_link, you may use \'mount -t ${name}\' and use ${name} in /etc/fstab.
    "
}
