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

github.setup        emeryberger Hoard cabdfad7c360c9dbb1ad76e52abd8419eea0c956
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                hoard
version             3.13
revision            0
categories          devel
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             Apache-2
homepage            http://hoard.org
description         A drop-in replacement for malloc that is very fast on multiprocessor machines
long_description    {*}${description}

checksums           rmd160  25653304c1cdd43ece0c4463ae33da430632feb3 \
                    sha256  4e6fef8087356be036d7cc584b91a0c0fdebc1c3f92c3e05cdc93fb816bd06b6 \
                    size    183940

build.dir           ${worksrcpath}/src

depends_build-append    port:git
git.cmd                 ${prefix}/bin/git

post-extract {
    delete ${build.dir}/Makefile
}

patchfiles-append   0001-Simplify-target-for-Darwin.patch \
                    0002-patch-test.diff

post-patch {
    reinplace "s|@ARCHFLAGS@|[get_canonical_archflags cxx]|g" ${build.dir}/GNUmakefile
    reinplace "s|@CC@|${configure.cc}|" ${build.dir}/test/Makefile
    reinplace "s|@CXX@|${configure.cxx}|" ${build.dir}/test/Makefile
    move ${build.dir}/GNUmakefile ${build.dir}/Makefile
}

build.target        Darwin

compiler.cxx_standard 2014

post-build {
    system "install_name_tool -id ${prefix}/lib/libhoard.dylib ${build.dir}/libhoard.dylib"
}

destroot {
    xinstall -m 755 ${build.dir}/libhoard.dylib ${destroot}${prefix}/lib/libhoard.dylib
}

test {
    system -W ${build.dir} "/bin/sh ./test.sh"
}

test.run            yes