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

name                    freeradius
version                 3.0.21
revision                33
categories              sysutils
maintainers             nomaintainer
platforms               darwin freebsd
license                 LGPL-2.1+
use_bzip2               yes
distname                ${name}-server-${version}

description             Free Radius Implementation
long_description        The FreeRADIUS Server Project is an attempt to create \
                        a high-performance and highly-configurable GPLd free \
                        RADIUS server. The server is similar to Livingston's \
                        2.0 server. FreeRADIUS is a variant of the Cistron \
                        RADIUS server, but they don't share a lot in common \
                        anymore.
homepage                https://freeradius.org
master_sites            ftp://ftp.freeradius.org/pub/freeradius/ \
                        ftp://ftp.freeradius.org/pub/freeradius/old
checksums               rmd160  04a038b701f19d9c598e826a795a0cdaacd3768b \
                        sha256  c22dad43954b0cbc957564d3f8cbb942ff09853852d2c2155d54e6bd641a4e7d \
                        size    3184588

# https://trac.macports.org/ticket/72324
patchfiles              patch-boiler.mk.diff

depends_build-append    port:gsed

depends_lib             port:gdbm \
                        port:libpcap \
                        port:libtool \
                        path:lib/libldap.dylib:openldap \
                        port:talloc

use_autoconf            yes

configure.args          --with-openssl-includes=[openssl::include_dir] \
                        --with-openssl-libraries=[openssl::lib_dir] \
                        --with-system-libltdl \
                        --with-system-libtool \
                        --without-rlm_krb5

compiler.blacklist-append \
                        *gcc-4.* {clang < 421}

use_parallel_build      no

# rlm_mschap/opendir.c:88:41: error: passing argument 5 of 'dsFindDirNodes' from incompatible pointer type [-Wincompatible-pointer-types]
# https://github.com/FreeRADIUS/freeradius-server/issues/5632
configure.cflags-append -Wno-error=incompatible-pointer-types
# rlm_python/rlm_python.c:241:33: error: implicit declaration of function 'PyFrame_GetLineNumber' [-Wimplicit-function-declaration]
configure.cflags-append -Wno-error=implicit-function-declaration

# Disable silent rules.
build.args-append       VERBOSE=1

destroot.env-append     R=${destroot}

variant kerberos description { Use Kerberos } {
    depends_lib-append port:kerberos5
    configure.args-delete --without-rlm_krb5
}

variant mysql51 conflicts mysql55 mysql56 mariadb percona description {Build with MySQL support using mysql51} {
    depends_lib-append port:mysql51
    configure.args-append \
                        --with-modules=rlm_sql \
                        --with-mysql-lib-dir=${prefix}/lib/mysql51/mysql \
                        --with-mysql-include-dir=${prefix}/include/mysql51
}

variant mysql55 conflicts mysql51 mysql56 mariadb percona description {Build with MySQL support using mysql55} {
    depends_lib-append port:mysql55
    configure.args-append \
                        --with-modules=rlm_sql \
                        --with-mysql-lib-dir=${prefix}/lib/mysql55/mysql \
                        --with-mysql-include-dir=${prefix}/include/mysql55
}

variant mysql56 conflicts mysql51 mysql55 mariadb percona description {Build with MySQL support using mysql56} {
    depends_lib-append port:mysql56
    configure.args-append \
                        --with-modules=rlm_sql \
                        --with-mysql-lib-dir=${prefix}/lib/mysql56/mysql \
                        --with-mysql-include-dir=${prefix}/include/mysql56
}

variant mariadb conflicts mysql51 mysql55 mysql56 percona description {Build with MySQL support using mariadb} {
    depends_lib-append port:mariadb
    configure.args-append \
                        --with-modules=rlm_sql \
                        --with-mysql-lib-dir=${prefix}/lib/mysql5/mysql \
                        --with-mysql-include-dir=${prefix}/include/mysql5
}

variant percona conflicts mysql51 mysql55 mysql56 mariadb description {Build with MySQL support using percona} {
    depends_lib-append port:percona
    configure.args-append \
                        --with-modules=rlm_sql \
                        --with-mysql-lib-dir=${prefix}/lib/percona/mysql \
                        --with-mysql-include-dir=${prefix}/include/percona
}

livecheck.type          regex
livecheck.url           [lindex ${master_sites} 0]
livecheck.regex         ${name}-server-(\[0-9.\]+)\\.tar
