# -*- 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 110344 2013-08-30 10:33:10Z cal@macports.org $

PortSystem          1.0
PortGroup           qmake 1.0

name                qt4-creator-mac
version             2.8.1
categories          devel aqua
platforms           darwin
license             LGPL-2.1
maintainers         sicherha.de:macports openmaintainer
description         Cross-platform integrated development environment (IDE) tailored to the needs of Qt developers.
long_description    Qt Creator is a cross-platform integrated development environment (IDE) tailored to the needs of Qt developers.

homepage            http://qt.digia.com/Product/developer-tools
distname            qt-creator-${version}-src
master_sites        https://download.qt-project.org/official_releases/qtcreator/[join [lrange [split ${version} .] 0 1] .]/${version}/

checksums           rmd160  9348896ff468a90e2c36260621c615c1ee89e82c \
                    sha256  d5ae007a297a4288d0e95fd605edbfb8aee80f6788c7a6cfb9cb297f50c364b9

depends_lib-append  port:botan \
                    port:qt4-mac-sqlite3-plugin

# fix up QMake build files to remove debug and release building;
# specify that here instead.
patchfiles          patch-remove_build_types.diff \
                    patch-macports-paths.diff

post-patch {
    # remove arch from QMake build scripts
    reinplace "/ppc/d" ${worksrcpath}/qtcreator.pri

    # add MacPorts-specific paths to the list of search paths for Qt binaries
    reinplace "s|@@PREFIX@@|${prefix}|" \
        ${worksrcpath}/src/libs/utils/environment.cpp
    reinplace "s|@@QT_APPS_DIR@@|${qt_apps_dir}|" \
        ${worksrcpath}/src/plugins/qtsupport/baseqtversion.cpp
}

pre-configure {
    # set arch type(s); done is a stage to make sure the 'options
    # qt_arch_types' is evaluated -after- +universal (if selected).
    configure.pre_args CONFIG+="${qt_arch_types}"

    # always build just the release, no debug
    configure.pre_args-append CONFIG+="release"
}

configure.args      "USE_SYSTEM_BOTAN=1"

build.target-append docs

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

destroot {
    xinstall -m 755 -d ${destroot}${qt_apps_dir}
    copy "${worksrcpath}/bin/Qt Creator.app" "${destroot}${qt_apps_dir}"
}

universal_variant   yes

livecheck.type      regex
livecheck.url       https://qt-project.org/downloads/
# Qt Creator >=2.6 requires Qt 4.8
livecheck.regex     "qt-creator-(2.\[0-9.-\]+)-src.zip"
