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

github.setup        alperakcan fuse-ext2 0.0.11 v
revision            0
categories          fuse
platforms           macosx
license             GPL-2
maintainers         nomaintainer
description         Fuse-ext2 is a multi OS FUSE module to mount ext2, ext3 and ext4 file system devices
long_description    {*}${description}.
checksums           rmd160  fd76de72117e995b62a225f31828d3adf332ffb1 \
                    sha256  a2c202f1fa53a2b306dcef3fa958840fe3efb384449123e93fea89d82183384c \
                    size    123410
github.tarball_from archive
supported_archs     ppc

# https://github.com/alperakcan/fuse-ext2/issues/102
patchfiles          patch-darwin.diff

patchfiles-append   patch-fix-macOS.diff

# FIXME: https://github.com/alperakcan/fuse-ext2/issues/150
post-extract {
    foreach f {fuse-ext2.install fuse-ext2.uninstall fuse-ext2.wait} {
        move ${worksrcpath}/fuse-ext2/${f}.m ${worksrcpath}/fuse-ext2/${f}.c
    }
}
patchfiles-append   patch-libtool.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/fuse-ext2/Makefile.am
}

use_autoreconf      yes

depends_build-append \
                    port:m4 \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:e2fsprogs \
                    port:libcomerr

variant universal   { }

if {${os.platform} eq "darwin" && ${configure.build_arch} in [list ppc ppc64]} {
    configure.args-append \
                    --build=powerpc-apple-darwin${os.major}
}

# https://github.com/alperakcan/fuse-ext2/issues/151
if {[string match macports-gcc* ${configure.compiler}]} {
    configure.cflags-append \
                    -Wno-error=incompatible-pointer-types
}
