# -*- 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
PortGroup           python 1.0

name                py-pyqwt
version             5.2.0
revision            13

platforms           macosx
categories-append   devel
maintainers         {michaelld @michaelld} 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           rmd160 e4c8a63d623d974cd500e29fbc62255746ca7feb \
                    sha256 98a8c7e0c76d07701c11dffb77793b05f071b664a8b520d6e97054a98179e70b

# PyQwt's Python scripts are not compatible with Python 3.4+, and
# there are many changes required to make it compatible.
python.versions     27

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

    use_configure      yes

    depends_lib-append port:py${python.version}-pyqt4 \
                       port:py${python.version}-numpy \
                       port:py${python.version}-sip4

    patchfiles         patch-sip_qwt5qt4_QwtModule.sip.diff

    pre-configure {
        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_exists universal] || ![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
