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

# On <10.15 built-in libc++ has no support for std::filesystem
legacysupport.newest_darwin_requires_legacy \
                                18
legacysupport.use_mp_libcxx     yes

github.setup                    complexlogic rsgain 3.6 v
revision                        0

categories                      audio
platforms                       {darwin all}
license                         GPL-2+

maintainers                     {gmail.com:lmkrawiec @lmkra} \
                                openmaintainer

description                     Really simple gain
long_description                ReplayGain 2.0 command line utility \
                                rsgain applies loudness metadata tags to your files, \
                                while leaving the audio stream untouched. \
                                A ReplayGain-compatible player will dynamically adjust \
                                the volume of your tagged files during playback.

github.tarball_from             releases
distname                        ${github.project}-${github.version}-source
use_xz                          yes
worksrcdir                      ${github.project}-${github.version}

checksums                       rmd160  c7c34aaa387206636a0cfdccde581e8233ace604 \
                                sha256  26d46f1240a83366e82cbc9121a467fc1dcc977c7adfb4e15c99ead6b3d07ec8 \
                                size    52168

depends_build-append            path:bin/pkg-config:pkgconfig

depends_lib-append              port:ffmpeg \
                                port:inih \
                                port:libebur128 \
                                port:taglib

configure.args-append           -DUSE_STD_FORMAT=ON

compiler.cxx_standard           2020

# Use libfmt9 until this is fixed:
# https://github.com/complexlogic/rsgain/issues/126
variant fmt description "Build with libfmt" {
    set libfmt_version          9

    depends_lib-append          port:libfmt${libfmt_version}

    configure.pkg_config_path   ${prefix}/lib/libfmt${libfmt_version}/pkgconfig

    configure.args-replace      -DUSE_STD_FORMAT=ON -DUSE_STD_FORMAT=OFF
}

# Notice, that gcc builds this without libfmt even on macOS 10.6.
# Clangs, however, do not. For now, just make +fmt default.
if {${os.platform} eq "darwin" && ${os.major} < 23} {
    default_variants-append     +fmt
}
