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

name                unar
version             1.10.1
revision            1
categories          archivers
platforms           darwin
license             LGPL-2.1+
maintainers         {l2dy @l2dy} openmaintainer
description         command-line unarchiver
long_description    ${description}
homepage            https://theunarchiver.com/command-line
master_sites        https://wakaba.c3.cx/releases/TheUnarchiver/
distname            ${name}${version}_src
use_zip             yes

checksums           rmd160  9dd2645fc75dfa4534caa6bc26735a5d41c8e1dd \
                    sha256  40967014a505b7a27864c49dc3b5d30b98ae4e6d4873783b2ef9ef9215fd092b

worksrcdir          "The Unarchiver"

post-patch {
    if {${configure.cxx_stdlib} eq "libc++"} {
        reinplace "s|libstdc++.6.dylib|libc++.1.dylib|g" ${worksrcpath}/XADMaster/XADMaster.xcodeproj/project.pbxproj
    }
}

xcode.project           "XADMaster/XADMaster.xcodeproj"
xcode.target            "unar" "lsar"
xcode.configuration     "Release"
xcode.destroot.path     "${prefix}/bin"
xcode.build.settings    "SYMROOT=../"
xcode.destroot.settings ${xcode.build.settings}

post-destroot {
    foreach f {libUniversalDetector.a libXADMaster.a} {
        move ${destroot}${prefix}/bin/${f} ${destroot}${prefix}/lib/${f}
    }

    set completions_path ${destroot}${prefix}/share/bash-completion/completions
    xinstall -d ${completions_path}
    foreach f {unar lsar} {
        xinstall -m 644 ${worksrcpath}/Extra/${f}.1 \
            ${destroot}${prefix}/share/man/man1
        xinstall -m 644 ${worksrcpath}/Extra/${f}.bash_completion \
            ${completions_path}/${f}
    }
}

livecheck.regex     unar(\\d+(?:\\.\\d+)*)_src${extract.suffix}
