# -*- 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           compilers 1.0
PortGroup           xcode_workaround 1.0
PortGroup           openssl 1.0

github.setup        wg wrk 4.2.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0

categories          net
license             Apache-2
maintainers         @jlopezr openmaintainer
description         wrk HTTP benchmarking tool
long_description    wrk is a modern HTTP benchmarking tool with optional LuaJIT HTTP request generation.
homepage            https://github.com/wg/wrk

checksums           rmd160  2ad5bca5cc3aa3486b67fae2bd99a4e31ed9fade \
                    sha256  74e61fc31c8e4ddac7a20d3dc54b59dbf5401d659fdd03d5222566587812f988 \
                    size    10973435

depends_build-append \
                    port:perl5

depends_lib-append  port:luajit

pre-configure {
    reinplace "s|WITH_LUAJIT)/include|WITH_LUAJIT)/include/luajit-2.1|g" \
            ${worksrcpath}/Makefile
}

# https://trac.macports.org/ticket/59346
xcode_workaround.type \
                    append_to_compiler_name

build.args-append   CC="${configure.cc}" \
                    CXX="${configure.cxx}" \
                    CPP=${configure.cpp} \
                    VER=${version}

build.target-append WITH_LUAJIT=${prefix} \
                    WITH_OPENSSL=[openssl::install_area]

# Avoid configure phase
use_configure       no

# wrk make fails with parallel build
use_parallel_build  no

# No make install so copy static binary to bin dir
destroot {
    xinstall ${worksrcpath}/wrk ${destroot}${prefix}/bin/wrk
}
