--- /opt/local/var/macports/sources/svn.macports.org/trunk/dports/kde/qtcurve/Portfile	2015-12-31 14:29:14.000000000 +0100
+++ /opt/local/site-ports/kde/QtCurve/Portfile	2015-12-31 17:32:37.000000000 +0100
@@ -1,16 +1,28 @@
 # -*- 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 141605 2015-10-22 20:56:07Z mk@macports.org $
-# kde/libkgapi/Portfile
+# 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 Thu Jun  5 12:10:38 UTC 2014 rjvbertin@gmail.com $
 
 PortSystem          1.0
 
 fetch.type          git
-git.url             git://anongit.kde.org/qtcurve.git
-git.branch          e3e2325e
+if {[file exists ${filespath}/QtCurve-git/.git]} {
+    git.url         ${filespath}//QtCurve-git
+} else {
+    git.url         git://anongit.kde.org/qtcurve.git
+}
 
 name                QtCurve
 set qtc_version     1.8.18
-version             ${qtc_version}.20150127
+if {${subport} ne "${name}-gtk2"} {
+#     git.branch      a3fff13ed5a362064c7abee8485e224be945cdc6
+#     version         ${qtc_version}.20150711
+    git.branch      330bfa56785d329aedfbb20a61e58705f725ded9
+    version         ${qtc_version}.20151017
+} else {
+    # newer GTk2 engine versions have issues with respecting the selected font and "icons in buttons" setting
+    git.branch      e3e2325e
+    version         ${qtc_version}.20150127
+}
 revision            1
 
 description         A set of widget styles for Qt4/KDE4, Qt5/KF5 and/or GTk2 based apps.
@@ -29,23 +41,28 @@
 
 worksrcdir          ${name}-${qtc_version}
 
-subport qt5-${name} {
-    replaced_by     ${name}-qt5
-    PortGroup       obsolete 1.0
-}
+PortGroup           muniversal 1.0
+
+test.run            yes
 
+# this port should probably be replaced by kf5-${qtcurve}
 subport ${name}-qt5 {
-    # 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
+    if {![variant_isset qtonly]} {
+        long_description        A highly configurable widget style for Qt5/KF5
+    } else {
+        long_description        A highly configurable widget style for Qt5
+    }
+}
 
-    PortGroup               qt5 1.0
+if {${os.platform} eq "darwin" && ${os.major} <= 10} {
+    depends_build-delete    port:clang-3.4 port:clang-3.5
+    ui_msg "This port only builds with configure.compiler=macports-gcc-4.7 (from port:gcc47) or newer on OS X 10.6"
 }
 
 subport ${name}-gtk2 {
     PortGroup               cmake 1.0
+    cmake.out_of_source     yes
+    long_description        The GTk2 version of the highly configurable QtCurve widget style for Qt
 
     post-extract            { file mkdir ${workpath}/build }
     # standard post-arg, where to find the primary CMakeLists.txt file.
@@ -53,27 +70,102 @@
     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 \
+    variant LTO description {Build with Link-Time Optimisation (LTO) (currently not 100% compatible with SSE4+ and 3DNow intrinsics)} {
+        configure.cflags-append     -flto
+        configure.cxxflags-append   -flto
+        configure.objcflags-append  -flto
+        configure.objcxxflags-append  -flto
+        configure.ldflags-append    -flto
+        # assume any compiler not clang will be gcc
+        if {![string match "*clang*" ${configure.compiler}]} {
+            configure.cflags-append         -fuse-linker-plugin -ffat-lto-objects
+            configure.cxxflags-append       -fuse-linker-plugin -ffat-lto-objects
+            configure.objcflags-append      -fuse-linker-plugin -ffat-lto-objects
+            configure.objcxxflags-append    -fuse-linker-plugin -ffat-lto-objects
+            configure.ldflags-append        -fuse-linker-plugin
+        }
+    }
+    depends_lib-append      port:gtk2
+    depends_run-append      port:perl5
+    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"
 }
 
-if {${subport} ne "${name}-gtk2"} {
+subport ${name}-extra {
+    long_description        Additional configuration presets and colour palettes for QtCurve
+    use_configure           no
+    installs_libs           no
+    supported_archs         noarch
+    fetch {}
+    checksum {}
+    extract {}
+    build {}
+    destroot {
+        xinstall -m 755 -d ${destroot}/${prefix}/share/apps/kstyle/themes
+        xinstall -m 755 -d ${destroot}/${prefix}/share/apps/color-schemes
+        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}/qtc_qtcurve-osxgraphite.themerc ${destroot}/${prefix}/share/apps/kstyle/themes/
+        xinstall -m 644 ${filespath}/qtc_qtcurve-osxgraphite-qt5.themerc ${destroot}/${prefix}/share/apps/kstyle/themes/
+        xinstall -m 644 ${filespath}/QtCurveOSX.colors ${destroot}/${prefix}/share/apps/color-schemes/
+        xinstall -m 644 ${filespath}/OxygenOSXGraphite.colors ${destroot}/${prefix}/share/apps/color-schemes/
+    }
+}
+
+if {${subport} ne "${name}-extra"} {
+    depends_run-append      port:${name}-extra
+}
+
+if {(${subport} ne "${name}-gtk2") && (${subport} ne "${name}-extra")} {
     if {${subport} eq "${name}-qt5"} {
 
         categories              kde kf5 qt5
 
+        if {![variant_isset qtonly]} {
+            PortGroup               kf5 1.1
+            long_description        A highly configurable widget style for Qt5/KF5
+            depends_build-append    port:gettext \
+                                    ${kf5.pythondep}
+            kf5.depends_frameworks  karchive kconfig kconfigwidgets \
+                                    ki18n kdelibs4support kguiaddons kio \
+                                    kiconthemes kwidgetsaddons kxmlgui
+            # (to be) submitted upstream:
+            patchfiles-append       patch-reenable-kf5-support.diff \
+                                    patch-respect-buttonhaveicons.diff
+            # these address the rendering issue that has long altered the appearance of
+            # checks, radiobuttons and round sliders
+            patchfiles-append       patch-qt5-always-antialias.diff \
+                                    patch-qt5-fix-appearance.diff
+            configure.args-append   -DPYTHON_EXECUTABLE=${prefix}/bin/python${kf5.pyversion} \
+                                    -DQTC_QT5_ENABLE_KDE:BOOL=ON
+            unset kf5.allow_docs_generation
+            notes-append            "Install port:kf5-frameworkintegration and set KDE_SESSION_VERSION to 5 \
+                                    (launchctl setenv KDE_SESSION_VERSION 5 and the equivalent expr. in your login script) \
+                                    in order to use this or any other KDE theme automatically in Qt5 and KF5 \
+                                    applications."
+        } else {
+            PortGroup               cmake 1.0
+            # Prefer port:qt5-kde if the user hasn't installed a Qt5 port yet.
+            # This *is* a KDE style after all.
+            set qt5.prefer_kde      1
+            PortGroup               qt5 1.0
+            long_description        A highly configurable widget style for Qt5
+            configure.args-append   -DQTC_QT5_ENABLE_KDE:BOOL=OFF
+        }
+        cmake.out_of_source     yes
+
+        # CMake will look for automoc4, but will of course not use it.
         configure.args-append   -DENABLE_QT4:BOOL=OFF -DENABLE_QT5:BOOL=ON \
-                                -DQTC_QT4_ENABLE_KDE:BOOL=OFF -DQTC_QT5_ENABLE_KDE:BOOL=ON \
+                                -DQTC_QT4_ENABLE_KDE:BOOL=OFF \
                                 -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"
+        # looks like this is not going to be relevant, as KF5 plugins install into Qt5's plugin dir:
+#         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 port:qt5-mac+KDE or port:qt5-kde"
 
     } else {
 
@@ -81,9 +173,13 @@
 
         if { [variant_isset qtonly] } {
             PortGroup           qt4 1.0
+            PortGroup           cmake 1.0
+            cmake.out_of_source yes
+            long_description    A highly configurable widget style for Qt4
         } else {
             PortGroup           kde4 1.1
             depends_lib-append  port:kdelibs4
+            long_description    A highly configurable widget style for Qt4/KDE4
         }
 
         configure.args-append   -DENABLE_QT4:BOOL=ON -DENABLE_QT5:BOOL=OFF \
@@ -91,11 +187,14 @@
 
         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"
+         with the appropriate privileges or install port:qt4-mac+KDE"
     }
 
     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
+                                -DQTC_ENABLE_PO:BOOL=ON -DENABLE_GTK2:BOOL=OFF
+    if {${os.platform} eq "darwin"} {
+        configure.args-append   -DQTC_ENABLE_X11:BOOL=OFF
+    }
 
     variant qtonly description {Build only Qt style support, for installations without KDE} {}
 
@@ -105,24 +204,25 @@
     } else {
 
         post-destroot {
-            if {${subport} ne "${name}-qt5"} {
-                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/
+            if {${subport} eq "${name}-qt5"} {
+            } else {
                 xinstall -d -m 755 ${destroot}${prefix}/share/qt4/plugins
                 if {[file exists ${qt_plugins_dir}] && ![file exists ${qt_plugins_dir}/styles]} {
-                    ln -s ${prefix}/lib/kde4/plugins/styles ${destroot}${qt_plugins_dir}/
+                    system "ln -s ${prefix}/lib/kde4/plugins/styles ${destroot}${qt_plugins_dir}/"
                 }
             }
         }
 
     }
-
 }
 
 variant devel description {Prevent stripping of binaries} {}
 if { [variant_isset devel] } {
-	configure.args-delete -DCMAKE_BUILD_TYPE=Release
-	configure.args-append -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_STRIP:FILEPATH=/bin/echo
+    if {${subport} eq "${name}"} {
+        ui_debug "Requested an obsolete variant that is now handled through the KDE4 PortGroup"
+    } else {
+        configure.args-delete -DCMAKE_BUILD_TYPE=Release
+        configure.args-append -DCMAKE_BUILD_TYPE:STRING=MacPorts -DCMAKE_STRIP:FILEPATH=/bin/echo
+    }
 }
 
