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

if {[info procs "cmake.save_configure_cmd"] ne ""} {
    cmake.save_configure_cmd "log too"
}

fetch.type          git
name                phonon-backend-vlc

if {${subport} eq "${name}-qt5"} {
    # v0.11.1-7-g86b0635
    github.setup    KDE phonon-vlc 86b0635f9f6fec4aa0d63a3e3aa11bb2fcbe151e
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball

    version         0.11.1.7
} else {
    # last Qt4-compatible version
    # v0.10.2-23-g844dec1
    github.setup    KDE phonon-vlc 844dec1f2e15eefd0baa945e9e0dc03363cc7194
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball

    version         0.10.2.23
}
revision            1

license             {LGPL-2.1 LGPL-3}
maintainers         {gmail.com:rjvbertin @RJVB} openmaintainer
description         VLC backend for Phonon
homepage            http://projects.kde.org/projects/kdesupport/phonon/phonon-vlc
distname            phonon-backend-vlc-git

if {[variant_exists vlc2] && [variant_isset vlc2]} {
    depends_lib-append \
                    path:libexec/vlc2/lib/pkgconfig/libvlc.pc:libVLC2
    configure.pkg_config_path-append "${prefix}/libexec/vlc2/lib/pkgconfig"
} else {
    depends_lib-append \
                    path:libexec/vlc3/lib/pkgconfig/libvlc.pc:VLC
    configure.pkg_config_path-append "${prefix}/libexec/vlc3/lib/pkgconfig"
}

patch.pre_args-append   -N
patch.pre_args-replace  -p0 -p1

subport ${name}-qt5 {
    set qt5.prefer_kde 1
    PortGroup       qt5 1.0
    categories      audio kde kf5
    long_description \
                    A VLC backend for the Phonon4Qt5 multimedia library.
    depends_build-append \
                    path:share/ECM/cmake/ECMConfig.cmake:kde-extra-cmake-modules
    depends_lib-append \
                    port:phonon-qt5

    patchfiles-append \
                    patch-link-cocoa-fw.diff

    configure.args-append \
                    -DAPPLE_SUPPRESS_X11_WARNING:BOOL=ON \
                    -DPhonon4Qt5_DIR=${qt_cmake_module_dir}/phonon
}

if {${subport} ne "${name}-qt5"} {
    PortGroup       qt4 1.0
    categories      audio kde kde4
    long_description    A VLC backend for the Phonon multimedia library.
    depends_lib-append  port:phonon port:automoc

    configure.args-append   -DPhonon_DIR=${qt_cmake_module_dir}/phonon
    post-destroot {
        if {[file exists ${qt_plugins_dir}] && ![file exists ${qt_plugins_dir}/phonon_backend]} {
            xinstall -m 755 -d ${destroot}${qt_plugins_dir}
            ln -s ${prefix}/lib/kde4/plugins/phonon_backend ${destroot}${qt_plugins_dir}
        }
    }
}

build.post_args     -k