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

name                haproxy
version             2.9.1
revision            0

set branch          [join [lrange [split ${version} .] 0 1] .]

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/
master_sites        ${homepage}download/${branch}/src/ \
                    https://sources.openwrt.org/

checksums           rmd160  b4c62e2cbaee7703cb53cdaec27ed35449881044 \
                    sha256  d5801c772aab9c43f40964b7b33b4388d14b5b45750be4d2671785863cdb9f1c \
                    size    4493103

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_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.type      regex
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
