# $Id: Portfile 119744 2014-05-05 13:51:49Z mmoll@macports.org $

PortSystem 1.0
PortGroup python 1.0
PortGroup cmake 1.0

set realname        pyside
name                py-${realname}
version             1.2.2
set          qt.ver 4.8
python.versions     26 27 32 33 34
python.default_version 27
categories-append   devel
maintainers         openmaintainer mmoll
license             LGPL
description         LGPL-licensed Python bindings for Qt
long_description    The PySide project provides LGPL-licensed Python bindings \
                    for the Qt cross-platform application and UI framework. \
                    PySide Qt bindings allow both free open source and \
                    proprietary software development and ultimately aim to \
                    support all of the platforms as Qt itself.
homepage            http://qt-project.org/wiki/PySide
platforms           darwin
license             LGPL
master_sites        http://download.qt-project.org/official_releases/pyside

checksums           md5     1969c2ff90eefaa4b200d234059d2287 \
                    rmd160  8d3102bb17138b1eb7e9f1666983bb231607058e \
                    sha1    955e32d193d173faa64edc51111289cdcbe3b96e
distname            ${realname}-qt${qt.ver}+${version}
use_bzip2           yes

if {${name} ne ${subport}} {
    patchfiles      FindShiboken.cmake.patch
    post-patch {
        if {${python.version} < 30} {
            reinplace "s|@PYTHONSUFFIX@|-python${python.branch}|g" ${worksrcpath}/cmake/Macros/FindShiboken.cmake
        } else {
            reinplace "s|@PYTHONSUFFIX@|.cpython-${python.version}m|g" ${worksrcpath}/cmake/Macros/FindShiboken.cmake
        }
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/cmake/Macros/FindShiboken.cmake
        reinplace "s|@PYTHONBRANCH@|${python.branch}|g" ${worksrcpath}/cmake/Macros/FindShiboken.cmake
        reinplace "s|@PYTHONINCLUDE@|${python.include}|g" ${worksrcpath}/cmake/Macros/FindShiboken.cmake
        reinplace "s|@PYTHONBIN@|${python.bin}|g" ${worksrcpath}/cmake/Macros/FindShiboken.cmake

    }
    depends_lib-append  port:qt4-mac port:py${python.version}-shiboken
    use_configure   yes
    configure.args-append -DBUILD_TESTS:BOOL=FALSE \
                          -DSITE_PACKAGE=${python.pkgd}
    build.cmd       make
    build.target    all
    destroot.cmd    make
    destroot.destdir DESTDIR=${destroot}
    post-destroot {
        move ${destroot}${prefix}/include/PySide ${destroot}${prefix}/include/PySide-${python.branch}
        move ${destroot}${prefix}/share/PySide ${destroot}${prefix}/share/PySide-${python.branch}
        file delete ${destroot}${prefix}/lib/cmake/PySide-${version}/PySideConfig-python${python.branch}.cmake
        file delete ${destroot}${prefix}/lib/cmake/PySide-${version}/PySideConfig.cmake
        file delete ${destroot}${prefix}/lib/cmake/PySide-${version}/PySideConfigVersion.cmake
        file delete ${destroot}${prefix}/lib/pkgconfig/pyside.pc

    }
}

if {${name} eq ${subport}} {
    livecheck.type      regex
    livecheck.url       http://qt-project.org/wiki/PySideDownloads
    livecheck.regex     ${realname}-qt${qt.ver}\\+(\[0-9.\]+)\\.tar\\.bz2
} else {
    livecheck.type      none
}
