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

# strnlen, clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup            mywave82 opencubicplayer 3.0.1 v
revision                1
checksums               rmd160  e49b75d4ffbcfb71fde7fd3eef32abfcb9e5b063 \
                        sha256  60a03d73883ea9c5dd94253907fc2002aa229e0fc41febb17d7baa341b228db1 \
                        size    4361096

name                    ocp
categories              audio
maintainers             {ryandesign @ryandesign} openmaintainer
license                 GPL-2+

description             OpenCubicPlayer - Music visualizer

long_description        {*}${description} for various tracked music formats \
                        (amiga modules, S3M, IT), chiptunes and other formats \
                        related to demoscene

github.tarball_from     releases
distname                ${name}-${version}
use_xz                  yes

depends_build-append    path:bin/pkg-config:pkgconfig \
                        port:unifont-ttf \
                        port:xa

depends_lib-append      port:ancient \
                        port:bzip2 \
                        port:freetype \
                        port:libcjson \
                        port:libdiscid \
                        path:include/turbojpeg.h:libjpeg-turbo \
                        port:libogg \
                        port:libpng \
                        port:libvorbis \
                        port:ncurses \
                        port:zlib

# ancient requires C++17
compiler.cxx_standard   2017

# The code provides its own fallback for a missing clock_gettime,
# which uses type definitions conflicting with legacysupport.
# types.h:90:13: error: conflicting types for 'clockid_t'; have 'int'
patchfiles-append       patch-types.h.diff

configure.args          --with-ncurses \
                        --without-alsa \
                        --without-desktop_file_install \
                        --without-flac \
                        --without-libgme \
                        --without-mad \
                        --without-oss \
                        --without-sdl \
                        --without-sdl2 \
                        --without-update-desktop-database \
                        --without-update-mime-database \
                        --without-x11

platform darwin {
    configure.args-append \
                        --with-coreaudio
}

variant flac description {Enable FLAC support} {
    depends_lib-append  port:flac
    configure.args-replace \
                        --without-flac --with-flac
}

variant mad description {Enable MAD MPEG support} {
    depends_lib-append  port:libmad
    configure.args-replace \
                        --without-mad --with-mad
}

variant sdl1 conflicts sdl2 description {Enable SDL1 GUI support} {
    depends_lib-append  port:libsdl
    configure.args-replace \
                        --without-sdl --with-sdl
}

variant sdl2 conflicts sdl1 description {Enable SDL2 GUI support} {
    depends_lib-append  port:libsdl2
    configure.args-replace \
                        --without-sdl2 --with-sdl2
}

variant x11 {
    depends_lib-append  port:xorg-libX11 \
                        port:xorg-libXxf86vm \
                        port:xpm
    configure.args-replace \
                        --without-x11 --with-x11
}

default_variants-append +flac +mad

if {![variant_isset sdl1] && ![variant_isset sdl2]} {
    if {${os.platform} eq "darwin" && ${os.major} <= 10} {
        default_variants-append +sdl1
    } else {
        default_variants-append +sdl2
    }
}
