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

# _getline
legacysupport.newest_darwin_requires_legacy 10

github.setup    libarchive libarchive 3.8.7 v
revision        0
categories      archivers
license         BSD
maintainers     {toby @tobypeterson} openmaintainer
description     Functions for reading and writing streaming archives
long_description \
    Libarchive is a programming library that can create and \
    read several different streaming archive formats, including \
    most popular tar variants, several cpio formats, 7zip and rar. \
    It can also write shar archives.
homepage        https://libarchive.org
use_xz          yes
checksums       rmd160  f02b4e2df197f8b7810f11c4b939f0b9efc8fbb7 \
                sha256  d3a8ba457ae25c27c84fd2830a2efdcc5b1d40bf585d4eb0d35f47e99e5d4774 \
                size    6012112
github.tarball_from releases

# To build with Xcode gcc, without requiring C++11 in rdeps, drop libxml2:
depends_lib-append \
                port:bzip2 \
                port:libb2 \
                port:libiconv \
                port:libxml2 \
                port:lz4 \
                port:lzo2 \
                port:xz \
                port:zlib \
                port:zstd

patchfiles      fix_pc_file.patch

platform darwin 8 {
    patchfiles-append   patch-libarchive-3.5-fix-tests-tiger.diff
}

depends_build   path:bin/pkg-config:pkgconfig

configure.args  --disable-silent-rules \
                --enable-bsdcpio=shared \
                --enable-bsdtar=shared \
                --with-lzo2 \
                --with-zstd \
                --without-nettle \
                --without-openssl

configure.checks.implicit_function_declaration.whitelist-append strchr

post-destroot {
    xinstall -d ${destroot}${prefix}/libexec/${subport}
    foreach program [glob -tails -directory ${destroot}${prefix}/bin *] {
        ln -s ${prefix}/bin/${program} ${destroot}${prefix}/libexec/${subport}
    }
}

test.run        yes
test.target     check
