# $Id: Portfile 107942 2013-07-09 19:39:11Z mmoll@macports.org $

PortSystem 1.0
PortGroup cmake 1.0
PortGroup python 1.0

set realname        shiboken
name                py-${realname}
version             1.2.0
python.versions     25 26 27 31 32 33
python.default_version 27
categories-append   devel
maintainers         openmaintainer mmoll
license             LGPL
description         Plugin for generatorrunner that generates python bindings \
                    for C++ libraries
long_description    Shiboken is a plugin (front-end) for generatorrunner that \
                    generates python bindings for C++ libraries using CPython \
                    source code.
homepage            http://qt-project.org/wiki/PySide
platforms           darwin
master_sites        http://download.qt-project.org/official_releases/pyside

checksums           md5     946ae0405ff3238d6b72124e07fae06e \
                    rmd160  cfd93c9c33e76f78ac49a3bfcf9fa802e738ea8b \
                    sha1    03866dbdfa34078b2d9d35f4b6d83aa65e292e3f
distname            ${realname}-${version}
use_bzip2           yes

if {$subport != $name} {
    pre-patch {
        # MacOS cannot have a file and directory with the same name, as occurs here
        system "mv -v '${worksrcpath}/generator/shiboken' '${worksrcpath}/generator/shiboken.d'"
        reinplace "s|3.2 3.1 3.0|${python.branch}|g" ${worksrcpath}/cmake/Modules/FindPython3Libs.cmake
        reinplace "s|NAMES python3.2mu python3.2m python3.2u python3.2 python3.1 python3.0 python3|NAMES python${python.branch}|g" ${worksrcpath}/cmake/Modules/FindPython3Interp.cmake
    }

    patchfiles          default_visibility.patch \
                        filename_collision.patch

    depends_lib-append  port:qt4-mac \
                        port:python${python.version} \
                        port:libxslt
    use_configure   yes
    configure.args-append -DBUILD_TESTS:BOOL=FALSE \
                    -DPYTHON_EXECUTABLE=${python.bin} \
                    -DPYTHON_LIBRARY=${python.lib} \
                    -DPYTHON_INCLUDE_DIR=${python.include}
    if {${python.version} >= 30} {
        configure.args-append -DUSE_PYTHON3:BOOL=TRUE -DPYTHON3_LIBRARY=${python.lib} -DPYTHON3_INCLUDE_DIR=${python.include}
    }
    build.cmd       make
    build.target    all
    destroot.cmd    make
    destroot.destdir DESTDIR=${destroot}
}

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