# -*- 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.56.0 v
revision            0

categories          audio www
license             GPL-3
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

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  b34a7a3178852785bfa62205882fb29624906371 \
                    sha256  0270838187528de88e61d0da5d4a68614a6b66140752090f930071f01935557f \
                    size    440559
github.tarball_from archive

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

pre-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${filespath}/0002-Fix-lms.conf-path.patch
}

# https://github.com/epoupon/lms/issues/514
patchfiles-append   777c36005bdcdc09e1813a84f3f2c0acc0b47fac.patch

# https://github.com/epoupon/lms/pull/524
patchfiles-append   0001-CMakeLists-do-not-use-Linux-ldflag-on-macOS.patch

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

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

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
"
