# -*- 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 119447 2014-04-25 20:52:32Z mf2k@macports.org $

PortSystem          1.0
PortGroup           python 1.0

name                py-pyqwt
version             5.2.0
revision            10

platforms           macosx
categories-append   devel
maintainers         mf2k michaelld erickt openmaintainer
license             GPL-2+

description         PyQwt is a set of Python bindings for the Qwt 5 toolkit
long_description    PyQwt is a set of Python bindings for the Qwt C++ class library which extends \
                    the Qt framework with widgets for scientific and engineering applications. It \
                    provides a widget to plot 2-dimensional data and various widgets to display \
                    and control bounded or unbounded floating point values. \
                    PyQwt version 5 is compatible with Qwt version 5 only.

homepage            http://pyqwt.sourceforge.net
master_sites        sourceforge:pyqwt
distname            PyQwt-${version}
dist_subdir         python

checksums           md5     fcd6c6029090d473dcc9df497516eae7 \
                    sha1    797f37c63dec660272f6a8ccfd16a017df0ad640 \
                    rmd160  e4c8a63d623d974cd500e29fbc62255746ca7feb

# Note that python 3.1 is apparently supported but the dependencies need to be added first
python.versions     26 27

if {${name} ne ${subport}} {

    use_configure      yes

    # Can use either py*-pyqt4 or py*-pyqt4-devel.
    depends_lib-append path:share/py${python.version}-sip/PyQt4:py${python.version}-pyqt4 \
                       port:py${python.version}-numpy \
                       port:py${python.version}-sip

    worksrcdir         ${worksrcdir}/configure
    
    configure.cmd      ${prefix}/bin/python${python.branch} configure.py
    configure.pre_args -I ${prefix}/include -I ${prefix}/include/qwt -I ${prefix}/include/python${python.branch} -L ${prefix}/lib --disable-numarray --disable-numeric
    configure.universal_args-delete --disable-dependency-tracking

    build.target
    build.cmd          make
    destroot.cmd       make install
    destroot.destdir   DESTDIR=${destroot}

    # depend on the QWT5 library, but default to 5.2.  This port is
    # does not work with Qwt 6 (any longer; not sure if it ever did).
    depends_lib-append  path:lib/libqwt.5.dylib:qwt52

    post-configure {

        # fix compiler

        reinplace "s@CC = .*@CC = ${configure.cc}@" \
            ${worksrcpath}/qwt5qt4/Makefile ${worksrcpath}/iqt5qt4/Makefile
        reinplace "s@CXX = .*@CXX = ${configure.cxx}@" \
            ${worksrcpath}/qwt5qt4/Makefile ${worksrcpath}/iqt5qt4/Makefile
        reinplace "s@LINK = .*@LINK = ${configure.cxx}@" \
            ${worksrcpath}/qwt5qt4/Makefile ${worksrcpath}/iqt5qt4/Makefile

        # if not universal, try removing all arch flags from the
        # Makefiles.  If Python is installed as +universal, these will
        # do the trick; if Python is installed as -universal, then
        # these will do no harm.

        if {![variant_isset universal]} {
            reinplace "s@-arch \[^ \]*@@g" ${worksrcpath}/qwt5qt4/Makefile
            reinplace "s@-arch \[^ \]*@@g" ${worksrcpath}/iqt5qt4/Makefile
        }
    }
}

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex PyQwt-(\[0-9\.\]+)\.tar\.gz
