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

name                    clamav
conflicts               clamav-legacy
version                 1.5.3
revision                0
categories              sysutils
platforms               {darwin > 10}
maintainers             {geeklair.net:dluke @danielluke}
description             ClamAV antivirus software
license                 {GPL-2 OpenSSLException}

long_description        Clam AntiVirus is a GPL anti-virus toolkit for UNIX. \
                        The main purpose of this software is the integration \
                        with mail servers (attachment scanning).

homepage                https://www.clamav.net
master_sites            https://www.clamav.net/downloads/production
checksums               rmd160  fa0e9d81dda3d327b6271747ba5c2eb5023e9fe2 \
                        sha256  89af57a45bbf13de4dc91ed7f20b435388c88428eb7dc30639a02b2f0fc2dad1 \
                        size    63805884

# Disable tests to avoid extra dependencies
configure.args-append   -DENABLE_TESTS=OFF

depends_build-append    bin:git:git \
                        port:cargo \
                        port:pkgconfig \
                        port:rust

depends_lib-append      path:lib/libssl.dylib:openssl \
                        port:bzip2 \
                        port:curl \
                        port:json-c \
                        port:libiconv \
                        port:libtool \
                        port:libxml2 \
                        port:ncurses \
                        port:pcre2 \
                        port:zlib

variant clamav_milter description {Build with libmilter support} {
    depends_lib-append      port:libmilter
    configure.args-append   -DENABLE_MILTER=ON
}

pre-test {
    if {![variant_isset tests]} {
        ui_error "'tests' variant must be activated to enable test support"
        error "Please enable the 'tests' variant and try again"
    }
}

variant tests description {Enable running 'port test'} {
    ui_msg "Tests run using the installed version of this port."

    depends_test-append \
                    port:check \
                    port:py312-pytest

    configure.args-delete \
                    -DENABLE_TESTS=OFF
    configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

    test.run        yes
    test.cmd        ctest
    test.target     --rerun-failed --output-on-failure
}

livecheck.type      regex
livecheck.url       https://www.clamav.net/downloads
livecheck.regex     ${name}-(\\d+.\\d+.\\d+)${extract.suffix}
