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

github.setup        enzo1982 freac 1.1.7 v
revision            1
checksums           rmd160  fcb567a70e5f204292bfb4721e4e5413cd9a6b60 \
                    sha256  617d51759315f65e387fcaf1f1b455c97a2fb53bfdbd2521c9c586b3271f3528 \
                    size    4662284

categories          audio
license             GPL-2
maintainers         nomaintainer
description         An open source audio converter.
long_description    ${name} is a free audio converter and CD ripper with support \
                    for various popular formats and encoders. It converts freely \
                    between MP3, M4A/AAC, FLAC, WMA, Opus, Ogg Vorbis, Speex, \
                    Monkey's Audio (APE), WavPack, WAV and other formats.

homepage            https://www.freac.org
github.tarball_from releases

depends_lib         port:BoCA \
                    port:smooth

depends_run         path:bin/ffmpeg:ffmpeg \
                    port:flac \
                    port:lame \
                    port:libfdk-aac \
                    port:libogg \
                    port:libopus \
                    port:libsamplerate \
                    port:libsndfile \
                    port:libvorbis \
                    port:mp4v2 \
                    port:mpg123 \
                    port:rubberband \
                    port:speex \
                    port:wavpack

makefile.prefix_name    prefix

post-destroot {
    # Copy the the application bundle shipped by the upstream project
    copy -- ${worksrcpath}/packaging/macosx/freac.app ${destroot}${applications_dir}

    # Create MacOS folders where freac binaries and symlinks will be moved/created
    xinstall -d ${destroot}${applications_dir}/freac.app/Contents/MacOS
    xinstall -d ${destroot}${applications_dir}/freac.app/Contents/Resources/translator.app/Contents/MacOS

    # Move resources to app folders, otherwise the freac binary does not recognize them
    move ${destroot}${prefix}/share/doc/freac/manual ${destroot}${applications_dir}/freac.app/Contents/Resources/manual
    move ${destroot}${prefix}/share/freac/icons ${destroot}${applications_dir}/freac.app/Contents/Resources/icons
    move ${destroot}${prefix}/share/freac/lang ${destroot}${applications_dir}/freac.app/Contents/Resources/lang

    # Move freac to app folders as it should not be executed from terminal
    move ${destroot}${prefix}/bin/freac ${destroot}${applications_dir}/freac.app/Contents/MacOS

    # Create symlink to smooth-translator from port smooth
    ln -s ${prefix}/bin/smooth-translator \
    ${destroot}${applications_dir}/freac.app/Contents/Resources/translator.app/Contents/MacOS/translator
}
