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

github.setup        libimobiledevice libirecovery 1.3.1
revision            0
github.tarball_from archive

categories          devel

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

description         The libirecovery library allows communication with iBoot/iBSS of iOS devices via USB.

long_description    libirecovery is a cross-platform library which implements communication to \
                    iBoot/iBSS found on Apple's iOS devices via USB. A command-line utility \
                    named irecovery is also provided. This is a fork of an older version from \
                    former openjailbreak.org and is meant to be used with idevicerestore from \
                    the libimobiledevice project.

homepage            https://www.libimobiledevice.org/

conflicts           iRecovery

checksums           rmd160  3311582a12bfbe51b1edb27367dfba9c68b62c59 \
                    sha256  5d3064d0377a5338e1686e61fdb9f51b0b1bc9e6b982417a1aaf3f0fdfa69ccd \
                    size    56896

depends_build-append \
                    port:autoconf \
                    port:automake \
                    port:libtool \
                    port:pkgconfig

depends_lib         port:readline \
                    port:libimobiledevice-glue

# See https://github.com/libimobiledevice/libimobiledevice-glue/commit/0e7b8b42ce4cbeb32eb3103b0ff97916cb273d78
# remove after next release
pre-configure {
    system -W ${worksrcpath} "echo ${version} > .tarball-version"
}
configure.cmd       ./autogen.sh

subport libirecovery-devel {
    github.setup    libimobiledevice libirecovery b59ef4814525f487287da1609864f432cd79e3ed
    version         20251018
    revision        0

    checksums       rmd160  8f76bac14bbd4a1bb894033044a0e6fe51252c12 \
                    sha256  97d5549bdddc00b0db6e9b11ae9df4cebcc262ff409d1f4d6555548bdfefd411 \
                    size    56926

    conflicts       libirecovery

    depends_lib-replace \
                    port:libimobiledevice-glue \
                    port:libimobiledevice-glue-devel

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

# libirecovery will still link with IOKit, but libusb will be priority
variant libusb description {Use libusb over IOKit.framework when linking} {
    depends_lib-append      path:lib/pkgconfig/libusb-1.0.pc:libusb
    configure.args          --with-iokit=no
}

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