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

# Pin ifuse version on older systems; upstream no longer supports FUSE2
# Support for older versions possible with a patch
# See: https://github.com/libimobiledevice/ifuse/issues/112
if {${os.platform} eq "darwin" && ${os.major} > 16} {
    set upstream_version    1.2.1
    set macports_revision   0
} else {
    set upstream_version    1.1.4
    set macports_revision   1
}

github.setup            libimobiledevice ifuse ${upstream_version}
github.tarball_from     releases
revision                ${macports_revision}
categories              fuse devel
license                 LGPL-2.1
maintainers             {@TheRealKeto gmail.com:therealketo} openmaintainer
description             A fuse filesystem to access the contents of iOS devices
long_description        {*}${description}.

homepage                https://libimobiledevice.org/

if {${os.platform} eq "darwin" && ${os.major} > 16} {
    checksums           rmd160  b7a162a93d2bb39e4d228ee4cdc3d9bf3e0476dd \
                        sha256  9d490470ba6553f8052b385bb5330462e46fbe82131ebe65be47a1cc1c70e857 \
                        size    303329
} else {
    checksums           rmd160  03c646a374a2724db9eed0e4ffbe6acbc9fa5062 \
                        sha256  3550702ef94b2f5f16c7db91c6b3282b2aed1340665834a03e47458e09d98d87 \
                        size    94137
}

use_bzip2               yes

depends_lib-append      path:lib/pkgconfig/glib-2.0.pc:glib2 \
                        port:libimobiledevice \
                        port:libplist

configure.args          --disable-silent-rules

if {${os.platform} eq "darwin" && ${os.major} > 16} {
    # ifuse 1.2.1+ uses FUSE3 headers and flags, not fuse
    configure.cflags-delete \
                        -I${prefix}/include/fuse
    configure.cppflags-delete \
                        -I${prefix}/include/fuse
}

post-destroot {
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/COPYING ${destroot}${prefix}/share/doc/${name}
}
