# -*- 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       github 1.0
PortGroup       muniversal 1.0

github.setup    libass libass 0.17.4
github.tarball_from archive
revision        0
conflicts       libass-devel

checksums       rmd160  c210290baf7a9791b135759e4ba4844db7fb7fb2 \
                sha256  c287d180d93dc9c9021872574b618ac49027e84cc90e1289318b1ee68bb42251 \
                size    341543

categories      multimedia
license         ISC
maintainers     nomaintainer
description     Subtitle renderer for the ASS/SSA subtitle format

long_description \
    libass is a portable subtitle renderer for the ASS/SSA \
    (Advanced Substation Alpha/Substation Alpha) subtitle \
    format. It is mostly compatible with VSFilter.

subport libass-devel {
    github.setup        libass libass 6a759836e5e76bb7b69b0ac244eea76b0d290512
    version             2024.10.14
    revision            0
    conflicts           libass
    checksums           rmd160  09c039d0ce8b6f13cef671c22dd1e306310d9039 \
                        sha256  5473c90b42fc0407529c2bba015815c89512a38f1cc4dcc9c5b44fd7cac72d3b \
                        size    334496
    github.tarball_from archive
}

depends_build   port:m4 \
                port:nasm \
                path:bin/pkg-config:pkgconfig

depends_lib     path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                port:fontconfig \
                port:fribidi

use_autoreconf  yes

configure.args  --disable-silent-rules \
                --enable-fontconfig

# ass.h:421: error: wrong number of arguments specified for 'deprecated' attribute
compiler.blacklist-append *gcc-3.* *gcc-4.*

if {${universal_possible} && [variant_isset universal]} {
    # Needed by configure to correctly set the yasm build flags.
    set merger_host(arm64)  "aarch64-apple-${os.platform}${os.major}.${os.minor}.0"
    set merger_host(i386)   "i386-apple-${os.platform}${os.major}.${os.minor}.0"
    set merger_host(ppc)    "powerpc-apple-${os.platform}${os.major}.${os.minor}.0"
    set merger_host(ppc64)  "powerpc64-apple-${os.platform}${os.major}.${os.minor}.0"
    set merger_host(x86_64) "x86_64-apple-${os.platform}${os.major}.${os.minor}.0"

    # I don't feel safe using a *86* match here. Who knows what other arch could
    # be matching in the future.
    if {"i386" in ${configure.universal_archs} ||
        "x86_64" in ${configure.universal_archs}} {
        depends_build-append port:yasm
    }
    lappend merger_configure_args(i386)     --enable-asm
    lappend merger_configure_args(x86_64)   --enable-asm
    lappend merger_configure_env(i386)      LDFLAGS=-Wl,-read_only_relocs,suppress
} else {
    if {${configure.build_arch} in "i386 x86_64"} {
        depends_build-append    port:yasm
        configure.args-append   --enable-asm
    }
    if {${configure.build_arch} eq "i386"} {
        configure.ldflags-append -Wl,-read_only_relocs,suppress
    }
    if {${configure.build_arch} eq "ppc"} {
        # https://trac.macports.org/ticket/65860
        compiler.blacklist-append   clang
        # This is necessary if MacPorts itself is built for x86,
        # but the build is for ppc via Rosetta.
        configure.args-append       --build=powerpc-apple-${os.platform}${os.major}
    }
}

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} COPYING Changelog README.md ${destroot}${docdir}
}
