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

# O_CLOEXEC
legacysupport.newest_darwin_requires_legacy 10
legacysupport.redirect_bins lms lms-metadata lms-recommendation

boost.version       1.81

github.setup        epoupon lms 3.62.1 v
revision            0

categories          audio multimedia www
license             GPL-3
maintainers         nomaintainer

description         Lightweight Music Server
long_description    LMS is a self-hosted music streaming software: \
                    access your music collection from anywhere using a web interface.
homepage            https://lms-demo.poupon.dev
checksums           rmd160  8e823bc11ada346ba7fbd4b3cb90bf9ca2d46fb4 \
                    sha256  bdf25bdb09bca581074ff9bc533bfdc064a94963a18e4f0248551061bb8cf9c3 \
                    size    474191
github.tarball_from archive

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

depends_lib-append  port:ffmpeg \
                    port:libarchive \
                    port:libconfig-hr \
                    port:stb \
                    port:taglib \
                    port:wt

# https://github.com/epoupon/lms/issues/525
patchfiles-append   0001-Fix-lms.conf-path.patch

post-patch {
    reinplace "s|@PREFIX@|${prefix}|" \
                    ${worksrcpath}/src/libs/core/include/core/SystemPaths.hpp
}

configure.args-append \
                    -DBUILD_BENCHMARKS=OFF \
                    -DENABLE_TESTS=OFF

# https://github.com/epoupon/lms/issues/526
if {${os.platform} eq "darwin" && ${os.major} < 24} {
    compiler.blacklist-append \
                    {macports-clang-1[8-9]}
}

compiler.cxx_standard   2020

post-destroot {
    xinstall -d ${destroot}${prefix}/etc/${name}
    xinstall -d ${destroot}${prefix}/var/${name}
    reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${prefix}/share/lms/lms.conf
}

post-activate {
    if {![file exists ${prefix}/etc/lms.conf]} {
        copy ${prefix}/share/lms/lms.conf ${prefix}/etc/lms.conf
    }
}

notes "
You may want to edit config settings in ${prefix}/etc/lms.conf
"
