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

PortSystem          1.0
PortGroup           cmake 1.1
PortGroup           github 1.0
PortGroup           boost 1.0
PortGroup           legacysupport 1.1

# strnlen
legacysupport.newest_darwin_requires_legacy 10

github.setup        VectorCamp vectorscan 5.4.11 vectorscan/
revision            0
categories          textproc
license             BSD
maintainers         nomaintainer
github.tarball_from archive
supported_archs     arm64 x86_64

description         A portable fork of the high-performance regular \
                    expression matching library.

long_description    {*}${description} It follows the regular \
                    expression syntax of the commonly-used libpcre \
                    library, but is a standalone library with its own \
                    C API.  Vectorscan uses hybrid automata techniques \
                    to allow simultaneous matching of large numbers \
                    (up to tens of thousands) of regular expressions \
                    and for the matching of regular expressions across \
                    streams of data.  Vectorscan is typically used in a \
                    DPI library stack.

homepage            https://www.vectorcamp.gr/project/vectorscan/

checksums           rmd160  f41a520f4cc5fe2eb4f1a35f8b68562c8136a59d \
                    sha256  905f76ad1fa9e4ae0eb28232cac98afdb96c479666202c5a4c27871fb30a2711 \
                    size    1895332

conflicts           hyperscan

# Use ${python.default_version}
# name consistency with ${prefix}/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/python-1.0.tcl
set python_default_version 313
set python_version  ${python_default_version}
set python_branch   [string index ${python_version} 0].[string range ${python_version} 1 end]

depends_build-append \
                    port:pkgconfig \
                    port:python${python_version} \
                    port:ragel

depends_lib-append \
                    port:pcre \
                    port:sqlite3

boost.version       1.81

compiler.cxx_standard   2023

# The flag `-DCMAKE_BUILD_TYPE=MacPorts` adds -Werror, which causes compile errors with -Wshadow
# Reference: https://github.com/intel/hyperscan/blob/master/CMakeLists.txt
cmake.build_type    Release

switch ${build_arch} {
    arm64 {
        configure.args-append \
                    -DARCH_AARCH64=On
    }
    x86_64 {
        configure.args-append \
                    -DARCH_X86_64=On \
                    -DBUILD_AVX512VBMI=On
    }
}

configure.args-append \
                    -DBUILD_SHARED_LIBS=On \
                    -DBUILD_STATIC_LIBS=Off \
                    -DPYTHON_EXECUTABLE=${prefix}/bin/python${python_branch}
