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

# For TARGET_OS_OSX, TARGET_OS_IOS & TARGET_OS_TV macros
legacysupport.newest_darwin_requires_legacy 14

name                    openal-soft
if {${os.platform} ne "darwin" || ${os.major} >= 17} {
    version             1.24.2
    revision            0
    checksums           rmd160  8469975aa3192c68678db050b56ae17c26e04758 \
                        sha256  cd4c88c9b7311cb6785db71c0ed64f5430c9d5b3454e0158314b2ef25ace3e61 \
                        size    1020760
} else {
    # macOS 10.12:
    # https://build.macports.org/builders/ports-10.12_x86_64-builder/builds/291362/steps/install-port/logs/stdio
    # common/almalloc.h:78:46: error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.13 or newer
    # common/almalloc.h:81:9: error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on macOS 10.13 or newer
    # https://github.com/kcat/openal-soft/issues/1066
    version             1.23.1
    revision            2
    checksums           rmd160  5ca2531cc9e7476d122ddc9ab3a1b3e568d62175 \
                        sha256  796f4b89134c4e57270b7f0d755f0fa3435b90da437b745160a49bd41c845b21 \
                        size    699330
}

categories              audio devel
maintainers             {ryandesign @ryandesign} openmaintainer
license                 LGPL-2

description             cross-platform software implementation of the OpenAL \
                        3D audio API

long_description        OpenAL Soft is a ${description}. It's forked from the \
                        open-sourced Windows version available originally \
                        from the SVN repository at openal.org. OpenAL \
                        provides capabilities for playing audio in a virtual \
                        3D environment. Distance attenuation, doppler shift, \
                        and directional sound emitters are among the features \
                        handled by the API. More advanced effects, including \
                        air absorption, occlusion, and environmental reverb, \
                        are available through the EFX extension. It also \
                        facilitates streaming audio, multi-channel buffers, \
                        and audio capture.

homepage                https://openal-soft.org
master_sites            ${homepage}/openal-releases/
use_bzip2               yes

depends_lib-append      port:libmysofa \
                        port:zlib

if {[vercmp ${version} < 1.24.0]} {
    # See: https://github.com/kcat/openal-soft/pull/851
    patchfiles-append   0001-Define-__STDC_FORMAT_MACROS-on-systems-that-need-it.patch \
                        0002-threads-do-not-use-libdispatch-where-it-is-not-prese.patch \
                        patch-cinttypes.diff

    compiler.cxx_standard       2014
} else {
    compiler.cxx_standard       2017
}
compiler.thread_local_storage   yes

# error: inline declaration of 'configValue<...>' follows non-inline definition
# https://github.com/kcat/openal-soft/issues/703
compiler.blacklist-append {clang < 900}

configure.args-append   -DALSOFT_EXAMPLES=OFF \
                        -DALSOFT_UTILS=ON \
                        -DALSOFT_NO_CONFIG_UTIL=ON \
                        -DALSOFT_REQUIRE_ALSA=OFF \
                        -DALSOFT_BACKEND_ALSA=OFF \
                        -DALSOFT_REQUIRE_JACK=OFF \
                        -DALSOFT_BACKEND_JACK=OFF \
                        -DALSOFT_REQUIRE_OBOE=OFF \
                        -DALSOFT_BACKEND_OBOE=OFF \
                        -DALSOFT_REQUIRE_OPENSL=OFF \
                        -DALSOFT_BACKEND_OPENSL=OFF \
                        -DALSOFT_REQUIRE_OSS=OFF \
                        -DALSOFT_BACKEND_OSS=OFF \
                        -DALSOFT_REQUIRE_PIPEWIRE=OFF \
                        -DALSOFT_BACKEND_PIPEWIRE=OFF \
                        -DALSOFT_REQUIRE_PORTAUDIO=OFF \
                        -DALSOFT_BACKEND_PORTAUDIO=OFF \
                        -DALSOFT_REQUIRE_PULSEAUDIO=OFF \
                        -DALSOFT_BACKEND_PULSEAUDIO=OFF \
                        -DALSOFT_REQUIRE_SDL2=OFF \
                        -DALSOFT_BACKEND_SDL2=OFF \
                        -DALSOFT_REQUIRE_SDL3=OFF \
                        -DALSOFT_BACKEND_SDL3=OFF \
                        -DALSOFT_REQUIRE_SNDIO=OFF \
                        -DALSOFT_BACKEND_SNDIO=OFF \
                        -DALSOFT_REQUIRE_SOLARIS=OFF \
                        -DALSOFT_BACKEND_SOLARIS=OFF \
                        -DALSOFT_RTKIT=OFF \
                        -DCMAKE_DISABLE_FIND_PACKAGE_FFmpeg=ON \
                        -DCMAKE_DISABLE_FIND_PACKAGE_Git=ON \
                        -DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON \
                        -DCMAKE_DISABLE_FIND_PACKAGE_SDL3=ON \
                        -DCMAKE_DISABLE_FIND_PACKAGE_SndFile=ON

variant gui description {Enable alsoft-config Qt GUI} {
    PortGroup           qt5 1.0

    configure.args-replace  -DALSOFT_NO_CONFIG_UTIL=ON -DALSOFT_NO_CONFIG_UTIL=OFF
}

variant jack description {Enable JACK backend} {
    depends_lib-append  port:jack
    configure.args-replace  -DALSOFT_REQUIRE_JACK=OFF -DALSOFT_REQUIRE_JACK=ON \
                            -DALSOFT_BACKEND_JACK=OFF -DALSOFT_BACKEND_JACK=ON
}

variant portaudio description {Enable PortAudio backend} {
    depends_lib-append  port:portaudio
    configure.args-replace  -DALSOFT_REQUIRE_PORTAUDIO=OFF -DALSOFT_REQUIRE_PORTAUDIO=ON \
                            -DALSOFT_BACKEND_PORTAUDIO=OFF -DALSOFT_BACKEND_PORTAUDIO=ON
}

variant pulseaudio description {Enable PulseAudio backend} {
    depends_lib-append  port:pulseaudio
    configure.args-replace  -DALSOFT_REQUIRE_PULSEAUDIO=OFF -DALSOFT_REQUIRE_PULSEAUDIO=ON \
                            -DALSOFT_BACKEND_PULSEAUDIO=OFF -DALSOFT_BACKEND_PULSEAUDIO=ON
}

variant sdl2 description {Enable SDL2 backend} {
    depends_lib-append  port:libsdl2
    configure.args-replace  -DALSOFT_REQUIRE_SDL2=OFF -DALSOFT_REQUIRE_SDL2=ON \
                            -DALSOFT_BACKEND_SDL2=OFF -DALSOFT_BACKEND_SDL2=ON
}
if {![variant_isset sdl2]} {
    configure.args-append   -DCMAKE_DISABLE_FIND_PACKAGE_SDL2=ON
}


livecheck.type          regex
livecheck.regex         /${name}-(\[0-9.\]+)${extract.suffix}
