# -*- 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

name                    freeradius
version                 3.2.10
revision                0
checksums               rmd160  ff6fa46a72c780aaf2415d014b65a8778eecead4 \
                        sha256  e30ce4b071ad4b48e7eb0c34c66324a32c2548cfc067900941a90f017dc174e3 \
                        size    3727834

categories              sysutils
maintainers             nomaintainer
homepage                https://freeradius.org
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.

master_sites            https://www.freeradius.org/ftp/pub/freeradius/ \
                        https://www.freeradius.org/ftp/pub/freeradius/old/

depends_lib             port:libpcap \
                        path:lib/libldap.dylib:openldap \
                        path:lib/libssl.dylib:openssl \
                        port:readline \
                        port:talloc \
                        port:gdbm

# Use OpenSSL 4 accessors for ASN1_STRING; builds against OpenSSL 3 too
# https://github.com/FreeRADIUS/freeradius-server/pull/5841
patchfiles              patch-openssl4.diff

# Modules whose dependencies are not declared are disabled explicitly so
# they don't get built opportunistically.
configure.args          --with-openssl-include-dir=${prefix}/include \
                        --with-openssl-lib-dir=${prefix}/lib \
                        --with-talloc-include-dir=${prefix}/include \
                        --with-talloc-lib-dir=${prefix}/lib \
                        --with-pcap-include-dir=${prefix}/include \
                        --with-pcap-lib-dir=${prefix}/lib \
                        --without-pcre \
                        --without-rlm_cache_memcached \
                        --without-rlm_cache_redis \
                        --without-rlm_couchbase \
                        --without-rlm_eap_ikev2 \
                        --without-rlm_eap_tnc \
                        --without-rlm_idn \
                        --without-rlm_json \
                        --without-rlm_kafka \
                        --without-rlm_krb5 \
                        --without-rlm_perl \
                        --without-rlm_python \
                        --without-rlm_python3 \
                        --without-rlm_redis \
                        --without-rlm_rediswho \
                        --without-rlm_rest \
                        --without-rlm_ruby \
                        --without-rlm_securid \
                        --without-rlm_sql_db2 \
                        --without-rlm_sql_firebird \
                        --without-rlm_sql_freetds \
                        --without-rlm_sql_iodbc \
                        --without-rlm_sql_mongo \
                        --without-rlm_sql_mysql \
                        --without-rlm_sql_oracle \
                        --without-rlm_sql_postgresql \
                        --without-rlm_sql_sqlite \
                        --without-rlm_sql_unixodbc \
                        --without-rlm_unbound \
                        --without-rlm_yubikey

use_parallel_build      no

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

destroot.env-append     R=${destroot}

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

# Each MySQL flavor installs its client library and headers in its own
# directory, so point rlm_sql_mysql at the selected one.
set mysql_variants {
    mysql51             mysql51     mysql51
    mysql55             mysql55     mysql55
    mysql56             mysql56     mysql56
    mysql8              mysql8      mysql8
    mysql9              mysql9      mysql9
    mysql_innovation    mysql-innovation mysql-innovation
    mariadb             mariadb     mysql5
}
set mysql_variant_names {}
foreach {v p d} ${mysql_variants} {
    lappend mysql_variant_names ${v}
}
foreach {v p d} ${mysql_variants} {
    set others [lsearch -all -inline -not -exact ${mysql_variant_names} ${v}]
    variant ${v} conflicts {*}${others} description "Build rlm_sql_mysql using ${p}" "
        depends_lib-append      port:${p}
        configure.args-delete   --without-rlm_sql_mysql
        configure.args-append   --with-mysql-include-dir=${prefix}/include/${d} \\
                                --with-mysql-lib-dir=${prefix}/lib/${d}/mysql
    "
}

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

notes "
If you are upgrading from FreeRADIUS 3.0.x, review your configuration in\
${prefix}/etc/raddb against the 3.2 release notes:\
https://freeradius.org/release_notes/?br=3.2.x
"
