# -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

name                audacity
version             3.7.6
categories          audio
license             GPL-3
maintainers         {makr @mohd-akram} openmaintainer

set audacity_dir    ${applications_dir}/Audacity.app/Contents

subport ${name} {
    PortGroup           cmake 1.1
    PortGroup           wxWidgets 1.0

    github.setup        audacity audacity ${version} Audacity-
    github.tarball_from releases
    revision            0
    conflicts           audacity-legacy
    description         multi-track audio editor

    long_description    Audacity is an easy-to-use, multi-track audio editor and \
                        recorder for Windows, macOS, GNU/Linux and other operating \
                        systems.

    homepage            https://www.audacityteam.org

    checksums           rmd160  9e0f748caf6fdc0696f97ffcee1287d027e3b3d8 \
                        sha256  429c9ea122a335b61898191c82bbbb61c6f6ab4dc345a8e927a9b7951a1843c3 \
                        size    64571955

    distname            ${name}-sources-${version}

    wxWidgets.use       wxWidgets-3.2

    # rapidjson is header-only
    depends_build-append \
                        port:rapidjson

    depends_lib-append  port:${wxWidgets.port} \
                        port:lame \
                        port:libvorbis \
                        port:flac \
                        port:libogg \
                        port:libopus \
                        port:opusfile \
                        port:libsndfile \
                        port:mpg123 \
                        port:portaudio \
                        port:libid3tag \
                        port:portmidi \
                        port:wavpack \
                        port:expat \
                        port:zlib

    depends_run         port:ffmpeg8

    patchfiles          patch-offline-manual.diff

    post-patch {
        # truncate/disable this script which changes library paths
        close [open ${worksrcpath}/scripts/build/macOS/fix_bundle.py w]
    }

    configure.args      -Daudacity_conan_enabled=OFF \
                        -Daudacity_has_vst3=OFF \
                        -DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets.wxconfig}

    compiler.cxx_standard   2017

    # if not present some menu items appear in another language
    destroot.keepdirs   ${destroot}${audacity_dir}/Resources/en.lproj

    post-destroot {
        platform darwin {
            move ${destroot}${prefix}/Audacity.app ${destroot}${applications_dir}/
        }
    }
}

subport ${name}-manual {
    revision            0
    description         The manual for audacity
    long_description    {*}${description}
    github.setup        audacity audacity-manual ${version} v
    github.tarball_from releases
    homepage            https://manual.audacityteam.org
    checksums           rmd160  c2916114a787642d6edf6013e48c2ff40fc96720 \
                        sha256  b2b8b91fe92217bb43d88adfa6355b483c958cbcc03b92d9c7d93e7dd58a6b8f \
                        size    26582998
    depends_run         port:audacity
    use_configure       no
    build               {}
    installs_libs       no
    supported_archs     noarch
    platforms           {darwin any}
    worksrcdir          help

    set data_dir        ${prefix}/share/audacity
    platform darwin {
        set data_dir    ${audacity_dir}
    }

    destroot {
        xinstall -d ${destroot}${data_dir}
        copy ${worksrcpath} ${destroot}${data_dir}
    }
}
