# -*- 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 b82333fdec6e5833f88780fcf1fc50b799268e1b
    version             2024.11.09
    conflicts           jemalloc
    checksums           rmd160  549ccb21289a1ef87e1bca317d8fc4c158b3d26c \
                        sha256  b804a1fcabf4943ddf1740b810d7f2e66ead74a0287e30afaeb8c5ff0b617002 \
                        size    858359
    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
