# -*- 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.1
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  073dd39f1cfb959f81f6fa4f0dbef2440723dfcc \
                        sha256  64fe4a16a5622c1d71efe9ed7f2c2fbd37f8f237da9f11ff66b73038df71db91 \
                        size    65638226

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