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

github.setup        FluidSynth fluidsynth 2.3.4 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1
categories          multimedia audio
maintainers         {gmail.com:rjvbertin @RJVB} openmaintainer
license             LGPL

description         FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications.
long_description    FluidSynth is a cross-platform real-time software synthesizer with \
                    support for SoundFont 2 and a built-in command line shell. \
                    It may be used for playback of MIDI files, but also \
                    provides a shared library which can be used in other programs.

homepage            http://www.fluidsynth.org/

checksums           rmd160  038c1d9e7c4231b6763a0b709caaabc44d70c8b8 \
                    sha256  cbe698fe353815c66a285ec2d8f30e4c050d05be60739ff2b751d193edb04d71 \
                    size    1775389

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

depends_lib-append \
                    port:flac \
                    port:gettext \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:libiconv \
                    port:libogg \
                    port:libsndfile \
                    port:libvorbis \
                    port:ncurses \
                    port:portaudio \
                    port:readline

depends_run-append  port:generaluser-soundfont

# https://trac.macports.org/ticket/68458
compiler.cxx_standard   2011

# parallel build fails on some arm platforms
# make[2]: *** read jobs pipe: Resource temporarily unavailable.  Stop.
use_parallel_build  no

# https://trac.macports.org/ticket/36962
platform darwin 8 {
    patchfiles-append \
                    patch-tiger.diff
}

# respect MacPorts compiler for builing make_tables.exe
# see https://trac.macports.org/wiki/UsingTheRightCompiler
patchfiles-append   patch-external_project_cc.diff
# Fix build error: os/log.h not found
patchfiles-append   patch-fluid_coremidi.c-log.diff

configure.args-append \
                    -Denable-jack=OFF \
                    -Denable-dbus=OFF \
                    -Denable-pulseaudio=OFF \
                    -Denable-framework=OFF \
                    -DLIB_SUFFIX="" \
                    -DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=ON \
                    -DCMAKE_DISABLE_FIND_PACKAGE_OpenMP=ON \
                    -DDEFAULT_SOUNDFONT=${prefix}/share/sounds/sf2/GeneralUser_GS_v1.471.sf2

# support for JACK makes JACK output the default and requires the daemon to be running
variant jack description {Enable JACK support (requires the deamon to be running)} {
    depends_lib-append \
                    port:jack
    configure.args-replace \
                    -Denable-jack=OFF -Denable-jack=ON
}

variant dbus description {Enable D-Bus support} {
    depends_lib-append \
                    port:dbus
    configure.args-replace \
                    -Denable-dbus=OFF -Denable-dbus=ON
}

variant openmp description {Enable OpenMP support} {
    compiler.openmp_version     4.0
    configure.args-delete       -DCMAKE_DISABLE_FIND_PACKAGE_OpenMP=ON
    configure.cflags-append     -fopenmp-version=40
}

test.run            yes
test.target         check
