# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           meson 1.0

set real_name       audacious
name                ${real_name}-core

# Please keep audacious, audacious-core and audacious-plugins synchronized.
version             4.6.1
revision            0
categories          audio
license             BSD
maintainers         {ionic @Ionic} \
                    {makr @mohd-akram} \
                    {@barracuda156 macos-powerpc.org:barracuda}
homepage            https://www.audacious-media-player.org
description         Audacious is an advanced audio player.
long_description    ${description} It is free, lightweight, based on GTK3, \
                    runs on Linux and many other *nix platforms. The player focuses on audio quality \
                    and supports a wide range of audio codecs. \
                    Its advanced audio playback engine is considerably more powerful than GStreamer. \
                    Audacious is a fork of Beep Media Player (BMP), which itself forked from XMMS.

# Maintainer-only helper for testing changes quickly and easily.
#fetch.type          git
#git.url             https://github.com/Ionic/${real_name}
#git.branch          ${real_name}-${version}-buildfix

master_sites        https://distfiles.audacious-media-player.org
distname            ${real_name}-${version}
use_bzip2           yes
checksums           rmd160  7fff509a81cd5f6bed8a16e73eac792ee9dedde1 \
                    sha256  62a5a609267eca7f6e3ce52ef6f42d5618d2961e3b4ddc227c6a5859026965d9 \
                    size    525741

universal_variant   no

depends_build-append \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libiconv

depends_run         port:dbus

compiler.c_standard     1999
compiler.cxx_standard   2017

configure.args      -Ddbus=true \
                    -Dgtk=false \
                    -Dgtk2=false \
                    -Dqt=false \
                    -Dqt5=false \
                    -Dvalgrind=false

#fix invalid conversion from 'char**' to 'const char**'
platform darwin 8 {
    configure.cxxflags-append -fpermissive
}

post-destroot {
    xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${real_name}
    move ${destroot}${prefix}/share/${real_name}/AUTHORS \
         ${destroot}${prefix}/share/${real_name}/COPYING \
         ${destroot}${prefix}/share/doc/${real_name}
}

variant qt5 description "Add Qt5 support" {
    PortGroup               qt5 1.0

    qt5.depends_component   qtsvg

    configure.args-replace  -Dqt=false \
                            -Dqt=true \
                            -Dqt5=false \
                            -Dqt5=true
}

variant qt6 description "Add Qt6 support" {
    PortGroup               qt6 1.0

    qt6.depends_lib         qtsvg

    # https://trac.macports.org/ticket/69214
    configure.pkg_config_path-append    [option qt6.dir]/lib/pkgconfig

    configure.args-replace  -Dqt=false \
                            -Dqt=true
}

variant gtk2 conflicts gtk3 description "Add GTK2 support" {
    depends_lib-append      path:lib/pkgconfig/gtk+-2.0.pc:gtk2

    configure.args-replace  -Dgtk=false \
                            -Dgtk=true \
                            -Dgtk2=false \
                            -Dgtk2=true
}

variant gtk3 conflicts gtk2 description "Add GTK3 support" {
    depends_lib-append      path:lib/pkgconfig/gtk+-3.0.pc:gtk3

    configure.args-replace  -Dgtk=false \
                            -Dgtk=true
}

# Need either one of gtk2, gtk3, Qt5 or Qt6 to have a GUI.
# Default to qt6, which is preferred by upstream.
if {![variant_isset gtk2] && ![variant_isset gtk3] && ![variant_isset qt5] && ![variant_isset qt6]} {
    # Fails to build on macOS - https://trac.macports.org/ticket/69214
    if {${os.platform} ne "darwin"} {
        default_variants-append +qt6
    } elseif {${os.platform} eq "darwin" && ${os.major} < 17} {
        default_variants-append +gtk3
    } else {
        default_variants-append +qt5
    }
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${real_name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
