# -*- 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
# $Id: Portfile 90296 2012-03-01 00:56:09Z dports@macports.org $

PortSystem          1.0

name                fuse4x
version             0.9.0
revision            1
set tag             [string map {. _ } $version]
categories          fuse devel
platforms           macosx
maintainers         dports
description         A FUSE-Compliant File System Implementation Mechanism \
                    for Mac OS X

long_description    Fuse4X implements a mechanism that makes it          \
                    possible to implement a fully functional file        \
                    system in a user-space program on Mac OS X. It       \
                    aims to be API-compliant with the FUSE               \
                    (File-system in USErspace) mechanism that            \
                    originated on Linux.  Therefore, many existing       \
                    FUSE file systems become readily usable on Mac OS    \
                    X. This port provides the user-space library and     \
                    header files for building filesystems.

homepage            http://fuse4x.org/
license             LGPL
master_sites        https://github.com/fuse4x/fuse/tarball/fuse4x_${tag}

checksums           sha256  fde8676cf5d30e167d18860d24843fcf03f64202dd648f0b833f02c12f726964 \
                    rmd160  c9cd0ceec85e4a4a3d27d302be7147a6e29c9b2a

extract.mkdir       yes
extract.post_args   "| tar --strip-components=1 -xf -"

patchfiles          patch-include_fuse_param.h.diff

# kext destination: kext will be installed into ${kextdir}/fuse4x.kext.
#
# The kext is autoloaded by the library using load_fuse4x, so it
# doesn't have to go into /System/Library/Extensions. It doesn't
# matter where we put it, as long as it's kept in sync with the library.
#
# If updating the patchfile or ${kextdir}, must also update the
# corresponding patch in the fuse4x-kext port!
set kextdir        "${prefix}/Library/Extensions"
post-patch {
    reinplace "s|@@KEXTPATH@@|${kextdir}/fuse4x.kext|" ${worksrcpath}/include/fuse_param.h

    # Fuse4X normally installs its library as libfuse4x.dylib to allow
    # it to co-exist with MacFUSE, but the ports are conflicting so we
    # don't need to worry about that. Instead, we'll install it as
    # libfuse.dylib so dependent ports don't need to be modified.
    reinplace "s|-lfuse4x|-lfuse|" ${worksrcpath}/fuse.pc.in
    reinplace "s|libfuse4x|libfuse|g" ${worksrcpath}/lib/Makefile.am
    reinplace "s|libfuse4x.la|libfuse.la|" ${worksrcpath}/example/Makefile.am
}

configure.cflags-append -D_DARWIN_USE_64_BIT_INODE
configure.ldflags   -framework CoreFoundation

use_autoreconf      yes
autoreconf.args     -fi

depends_build       port:pkgconfig port:autoconf port:automake port:libtool
depends_run         port:fuse4x-kext

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     {Fuse4X-([0-9.]+).dmg}
