# -*- 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
# $Id: Portfile 105452 2013-04-20 19:52:26Z michaelld@macports.org $

PortSystem          1.0
PortGroup           qt4 1.0
PortGroup           cmake 1.0

name                phonon
version             4.6.0
revision            1
categories          audio kde kde4
license             {LGPL-2.1 LGPL-3}
maintainers         michaelld openmaintainer
description         Cross Platform Multimedia API used by KDE4
long_description    Cross Platform Multimedia API used by KDE4
platforms           darwin
homepage            http://phonon.kde.org
master_sites        kde:stable/${name}/${version}/src
use_xz              yes
distname            phonon-${version}
checksums           md5     bbe0c1c62ed14c31479c4c1a6cf1e173 \
                    sha1    d8dbc188b58c6dd9c6a73d3742a25291e647bb95 \
                    rmd160  4b6037744c519613f0e39065a92d6742305e1366

depends_build-append  port:automoc

# fix the library compatibility version to be 4.4.0
patchfiles          patch-CMakeLists.txt.diff

configure.args-append   \
    ${qt_cmake_defines} \
    -DPHONON_INSTALL_QT_EXTENSIONS_INTO_SYSTEM_QT=true

configure.ldflags-append -F${qt_frameworks_dir}

post-destroot {

    # fix plugin name

    move ${destroot}${qt_plugins_dir}/designer/libphononwidgets.so \
        ${destroot}${qt_plugins_dir}/designer/libphononwidgets.dylib

    # link major library version name

    ln -s ${prefix}/lib/libphonon.dylib ${destroot}${prefix}/lib/libphonon.4.dylib
    ln -s ${prefix}/lib/libphononexperimental.dylib ${destroot}${prefix}/lib/libphononexperimental.4.dylib

    # fix library and plugin self-names

    system "install_name_tool -id ${prefix}/lib/libphonon.4.dylib ${destroot}${prefix}/lib/libphonon.dylib"
    system "install_name_tool -id ${prefix}/lib/libphononexperimental.4.dylib ${destroot}${prefix}/lib/libphononexperimental.dylib"

    # fix use of libphonon

    system "install_name_tool -change lib/libphonon.4.4.0.dylib ${prefix}/lib/libphonon.4.dylib ${destroot}${prefix}/lib/libphononexperimental.dylib"
    system "install_name_tool -change lib/libphonon.4.4.0.dylib ${prefix}/lib/libphonon.4.dylib ${destroot}${prefix}/share/qt4/plugins/designer/libphononwidgets.dylib"

    # move odd cmake directory into the cmake module's directory

    xinstall -m 755 -d ${destroot}${qt_cmake_module_dir}
    move ${destroot}${prefix}/lib/cmake/phonon \
        ${destroot}${qt_cmake_module_dir}

    # install 'phonon' header from Qt into include/phonon/.

    xinstall -m 644 ${filespath}/phonon ${destroot}${prefix}/include/phonon

}

livecheck.type		regex
livecheck.url		http://www.gtlib.gatech.edu/pub/kde/stable/${name}/
livecheck.regex		"\(\\d+(?:\\.\\d+)*)\/"
