# -*- 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.8
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-
    revision            0
    conflicts           audacity2
    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  95876e7df051c5ebfd58f6bff5bc6b97beb860c6 \
                        sha256  75f2b1d9c7d45faaaf193844d5fee796694deac7bf4932ca520563ab4fb74c27 \
                        size    67556613

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

    wxWidgets.use       wxWidgets-3.2

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

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

    depends_run         path:lib/libavcodec.dylib:ffmpeg

    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 \
                        -Daudacity_use_sqlite=system \
                        -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}/
        }
    }

    github.livecheck.regex {([0-9.]+)}
}

subport ${name}-manual {
    revision            0
    description         The manual for audacity
    long_description    {*}${description}
    github.setup        audacity audacity-manual ${version} v
    homepage            https://manual.audacityteam.org
    checksums           rmd160  8ec4aef75fa01a5dd10552b97b37bfa8d910cb27 \
                        sha256  00370c8d8c666598e9b20728efd66652315ffb58c04add01d2b5b3de49ba42f2 \
                        size    26563734
    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}
    }
}
