# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           legacysupport 1.1
PortGroup           makefile 1.0

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup        davidesantangelo krep 3.0.0 v
revision            0
categories          textproc
installs_libs       no
license             BSD
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

description         High-Performance String Search Utility

long_description    \
    ${name} is a blazingly fast string search utility designed for \
    performance-critical applications. It implements multiple optimized \
    search algorithms and leverages modern hardware capabilities to deliver \
    maximum throughput.

checksums           rmd160  7f3cc6bdfc1f0e7eea06b2252626dff27ffaba78 \
                    sha256  78ed8e36051145d523c9a7be878f7af82bd26405ff28d1ebdcae07efe4c52fdf \
                    size    89770
github.tarball_from archive

# This flag should not be used, use -mtune=native.
post-patch {
    reinplace "s|-march=native ||" ${worksrcpath}/Makefile
}

compiler.c_standard 2011
# krep.h:15:10: fatal error: 'stdatomic.h' file not found
compiler.blacklist-append \
                    {clang < 700}

# github.com/davidesantangelo/krep/issues/40
if {[string match *gcc* ${configure.compiler}] && ${configure.build_arch} in [list arm i386 ppc]} {
    configure.ldflags-append \
                    -latomic
}

makefile.override   CC LDFLAGS

variant native description "Enable cpu optimizations" {
    build.args-append \
                    NATIVE=1
}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/
}
