# -*- 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           ffmpeg 1.0

name                moc
version             2.6-alpha3
revision            12
license             GPL-2
categories          multimedia
maintainers         nomaintainer
description         MOC (music on console) is a console audio player for LINUX/UNIX
long_description    MOC (music on console) is a console audio player for LINUX/UNIX \
                    designed to be powerful and easy to use. \
                    Internet stream (Icecast, Shoutcast) are supported, \
                    key mapping can be fully customized. \
                    Supported file formats are: mp3, Ogg Vorbis, FLAC, Musepack, Speex, WAVE, \
                    AIFF, AU (and other less popular formats supported by libsndfile).

homepage            http://moc.daper.net
master_sites        http://ftp.daper.net/pub/soft/moc/unstable/

checksums           rmd160  d56a53b67438d397f309a1e07f42ac3b4b3550be \
                    sha256  a27b8888984cf8dbcd758584961529ddf48c237caa9b40b67423fbfbb88323b1 \
                    size    496676

use_xz              yes

ffmpeg.version      4

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

depends_lib-append  port:curl \
                    port:faad2 \
                    port:flac \
                    port:jack \
                    port:libiconv \
                    port:libid3tag \
                    port:libmad \
                    port:libmagic \
                    port:libmodplug \
                    port:libogg \
                    port:libsamplerate \
                    port:libsndfile \
                    port:libvorbis \
                    port:musepack \
                    port:ncurses \
                    port:popt \
                    path:lib/libspeex.dylib:speex \
                    port:taglib \
                    port:wavpack

patchfiles          patch-ffmpeg-4.0.diff \
                    patch-tags-cache.diff

post-patch {
    reinplace {s|AC_CHECK_LIB(\[rt], \[clock_gettime]|AC_SEARCH_LIBS([clock_gettime], [rt]|} \
        ${worksrcpath}/configure.in
}

use_autoreconf      yes
autoreconf.args     -fvi

configure.args-append \
                    --disable-cache \
                    --with-jack \
                    --without-sidplay2

configure.cppflags-append \
                    -D_DARWIN_C_SOURCE

if {[string match *clang* ${configure.compiler}]} {
    configure.cflags-append \
                    -Wno-error=unused-but-set-parameter
}

# Old jack1 requires Berkley DB, and unless moc
# is pointed to it, the build fails:
# Undefined symbols: "_db_strerror"
if {${configure.cxx_stdlib} ne "libc++"} {
    set bdb_v       60

    depends_lib-append \
                    port:db${bdb_v}

    # Configure arg is there, but does not really work.
    configure.args-append \
                    --with-bdb-dir=${prefix}/lib/db${bdb_v}

    # So we need explicit flags:
    configure.cflags-append \
                    -I${prefix}/include/db${bdb_v}
    configure.ldflags-append \
                    -L${prefix}/lib/db${bdb_v} -ldb
}

livecheck.regex     ">${name}-\(\.*\)\.tar"
