# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 54640 2009-07-30 19:53:20Z dh@macports.org $

PortSystem 1.0

name         py26-sip
version      4.8.2
categories   python devel
maintainers  mcalhoun openmaintainer
platforms    macosx
description  create Python bindings for C and C++ libraries
long_description \
    SIP is a tool that makes it very easy to create \
    Python bindings for C and C++ libraries. \
    It was originally developed to create PyQt, \
    the Python bindings for the Qt toolkit, \
    but can be used to create bindings for any \
    C or C++ library.
homepage http://www.riverbankcomputing.co.uk/sip/
master_sites \
    http://www.riverbankcomputing.com/static/Downloads/sip4/ \
    http://gentoo.mirrors.easynews.com/linux/gentoo/distfiles/ \
    http://gentoo.osuosl.org/distfiles/ \
    http://www.gtlib.gatech.edu/pub/gentoo/distfiles/

distname sip-${version}
checksums           md5     7ae60712aa6b4095a8cdab11b437f8f0 \
                    sha1    0364027c34eb69ce8c51d316c68f10a02a42d036 \
                    rmd160  5b390d09a5b1a5e5fbf29d245aee8543397a1f19

set pyversion 2.6
depends_lib-append port:python[strsed ${pyversion} {g/[.]//}]
set pybin ${prefix}/bin/python${pyversion}

# For linking sip.so, replace
#    -F${frameworks_dir}/Library/Frameworks -framework Python
#    with
#    ${frameworks_dir}/Python.framework/Versions/${pyversion}/Python

post-patch {
    reinplace \
        "s|__MacPorts_Required_Python_Lib__|${frameworks_dir}/Python.framework/Versions/${pyversion}/Python|" \
        ${worksrcpath}/siputils.py
}

configure.cmd ${pybin} configure.py

pre-configure {
    # Ensure correct compilers are used
    reinplace "s| cc\$| ${configure.cc}|" \
        ${worksrcpath}/specs/macx-g++
    reinplace "s| c++\$| ${configure.cxx}|" \
        ${worksrcpath}/specs/macx-g++
}

# By default, everything gets installed in the Python Frameworks directory
configure.pre_args-delete  --prefix=${prefix}

test.run  yes
test.cmd  cd siplib && ${pybin} -c 'import sip'

post-destroot {
    ln -s ${frameworks_dir}/Python.framework/Versions/${pyversion}/bin/sip ${destroot}${prefix}/bin/sip-${pyversion}

    # Install documentation
	xinstall -m 755 -d ${destroot}${prefix}/share/doc
	file copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${name}
	xinstall -m 644 -W ${worksrcpath} ChangeLog NEWS README \
		${destroot}${prefix}/share/doc/${name}
}

livecheck.check  regex
livecheck.url    http://www.riverbankcomputing.co.uk/news
livecheck.regex  "SIP v(\\d+(?:\\.\\d+)*) Released"
