# -*- 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           muniversal 1.1

name                jemalloc
license             BSD
categories          devel
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

description         a general-purpose scalable concurrent malloc(3) implementation
long_description    ${name} is {*}${description}

homepage            https://jemalloc.net

if {${subport} eq ${name}} {
    github.setup        jemalloc jemalloc 5.3.0
    revision            4
    conflicts           jemalloc-devel
    checksums           rmd160  ff8f2958d88705927b7566d219763dda2eb7edda \
                        sha256  2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa \
                        size    736023
    github.tarball_from releases
    use_bzip2           yes

    patchfiles-append   patch-quantum.diff \
                        patch-Makefile.diff

    # building as x86_64 on an arm64 Mac gives an error if rosetta is installed
    # https://trac.macports.org/ticket/65671
    patchfiles-append   patch-universal.diff
}

subport jemalloc-devel {
    github.setup        jemalloc jemalloc 21bcc0a8d49ab2944ae53c7e43f5c84fc8a34322
    version             2024.06.13
    conflicts           jemalloc
    checksums           rmd160  3f6a50650156258b62433b3ae1e7d9baac54d27b \
                        sha256  b2e736babf074e7fb9856ebf6b2315e5fc45b83d9682f74638ecd25813ee62e7 \
                        size    848719
    github.tarball_from archive

    use_autoreconf      yes
}

compiler.cxx_standard   2014

configure.args-append   --with-jemalloc-prefix=

# provide a compatibility symlink with the older name
post-destroot {
    ln -s jeprof ${destroot}${prefix}/bin/${name}-prof
}

test.run            yes
test.target         check
