# -*- 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           openssl 1.0
PortGroup           legacysupport 1.1
PortGroup           makefile 1.0

github.setup        haproxy haproxy 3.4.0 v
github.tarball_from archive
revision            0

categories          net
maintainers         {gmail.com:jeremy.mcmillan @aphor} \
                    {judaew @judaew} \
                    openmaintainer
license             {GPL-2+ OpenSSLException}

description         The Reliable, High Performance TCP/HTTP Load Balancer
long_description    HAproxy is a high-performance and highly-robust TCP/HTTP \
                    load balancer which provides cookie-based persistence, \
                    automatic failover, header insertion, deletion, \
                    modification on the fly, advanced logging contents to \
                    help trouble-shooting buggy applications and/or networks, \
                    and a few other features. It uses its own state machine \
                    to achieve up to ten thousands hits per second on modern \
                    hardware, even with thousands simultaneous connections.
homepage            https://www.haproxy.org/

checksums           rmd160  335d869d8a257834c18a3db2b147109d8fbb27a6 \
                    sha256  72ee779970afaba4632151ffd93a5c2494c96d35aa7fc2c01335eca3af8a98fc \
                    size    5504857

openssl.branch      3
depends_lib         port:pcre port:zlib

# https://trac.macports.org/ticket/65699
compiler.thread_local_storage yes

patchfiles-append   patch-older_systems.diff

installs_libs       no

# Disable compiler wrapping
compwrap.compilers_to_wrap

build.target        TARGET=osx

configure.cflags-append "-fwrapv"
makefile.override   PREFIX \
                    CC \
                    LD \
                    CFLAGS \
                    LDFLAGS

build.args-append   SSL_INC=[openssl::include_dir] \
                    SSL_LIB=[openssl::lib_dir] \
                    USE_LIBCRYPT=1 \
                    USE_OPENSSL=1 \
                    USE_PCRE=1 \
                    USE_PCRE_JIT=1 \
                    USE_PROMEX=1 \
                    USE_THREAD=1 \
                    USE_ZLIB=1

if {${os.platform} eq "darwin" && ${os.major} < 15} {
    build.args-append   USE_TFO=0
}

variant lua description {Build with Lua support} {
    PortGroup           lua 1.0

    build.args-append   USE_LUA=1 \
                        LUA_LIB_NAME=lua${lua.version} \
                        LUA_INC=${lua.include}
}

destroot.args           DOCDIR=${prefix}/share/doc/${name}

destroot.keepdirs       ${destroot}${prefix}/etc/haproxy

startupitem.create      yes
startupitem.executable  ${prefix}/sbin/haproxy -f ${prefix}/etc/haproxy

notes "
The configuration files (and only files) in ${prefix}/etc/haproxy are loaded in\
lexical order; only non hidden files with .cfg extension are added.

Adjust these files to your needs before starting haproxy with the startup item.
"

livecheck.regex     {/tag/v(\d+\.\d+\.\d+)(?![-.])}
