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

name                MP4Tools
version             3.8
revision            2
categories          multimedia
license             GPL-2+
maintainers         {makr @mohd-akram} openmaintainer

homepage            https://www.mp4joiner.org

description         tools to manipulate MP4 files

long_description    MP4Tools is a collection of cross-platform free tools to \
                    manipulate MP4 files. It contains MP4Splitter for \
                    splitting MP4 files, and MP4Joiner for joining them.

master_sites        sourceforge:project/mp4joiner/MP4Tools/${version}

use_bzip2           yes

checksums           rmd160  270c23880063242fa6629dc15e6b16ed363a56c3 \
                    sha256  6a64d4c02b84affb6b6e1f17aaca78a41d319576b7f428b50b55a6ba2ce64b3e \
                    size    310988

wxWidgets.use       wxWidgets-3.2

depends_build       path:bin/pkg-config:pkgconfig \
                    port:gettext \
                    port:gpac

depends_lib         path:lib/libavcodec.dylib:ffmpeg \
                    port:${wxWidgets.port} \
                    port:wxsvg

depends_run         port:gpac

# gpac is not universal but we only use its MP4Box program not its libraries
depends_skip_archcheck  gpac

patchfiles          patch-Makefile.in.diff

configure.args      --with-wxdir=${wxWidgets.wxdir}

platform darwin {
    build.target    apps
    post-destroot {
        copy ${worksrcpath}/MP4Joiner.app ${destroot}${applications_dir}
        copy ${worksrcpath}/MP4Splitter.app ${destroot}${applications_dir}

        ln -sf ${prefix}/bin/mp4joiner \
            ${destroot}${applications_dir}/MP4Joiner.app/Contents/MacOS/MP4Joiner
        ln -s ${prefix}/bin/ffmpeg \
            ${destroot}${applications_dir}/MP4Joiner.app/Contents/MacOS
        ln -s ${prefix}/bin/MP4Box \
            ${destroot}${applications_dir}/MP4Joiner.app/Contents/MacOS

        ln -sf ${prefix}/bin/mp4splitter \
            ${destroot}${applications_dir}/MP4Splitter.app/Contents/MacOS/MP4Splitter
        ln -s ${prefix}/bin/ffmpeg \
            ${destroot}${applications_dir}/MP4Splitter.app/Contents/MacOS

        foreach f [glob -tails -directory ${destroot}${prefix}/share locale/*] {
           ln -sf ${prefix}/share/${f}/LC_MESSAGES/mp4tools.mo \
               ${destroot}${applications_dir}/MP4Joiner.app/Contents/${f}
           ln -sf ${prefix}/share/${f}/LC_MESSAGES/mp4tools.mo \
               ${destroot}${applications_dir}/MP4Splitter.app/Contents/${f}
        }
    }
}

livecheck.distname  ${name}
