# -*- 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 84512 2011-09-27 14:19:06Z snc@macports.org $

PortSystem 1.0
PortGroup           qt4 1.0

name                qscintilla
version             2.4.6
revision            0
categories          devel
maintainers         adfernandes openmaintainer
description         QScintilla is a port to Qt of Neil Hodgson's Scintilla C++ editor control.
homepage            http://www.riverbankcomputing.com/software/qscintilla/
platforms           darwin

long_description    QScintilla is a port to Qt of Neil Hodgson's Scintilla C++ editor control. \
                	As well as features found in standard text editing components,		\
                	QScintilla includes features especially useful when editing and		\
                	debugging source code. These include support for syntax styling,	\
                	error indicators, code completion and call tips. The selection		\
                	margin can contain markers like those used in debuggers to indicate	\
                	breakpoints and the current line. Styling choices are more open		\
                	than with many editors, allowing the use of proportional fonts,		\
                	bold and italics, multiple foreground and background colours and	\
                	multiple fonts. See the py*-qscintilla port to install python bindings.

#
# NOTE: the version of this port must be kept in sync with the 'py*-qscintilla' port(s),
#       since they contain the python bindings!
#

distname            QScintilla-gpl-${version}
master_sites        http://www.riverbankcomputing.com/static/Downloads/QScintilla2/ \
                    http://gentoo.mirrors.easynews.com/linux/gentoo/distfiles/ \
                    http://www.gtlib.gatech.edu/pub/gentoo/distfiles/ \
                    http://gentoo.osuosl.org/distfiles/

checksums           md5     424a89736b900e6ca5bc6d929cdafaf8 \
                    sha1    0527feedf74186a02ca0757d71be0c790149f674 \
                    rmd160  b48880e3e0fa0d285f04bf7ceb509f509d684929

universal_variant   yes

# fix up QMake .pro files for +debug, if selected; also fixed up the
# library and header paths to include .. and ../Qt4 before others.
patchfiles-append   patch-add_debug.diff

post-patch {
    # allow for universal and non-native building, if desired, by
    # fixing up the QMake .pro files.
    reinplace "s/@ARCHES@/${qt_arch_types}/" \
        ${worksrcpath}/Qt4/qscintilla.pro
    reinplace "s/@ARCHES@/${qt_arch_types}/" \
        ${worksrcpath}/designer-Qt4/designer.pro

    # fix up 'Platform.h's, to avoid a conflict with the port 'tidy's
    # 'platform.h'.
    foreach fixfile [exec grep -lr \"Platform\.h\" ${worksrcpath}] {
        reinplace "s@\"Platform\.h\"@\"include/Platform\.h\"@g" ${fixfile}
    }

    # fix up .pro files to handle debug and release
    set build_type "release"
    if {[variant_isset debug]} {
        set build_type "debug_and_release build_all"
    }
    reinplace "s/@BUILD_TYPE@/${build_type}/" \
        ${worksrcpath}/designer-Qt4/designer.pro
    reinplace "s/@BUILD_TYPE@/${build_type}/" \
        ${worksrcpath}/Qt4/qscintilla.pro

    # drop in a simple QMake file, for easy building
    copy ${filespath}/Qsci.pro ${worksrcpath}

    # rename QMake .pro files in subdirs to work with top-level file
    move ${worksrcpath}/Qt4/qscintilla.pro \
        ${worksrcpath}/Qt4/Qt4.pro
    move ${worksrcpath}/designer-Qt4/designer.pro \
        ${worksrcpath}/designer-Qt4/designer-Qt4.pro
}

# QMake does not handle this flag.
configure.universal_args-delete --disable-dependency-tracking
configure.args-delete  --disable-dependency-tracking

configure.pre_args
configure.cmd ${qt_qmake_cmd}

# allow ccache, if specified by the user
pre-build {
    if {[tbool configure.ccache]} {
        build.post_args "CCACHE=ccache"
    }
}

variant debug \
description {Produce both release and debug library and plugin} {}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     QScintilla-gpl-\(\\d+.\\d+.\\d+\).tar.gz
