--- /opt/local/site-ports/kde/QtCurve/macports-current/Portfile	2014-10-01 23:31:04.000000000 +0200
+++ /opt/local/site-ports/kde/QtCurve/Portfile	2015-01-09 21:21:44.000000000 +0100
@@ -1,20 +1,18 @@
 # -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
-# $Id: Portfile 126006 2014-10-01 21:17:50Z mk@macports.org $
+# $Id: Portfile Thu Jun  5 12:10:38 UTC 2014 rjvbertin@gmail.com $
 # kde/libkgapi/Portfile
 
 PortSystem          1.0
-PortGroup           kde4 1.1
 
 fetch.type          git
 git.url             git://anongit.kde.org/qtcurve.git
-git.branch          660f859556471f13834ef4fb095816639aa85014
+git.branch          6a54902
 
 name                QtCurve
 version             1.8.18
+revision            20150106
 
-categories          kde kde4
-
-description         A set of widget styles for Qt4/KDE4 based apps.
+description         A set of widget styles for Qt4/KDE4, Qt5/KF5 and/or GTk2 based apps.
 
 platforms           darwin
 license             LGPL-2+
@@ -29,34 +27,97 @@
 livecheck.url       http://quickgit.kde.org/?p=qtcurve.git
 livecheck.regex     (\\d+(\\.\\d+)+)
 
-depends_lib-append  port:gtk2 \
-                    port:kdelibs4 \
-                    port:qt4-mac
-
-configure.args-append   -DQTC_QT4_STYLE_SUPPORT:BOOL=OFF -DENABLE_QT5:BOOL=OFF \
-                        -DQTC_QT4_ENABLE_KWIN:BOOL=OFF
-
-variant x11 description {build x11 support} {}
-if { [variant_isset x11] } {
-	depends_lib-append port:xorg-libX11
-	configure.args-append -DQTC_ENABLE_X11:BOOL=ON
-} else {
-	configure.args-append -DQTC_ENABLE_X11:BOOL=OFF
+# add an infix to libqtcurve-utils.dylib, so that it can exist in specific forms for Qt4, Qt5 and GTk2
+# this is a -p1 patchfile
+patch.pre_args      -p1
+patchfiles-append   add-utilslib-infix.patch
+
+subport qt5-${name} {
+    # replace this with the KF5 portgroup when it exists!!
+    PortGroup               kde4 1.1
+    # remove dependencies pulled in by the kde4 portgroup:
+    depends_build-delete    port:automoc
+    depends_lib-delete      port:phonon port:doxygen port:qt4-mac
+
+    PortGroup               qt5 1.0
 }
 
-variant gtk2 description {build the gtk2 plugin} {}
-if { [variant_isset gtk2] } {
-	depends_lib-append port:gtk2
-	configure.args-append -DENABLE_GTK2:BOOL=ON
-} else {
-	configure.args-append -DENABLE_GTK2:BOOL=OFF
+subport ${name}-gtk2 {
+    PortGroup               cmake 1.0
+
+    post-extract            { file mkdir ${workpath}/build }
+    # standard post-arg, where to find the primary CMakeLists.txt file.
+    default configure.post_args {../${worksrcdir}}
+    default configure.dir       {${workpath}/build}
+    default build.dir           {${workpath}/build}
+
+	depends_lib-append      port:gtk2
+	configure.args-delete   -DQTC_ENABLE_X11:BOOL=OFF
+	configure.args-append   -DENABLE_GTK2:BOOL=ON -DQTC_ENABLE_X11:BOOL=ON \
+                            -DENABLE_QT4:BOOL=OFF -DENABLE_QT5:BOOL=OFF \
+                            -DQTC_QT4_ENABLE_KDE:BOOL=OFF -DQTC_QT5_ENABLE_KDE:BOOL=OFF \
+                            -DQTC_UTILSLIB_INFIX:STRING="gtk2"
 }
 
-variant qt5 description {build for qt5 too} {}
-if { [variant_isset qt5] } {
-	depends_lib-append port:qt5-mac
-	# default for ENABLE_QT5=on:
-	configure.args-delete -DENABLE_QT5:BOOL=OFF
+if {${subport} ne "${name}-gtk2"} {
+    if {${subport} eq "qt5-${name}"} {
+
+        categories              kde kf5 qt5
+
+        depends_lib-append      port:qt5-mac
+
+        configure.args-append   -DENABLE_QT4:BOOL=OFF -DENABLE_QT5:BOOL=ON \
+                                -DQTC_QT4_ENABLE_KDE:BOOL=OFF -DQTC_QT5_ENABLE_KDE:BOOL=ON \
+                                -DQTC_UTILSLIB_INFIX:STRING="qt5"
+
+        # not sure if this is going to be relevant:
+        notes-append "To access QtCurve and other KDE styles from pure Qt5 applications, execute
+         ln -s ${prefix}/lib/kf5/plugins/styles (???) ${prefix}/share/qt5/plugins
+         with the appropriate privileges or install qt5-mac's +KDE variant"
+
+    } else {
+
+        categories              kde kde4 qt4
+
+        PortGroup               kde4 1.1
+
+        depends_lib-append      port:kdelibs4 \
+                                port:qt4-mac
+
+        configure.args-append   -DENABLE_QT4:BOOL=ON -DENABLE_QT5:BOOL=OFF \
+                                -DQTC_QT5_ENABLE_KDE:BOOL=OFF -DQTC_UTILSLIB_INFIX:STRING="qt4"
+
+        notes-append "To access QtCurve and other KDE styles from pure Qt4 applications, execute
+         ln -s ${prefix}/lib/kde4/plugins/styles ${prefix}/share/qt4/plugins
+         with the appropriate privileges or install qt4-mac's +KDE variant"
+    }
+
+    configure.args-append       -DQTC_QT4_STYLE_SUPPORT:BOOL=OFF -DQTC_QT4_ENABLE_KWIN:BOOL=OFF \
+                                -DQTC_ENABLE_PO:BOOL=ON -DENABLE_GTK2:BOOL=OFF -DQTC_ENABLE_X11:BOOL=OFF
+
+    variant qtonly description {Build only Qt style support, for installations without KDE} {}
+
+    if { [variant_isset qtonly] } {
+        depends_lib-delete    port:kdelibs4
+        configure.args-append -DQTC_QT4_ENABLE_KDE:BOOL=OFF -DQTC_QT5_ENABLE_KDE:BOOL=OFF
+        configure.args-delete -DQTC_QT4_ENABLE_KDE:BOOL=ON -DQTC_QT5_ENABLE_KDE:BOOL=ON
+    } else {
+
+        post-destroot {
+            if {${subport} eq "qt5-${name}"} {
+            } else {
+                xinstall -m 644 ${filespath}/qtc_qtcurve-rjvb.themerc ${destroot}/${prefix}/share/apps/kstyle/themes/
+                xinstall -m 644 ${filespath}/qtc_qtcurve-osx.themerc ${destroot}/${prefix}/share/apps/kstyle/themes/
+                xinstall -m 644 ${filespath}/QtCurveOSX.colors ${destroot}/${prefix}/share/apps/color-schemes/
+                xinstall -d -m 755 ${destroot}${prefix}/share/qt4/plugins
+                if {[file exists ${qt_plugins_dir}] && ![file exists ${qt_plugins_dir}/styles]} {
+                    system "ln -s ${prefix}/lib/kde4/plugins/styles ${destroot}${qt_plugins_dir}/"
+                }
+            }
+        }
+
+    }
+
 }
 
 variant devel description {Prevent stripping of binaries} {}
@@ -65,21 +126,3 @@
 	configure.args-append -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_STRIP:FILEPATH=/bin/echo
 }
 
-variant qtonly description {Build only Qt style support, for installations without KDE} {}
-if { [variant_isset qtonly] } {
-	depends_lib-delete    port:kdelibs4
-#	configure.args-append -DQTC_QT_ONLY:BOOL=ON
-	configure.args-append -DQTC_QT4_ENABLE_KDE:BOOL=OFF
-} else {
-    post-destroot {
-        xinstall -m 644 ${filespath}/qtc_qtcurve-rjvb.themerc ${destroot}/${prefix}/share/apps/kstyle/themes/
-        xinstall -m 644 ${filespath}/qtc_qtcurve-osx.themerc ${destroot}/${prefix}/share/apps/kstyle/themes/
-        xinstall -m 644 ${filespath}/QtCurveOSX.colors ${destroot}/${prefix}/share/apps/color-schemes/
-        xinstall -d -m 755 ${destroot}${prefix}/share/qt4/plugins
-        system "ln -s ${prefix}/lib/kde4/plugins/styles ${destroot}${prefix}/share/qt4/plugins"
-    }
-}
-
-notes-append "To access QtCurve and other KDE styles from pure Qt4 applications, execute
- ln -s ${prefix}/lib/kde4/plugins/styles ${prefix}/share/qt4/plugins
- with the appropriate privileges"
