# -*- 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           github 1.0
PortGroup           openssl 1.0
PortGroup           legacysupport 1.1

github.setup        libimobiledevice libimobiledevice 1.4.0
github.tarball_from archive
revision            1

categories          devel

license             LGPL-2.1
maintainers         {ijackson @JacksonIsaac} {i0ntempest @i0ntempest} openmaintainer

description         A cross-platform software protocol library \
    and tools to communicate with iOS devices natively.

long_description    libimobiledevice is a cross-platform software \
    library that talks the protocols to support iPhone, iPod Touch, \
    iPad and Apple TV devices. Unlike other projects, it does not \
    depend on using any existing proprietary libraries and does not \
    require jailbreaking. It allows other software to easily access \
    the device's filesystem, retrieve information about the device \
    and it's internals, backup/restore the device, manage SpringBoard \
    icons, manage installed applications, retrieve addressbook/calendars \
    /notes and bookmarks and (using libgpod) synchronize music and video \
    to the device.

homepage            https://www.libimobiledevice.org/

checksums           rmd160  39b04ee9528c622611394f2f6ef86eb2d144bc10 \
                    sha256  99e042acc1513815c36816723de52e0d0892e081f36ec29672531ce99ed59ccd \
                    size    426246

depends_build-append \
                    port:autoconf \
                    port:automake \
                    port:libtool \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:libplist \
                    port:libtatsu \
                    port:libusbmuxd

# Undefined symbols "_environ", referenced from: _t_initrand in libsrp6a-sha512.a(t_misc.o)
# Remove after a new release or accomodate it when updating the devel port
patch.pre_args-replace \
                    -p0 -p1
patchfiles          0001-libsrp6a-sha512-fix-environ-for-Apple.patch

# _strnlen
legacysupport.newest_darwin_requires_legacy 10

pre-configure {
    system -W ${worksrcpath} "echo ${version} > .tarball-version"
}

configure.cmd       ./autogen.sh

# See: https://trac.macports.org/wiki/WimplicitFunctionDeclaration#AddnamestowhitelistviaPortfile
configure.checks.implicit_function_declaration.whitelist-append strchr

configure.args      --disable-silent-rules \
                    --without-cython

subport libimobiledevice-devel {
    github.setup    libimobiledevice libimobiledevice 1fb6b3d1eb64f29ec6d82662a3ca0f9161878017
    version         20251022
    revision        0

    checksums       rmd160  557cc8b2e5088af0c3f48b15c214418ad246767d \
                    sha256  b2ef89ec2799f1c0d6e4275c1f15058b3d7b26e77b3c25304311479c2fa29296 \
                    size    426593

    depends_lib-replace port:libusbmuxd port:libusbmuxd-devel
    depends_lib-replace port:libplist port:libplist-devel
    depends_lib-replace port:libtatsu port:libtatsu-devel

    conflicts       libimobiledevice

    livecheck.url   ${github.homepage}/commits/${github.livecheck.branch}.atom
}

if {${subport} eq ${name}} {
    conflicts       libimobiledevice-devel
}
