# -*- 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 118029 2014-03-19 20:07:12Z michaelld@macports.org $

PortSystem          1.0
PortGroup           qt4 1.0
PortGroup           cmake 1.0

name                phonon
version             4.7.1
categories          audio kde kde4
license             {LGPL-2.1 LGPL-3}
maintainers         michaelld openmaintainer
description         Cross Platform Multimedia API used by KDE4
long_description    Phonon is a multimedia, multi-platform sound \
    framework for the application developer.
platforms           darwin
homepage            http://phonon.kde.org
master_sites        kde:stable/${name}/${version}
use_xz              yes
distname            phonon-${version}
checksums           rmd160 15427574bfd8ef65713bb9a5dc5d1a52d6e5468d \
                    sha256 4ff7802deeac1557166591deb9fc2bfdfcaacdeb5389d07f08255365fb91b75d

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}

}

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