# -*- 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.2.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  68b83661dedf3556a323b0b000b4f49ae023c3f4 \
                    sha256  531f419b23b8219e2fe97ae9e4598fb2169c39ffff98174f200581f7931824dd \
                    size    54433

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 98c9f7055ec1f2e09fac69ef1413a8757113b838
    version         20230512
    revision        0

    checksums       rmd160  4bf7617ae0c5a80955bea47be868e5a87d722d25 \
                    sha256  786cf39de1d9ee53e9f177d60ef012883b0fe09e3d81dd29c800dc677652eb70 \
                    size    46731

    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
}