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

name            dbus-python27
version         1.2.18
revision        1

maintainers     {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
license         MIT
categories      devel python
description     Python bindings for the dbus message bus system.
long_description \
    {*}${description}
homepage        https://www.freedesktop.org/wiki/Software/dbus/

master_sites    https://dbus.freedesktop.org/releases/dbus-python/
distname        dbus-python-${version}

checksums       rmd160  5552b124fb35d5271b8a4813e8635cbf1bdb5836 \
                sha256  92bdd1e68b45596c833307a5ff4b217ee6929a1502f5341bae28fd120acf7260 \
                size    578204

patchfiles-append dynamic_lookup-11.patch

depends_build   path:bin/pkg-config:pkgconfig

depends_lib     port:dbus \
                port:gettext-runtime \
                path:lib/pkgconfig/glib-2.0.pc:glib2 \
                port:python27

set python_branch 2.7
set python_prefix ${frameworks_dir}/Python.framework/Versions/${python_branch}

configure.pre_args-replace \
                --prefix=${prefix} --prefix=${python_prefix}
configure.args  --docdir=${prefix}/share/doc/${subport} \
                --disable-documentation

set includedir_base ${python_prefix}/include/python${python_branch}
set python_config ${prefix}/bin/python${python_branch}-config

pre-configure {
    # determine any abiflags; works for Python 3+ only; will
    # catch for Python 2.7 and we know there are no flags.
    if {[catch {set abiflags [exec ${python_config} --abiflags]}]} {
        set abiflags ""
    }
    configure.args-append --includedir=${includedir_base}${abiflags}
}

configure.pkg_config_path  ${python_prefix}/lib/pkgconfig

configure.python    ${prefix}/bin/python${python_branch}

variant examples description {Install examples} {
    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        set exdir ${docdir}/examples
        xinstall -d ${destroot}${exdir}
        xinstall -m 644 {*}[glob ${worksrcpath}/examples/*] ${destroot}${exdir}
    }
}

platform darwin 9 {
    # see https://trac.macports.org/ticket/13782
    # see https://trac.macports.org/ticket/12966
    post-patch {
        reinplace "s|-export-symbols-regex.*|\\\\|g" \
            ${worksrcpath}/Makefile.in
    }
}
