# -*- 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 107796 2013-07-05 21:30:11Z cal@macports.org $

PortSystem          1.0
PortGroup           qmake 1.0

name                qt4-creator-mac
version             2.7.2
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  048e66a3c47837e8db4a553f0d6a528f488e7f57 \
                    sha256  5df913faa43a5fbf44fb1f25faaf6d258134b8f9e6b8ef8a21277136dec9e189

depends_lib-append  port:botan

# 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"

# 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"
