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

# _getline
legacysupport.newest_darwin_requires_legacy 10

name                bindfs
version             1.18.4
revision            0

categories          fuse
license             GPL-2+
maintainers         {i0ntempest @i0ntempest} openmaintainer

description         Mirrors or overlays a local directory with altered permissions
long_description    ${name} is a FUSE filesystem for mirroring a directory to another \
                    directory, similarly to mount --bind. The permissions of \
                    the mirrored directory can be altered in various ways.

homepage            https://bindfs.org
master_sites        ${homepage}/downloads/

checksums           rmd160  0204b5630894b86715e72bc2e0ba4250452bedac \
                    sha256  3266d0aab787a9328bbb0ed561a371e19f1ff077273e6684ca92a90fedb2fe24 \
                    size    432774

# https://github.com/mpartel/bindfs/issues/169
patchfiles-append   patch-revert-3293dc98e37eed0fb0cbfcbd40434d3c37c69480.patch

# Fix a wrong flag:
post-patch {
    reinplace "s|-Wpedantic|-pedantic|" ${worksrcpath}/configure
}

configure.args-append \
                    --with-core-foundation \
                    --with-fuse2 \
                    --disable-macos-fs-link

configure.cflags-append \
                    -D_DARWIN_C_SOURCE
if {${os.platform} eq "darwin" && ${os.major} > 22} {
    if {[string match *clang* ${configure.compiler}]} {
        configure.cflags-append \
                    -Wno-error=incompatible-function-pointer-types
    }
}

# ___builtin_add_overflow
compiler.blacklist-append \
                    *gcc-4.*

variant fs_link description "Add a symlink to /Library/Filesystems, enables \'mount -t ${name}\' and /etc/fstab support" {
    configure.args-delete \
                    --disable-macos-fs-link

    destroot.violate_mtree \
                    yes
}
