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

# On <10.15 built-in libc++ has no support for std::filesystem
legacysupport.newest_darwin_requires_legacy 18
legacysupport.use_mp_libcxx                 yes

github.setup        cabinpkg cabin 0.13.0
revision            3
categories          sysutils devel
license             Apache-2
homepage            https://cabinpkg.com
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         Package Manager for C++
long_description    Poac is a package manager for C++, inspired by Cargo \
                    for Rust. Poac can download project's dependencies \
                    and compile a project.

# Until poac is retired.
conflicts           poac

github.tarball_from archive

checksums           rmd160  dfa4df12d4df5616259362e54825ba6e0e8676e7 \
                    sha256  f9115bb0566800beedb41106e00f44a7eaf1dea0fa6528281e31de5f80864177 \
                    size    93023

# cabin(16894) malloc: *** error for object 0xa04da754: pointer being freed was not allocated
# However, this is not strictly necessary, the app still works without a wrapper.
legacysupport.redirect_bins ${name}

makefile.override   CXXFLAGS LDFLAGS

patchfiles-append   patch-Makefile.diff

if {${configure.build_arch} in [list arm i386 ppc]} {
    post-patch {
        reinplace "s|TBB_VERREQ \:= tbb|TBB_VERREQ \:= tbb32|" ${worksrcpath}/Makefile
    }

    if {[string match *gcc* ${configure.compiler}]} {
        configure.ldflags-append \
                    -latomic
    }
}

set fmt_v           12

depends_build-append \
                    path:bin/git:git \
                    port:nlohmann-json \
                    path:bin/pkg-config:pkgconfig

configure.pkg_config_path-prepend \
                    ${prefix}/lib/libfmt${fmt_v}/pkgconfig \
                    ${prefix}/libexec/onetbb/lib/pkgconfig

depends_lib-append  port:curl \
                    port:libarchive \
                    port:libfmt${fmt_v} \
                    path:lib/pkgconfig/libgit2.pc:libgit2 \
                    port:onetbb \
                    port:spdlog

compiler.cxx_standard   2020
compiler.blacklist-append \
                    {clang < 1300}

configure.cxxflags-append \
                    -std=c++20

test.run            yes
