--- /opt/local/var/macports/sources/svn.macports.org/trunk/dports/devel/qt5-creator-mac/Portfile	2015-01-12 12:43:01.000000000 +0100
+++ /opt/local/site-ports/devel/qt5-creator-mac/Portfile	2015-05-29 22:21:48.000000000 +0200
@@ -1,4 +1,5 @@
 # -*- 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
+# kate: backspace-indents true; indent-pasted-text true; indent-width 4; keep-extra-spaces true; remove-trailing-spaces modified; replace-tabs true; replace-tabs-save true; syntax Tcl/Tk; tab-indents true; tab-width 4;
 # $Id: Portfile 127658 2014-10-31 18:21:47Z mcalhoun@macports.org $
 
 PortSystem          1.0
@@ -9,46 +10,135 @@
     universal_variant no
     supported_archs   noarch
 }
+
 PortGroup           qmake5 1.0
+# universal build hasn't been tested (20150410)
+# universal_variant   no
 
-version             3.2.2
 categories          devel aqua
 platforms           darwin
 license             LGPL-2.1
-maintainers         mcalhoun openmaintainer
+maintainers         gmail.com:rjvbertin mcalhoun 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.
+installs_libs       no
+
+homepage            http://wiki.qt.io/Category:Tools::QtCreator
+
+subport ${name}-devel {
+    set use_git         yes
+    if {${use_git}} {
+        depends_fetch-append port:git
+        fetch.type      git
+        git.url     git://code.qt.io/qt-creator/qt-creator.git
+        git.branch      51bb521
+        set qbs.branch  760dc4e
+        version         3.4.0.638.g${git.branch}
+        distname        qt-creator-opensource-src-3.4.x
+        fetch {
+            # I don't see any provisions for git submodules in MacPorts, so we have to clone by hand:
+            system "${prefix}/bin/git clone --depth=1 --no-single-branch --recursive -q ${git.url} ${workpath}/${worksrcdir}"
+            system "cd ${workpath}/${worksrcdir} ; ${prefix}/bin/git checkout -q ${git.branch}"
+            system "cd ${workpath}/${worksrcdir}/src/shared/qbs ; ${prefix}/bin/git checkout -q ${qbs.branch}"
+        }
+        # hopefully temporary patches:
+        patchfiles-append \
+                        patch-missing-botan-headers.diff \
+                        patch-coreplugin+CoreServices.diff
+    } else {
+        version         3.4.0
+        master_sites    https://download.qt.io/official_releases/qtcreator/[join [lrange [split ${version} .] 0 1] .]/${version}/
+
+        distname        qt-creator-opensource-src-${version}
+        checksums       rmd160  de85ab935a094e94a8e8864406d82dbb57b3233a \
+                        sha256  b80baf5be9b0421b3d951a8a0eb411a65cf008f4c753f5a80d205e90fa4fe112
+        livecheck.type  regex
+        livecheck.url   http://www.qt.io/download-open-source/
+        livecheck.regex qt-creator-opensource-src-(\[a-z0-9.\]+)${extract.suffix}
+    }
 
-homepage            http://qt-project.org/wiki/Category:Tools::QtCreator
-distname            qt-creator-opensource-src-${version}
-master_sites        https://download.qt-project.org/official_releases/qtcreator/[join [lrange [split ${version} .] 0 1] .]/${version}/
+    # don't let QtCreator set up a global Mac-style menubar when using the xcb plugin
+    patchfiles-append   devel/patch-show-menubar-with-xcb.diff
+}
+#else
+if { ${subport} ne "${name}-devel" } {
+#     version         3.3.2
+#     master_sites    https://download.qt.io/official_releases/qtcreator/[join [lrange [split ${version} .] 0 1] .]/${version}/
+#
+#     distname        qt-creator-opensource-src-${version}
+#     checksums       rmd160  faeff05d1d58f3eb4666618221a3775239f4c6ec \
+#                     sha256  6ef76d23c778a58caffb487b8bc6a192defa2d5dd5fab1ecf8eb70d53ccfb98a
+#     livecheck.type  regex
+#     livecheck.url   http://www.qt.io/download-open-source/
+#     livecheck.regex qt-creator-opensource-src-(\[a-z0-9.\]+)${extract.suffix}
+    version         3.4.0
+    master_sites    https://download.qt.io/official_releases/qtcreator/[join [lrange [split ${version} .] 0 1] .]/${version}/
+
+    distname        qt-creator-opensource-src-${version}
+    checksums       rmd160  de85ab935a094e94a8e8864406d82dbb57b3233a \
+                    sha256  b80baf5be9b0421b3d951a8a0eb411a65cf008f4c753f5a80d205e90fa4fe112
+    livecheck.type  regex
+    livecheck.url   http://www.qt.io/download-open-source/
+    livecheck.regex qt-creator-opensource-src-(\[a-z0-9.\]+)${extract.suffix}
 
-checksums           rmd160  5c85bfb5dc02c3639453421dd48355c8b4aa8145 \
-                    sha256  a115f1d7b08446dcfeb79537f3d8d251dbc3c9808d0ff377efe5c4fad7dbd8f0
+    patchfiles-append   patch-show-menubar-with-xcb.diff
+}
+# don't set up a Dock menu when using the xcb plugin
+patchfiles-append   patch-no-dockmenu-xcb.diff
 
-if { ${subport} eq ${name}  } {
+if { ${subport} eq ${name} || ${subport} eq "${name}-devel" } {
     depends_lib-append     port:botan
     configure.args-append  "USE_SYSTEM_BOTAN=1"
-        
+
+    post-fetch            {
+        file mkdir ${workpath}/build
+        if {${use_git} && (${subport} eq "${name}-devel")} {
+            catch {eval exec sh -c "\"cd ${workpath}/${worksrcdir} ; git submodule update --init\""} result
+            ui_debug "git submodule -init: $result"
+            if {[file exists ${filespath}/QC-git/.git]} {
+                reinplace -W ${workpath}/${worksrcdir} "s|qt-labs/qbs.git|files/QC-git/src/shared/qbs|g" .git/config
+            }
+            catch {eval exec sh -c "\"cd ${workpath}/${worksrcdir} ; git submodule update\""} result
+            ui_debug "git submodule: $result"
+        }
+    }
+    configure.args-append   ../${worksrcdir}/qtcreator.pro
+    default configure.dir   {${workpath}/build}
+    default build.dir       {${workpath}/build}
+
     if { ![variant_isset universal] } {
         destroot {
             # make install attempts to install command line tools into /bin, etc.
             xinstall -m 755 -d ${destroot}${qt_apps_dir}
-            copy "${worksrcpath}/bin/Qt Creator.app" "${destroot}${qt_apps_dir}"
+            copy "${build.dir}/bin/Qt Creator.app" "${destroot}${qt_apps_dir}"
+            reinplace "s|/usr/local|${prefix}|g" \
+                "${destroot}${qt_apps_dir}/Qt Creator.app/Contents/Resources/qbs/share/qbs/imports/qbs/Probes/PathProbe.qbs"
+            reinplace "s|/usr/local/lib|${qt_frameworks_dir}|g" \
+                "${destroot}${qt_apps_dir}/Qt Creator.app/Contents/Resources/qbs/share/qbs/imports/qbs/Probes/FrameworkProbe.qbs"
         }
     } else {
         # We should really just override destroot, but the muniversal Portgroup would override our override.
         destroot.cmd "true"
         merger-post-destroot {
             foreach arch ${universal_archs_to_use} {
-                xinstall -m 755 -d ${destroot}-${arch}${qt_apps_dir}
-                copy "${worksrcpath}-${arch}/bin/Qt Creator.app" "${destroot}-${arch}${qt_apps_dir}"
+                set adest ${destroot}-${arch}${qt_apps_dir}
+                xinstall -m 755 -d ${adest}
+                copy "${worksrcpath}-${arch}/bin/Qt Creator.app" "${adest}"
+                reinplace "s|/usr/local/|${prefix}/|g" \
+                    "${adest}/Qt Creator.app/Contents/Resources/qbs/share/qbs/imports/qbs/Probes/FrameworkProbe.qbs" \
+                    "${adest}/Qt Creator.app/Contents/Resources/qbs/share/qbs/imports/qbs/Probes/PathProbe.qbs"
             }
         }
     }
+    post-destroot {
+        xinstall -m 755 -d ${destroot}/${qt_bins_dir}
+        ln -s "${qt_apps_dir}/Qt Creator.app/Contents/MacOS/Qt Creator" ${destroot}/${qt_bins_dir}/qtcreator
+        copy ${filespath}/qtcreator-remote ${destroot}/${qt_bins_dir}
+        reinplace "s|@@QT_APPS_DIR@@|${qt_apps_dir}|g" ${destroot}/${qt_bins_dir}/qtcreator-remote
+    }
 }
 
-use_parallel_build  no
+#use_parallel_build  no
 
 subport ${name}-docs {
     depends_lib-append port:${name} port:qt5-mac-sqlite3-plugin 
@@ -75,6 +165,3 @@
     destroot.target -f Makefile.static INSTALL_ROOT=${destroot}${prefix} install_examples
 }
 
-livecheck.type      regex
-livecheck.url       http://www.qt.io/download-open-source/
-livecheck.regex     qt-creator-opensource-src-(\[a-z0-9.\]+)${extract.suffix}"
