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

# posix_memalign
legacysupport.newest_darwin_requires_legacy 9

name                dav1d
# Please increase the revision of libheif, ffmpeg and ffmpeg-devel whenever
# dav1d's version is updated.
version             1.5.4
revision            0

checksums           rmd160  d695873234ac145285bfb9785a813888fd3af4bc \
                    sha256  686616b7c69eb88d44459391ab25cac13b6647a3b288835c5784e71c1514a5c5 \
                    size    1038852

categories          multimedia
license             BSD
maintainers         nomaintainer

description         small and fast AV1 decoder
long_description    dav1d is an AV1 decoder that is open-source, cross-platform and \
                    focused on speed, size and correctness.

homepage            https://www.videolan.org/projects/dav1d.html
set download_site   https://downloads.videolan.org/pub/videolan/${name}
master_sites        ${download_site}/${version}/
use_xz              yes

# nasm is not needed on arm64 platforms
if { ${build_arch} in "i386 x86_64" || [variant_isset universal] } {
    depends_build-append  port:nasm
}

# workaround meson change that causes configure to fail on older OS X versions
# see https://github.com/mesonbuild/meson/issues/8307
compiler.blacklist-append *gcc-3.* *gcc-4.*
compiler.blacklist-append { clang < 700 } macports-clang-3.3 macports-clang-3.4

configure.args-append \
                    -Denable_tests=false

variant test description {enable tests} {
    configure.args-replace  -Denable_tests=false -Denable_tests=true
    test.run                yes
    test.target             test
}

if {${universal_possible} && [variant_isset universal]} {
    lappend merger_configure_env(i386)      LDFLAGS=-Wl,-read_only_relocs,suppress,-no_compact_unwind
} elseif {${configure.build_arch} eq "i386"} {
    configure.env-append                LDFLAGS=-Wl,-read_only_relocs,suppress,-no_compact_unwind
}

# developer docs are automatically built if doxygen and dot (graphviz) are present
# but are not installed

set docdir              ${prefix}/share/doc/${name}

post-destroot {
    xinstall -m 0755 -d ${destroot}${docdir}

    xinstall -m 0644 -W ${worksrcpath} \
        CONTRIBUTING.md \
        COPYING \
        doc/dav1d_logo.png \
        NEWS \
        README.md \
        THANKS.md \
        ${destroot}${docdir}
}

livecheck.url       ${download_site}
livecheck.regex     {>([0-9.]+)/<}
