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

gitlab.setup            AOMediaCodec SVT-AV1 3.1.0 v
name                    [string tolower ${gitlab.project}]
revision                0
categories              multimedia
license                 BSD
maintainers             {i0ntempest @i0ntempest} openmaintainer

description             Scalable Video Technology for AV1
long_description        The Scalable Video Technology for AV1 (SVT-AV1 Encoder and Decoder) is an \
                        AV1-compliant software encoder/decoder library. The work on the SVT-AV1 encoder \
                        targets the development of a production-quality AV1-encoder with performance \
                        levels applicable to a wide range of applications, from premium VOD to \
                        real-time and live encoding/transcoding. The SVT-AV1 decoder implementation \
                        targets future codec research activities.

checksums               rmd160  1d70261a2ec1cc0a11cc5cf24313033c7bbd6a56 \
                        sha256  cb865cc90ad83ae57d4dc16c7495f9e324631dc3acfa512957e5e94eb8c080e6 \
                        size    10212725

# error: unknown type name '__m256i'
compiler.blacklist-append \
                        *gcc-4.8* *gcc-4.9* {clang < 500}
compiler.cxx_standard   2011

# _posix_memalign
legacysupport.newest_darwin_requires_legacy \
                        9

if {${os.arch} ne "powerpc"} {
    depends_build-append \
                        port:yasm
}

if {${os.platform} eq "darwin" && ${os.major} < 13} {
    # Lion+ (with Xcode 4.1+) have git; earlier need to bring their own.
    # On 10.8.5 git fetch fails with ssl error.
    depends_build-append    port:git
    git.cmd                 ${prefix}/bin/git
}

patchfiles              patch-no-dispatch-on-old-OS.diff \
                        patch-fix-native.diff

# never enable AVX512 by default
configure.args-append   -DENABLE_AVX512=OFF

post-destroot {
    ln -s SvtAv1EncApp ${destroot}${prefix}/bin/svtav1enc
    ln -s SvtAv1DecApp ${destroot}${prefix}/bin/svtav1dec
}

variant avx512 description "Build with AVX-512 asm files" {
    configure.args-replace \
                        -DENABLE_AVX512=OFF \
                        -DENABLE_AVX512=ON
}

variant native description "Optimize for CPU" {
    configure.args-append \
                        -DNATIVE=ON
}

gitlab.livecheck.regex {([0-9.]+)}
