--- /opt/local/var/macports/sources/git.macports.org/dports/multimedia/mlt/Portfile	2016-12-17 10:41:00.149095250 +0100
+++ Portfile	2017-01-30 18:03:39.545320633 +0100
@@ -1,13 +1,14 @@
 # -*- 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 145945 2016-02-22 08:53:45Z devans@macports.org $
 
 PortSystem          1.0
 PortGroup           muniversal 1.0
 
 name                mlt
 epoch               3
-version             6.4.1
+version             6.4.1 ; revision 1
 categories          multimedia
-maintainers         dennedy.org:dan gmail.com:rjvbertin openmaintainer
+maintainers         gmail.com:rjvbertin dennedy.org:dan openmaintainer
 license             GPL-2+
 
 description         Open source multimedia framework - core libraries
@@ -27,6 +28,11 @@
 checksums           rmd160  647cdad41974b93c5745a358e1129f2ed5f6e577 \
                     sha256  d3a992f3e67463e68630cb0b455d408a2a12f4da7a19e46807fa08a79f09b2b6
 
+subport qt5-${name} {
+    replaced_by     mlt-qt5
+    PortGroup       obsolete 1.0
+}
+
 subport ${name}-qt5 {
     description     ${description} - Qt5 version
     long_description \
@@ -34,43 +40,30 @@
 }
 
 if {${subport} eq "${name}"} {
-    conflicts       ${name}-qt5
+    conflicts       ${name}-qt5 qt5-${name}
     PortGroup       qt4 1.0
 } else {
     conflicts       ${name}
     PortGroup       qt5 1.0
-    if {[info procs qt5.depends_component] eq ""} {
-        # A procedure to indicate dependencies on Qt components that are not
-        # included in the default dependency declared by the Qt5 PortGroup.
-        # It allows to specify those dependencies without having to handle
-        # the appropriate path-style declarations that work against every Qt5 port
-        # (currently port:qt5, port:qt55, "soon" port:qt5-kde too.)
-        # A complete version of this procedure will be provided by the Qt5 PG
-        # after qt5-kde is introduced. Provide a simplified version in the meantime.
-        proc qt5.depends_component {first args} {
-            global os.major
-            # join ${first} and (the optional) ${args}
-            set args [linsert $args[set list {}] 0 ${first}]
-            # select the Qt5 port prefix, depending on OS version and which Qt5 port is installed
-            if {${os.major} == 11} {
-                set qt5pprefix  "qt55"
+    if {[info procs qt5.active_version] eq ""} {
+        proc qt5.active_version {} {
+            global prefix
+            if {[file exists ${prefix}/bin/pkg-config]} {
+                set av [exec ${prefix}/bin/pkg-config --modversion Qt5Core]
+                return ${av}
             } else {
-                set qt5pprefix  "qt5"
-            }
-            foreach comp ${args} {
-                if {${comp} eq "qt5"} {
-                    # in case one needs an explicit dependency on the Qt5 main port itself:
-                    depends_lib-append port:${qt5pprefix}
-                } else {
-                    set portname "${qt5pprefix}-${comp}"
-                    depends_lib-append port:${portname}
-                }
+                return 0.0.0
             }
         }
     }
 
     qt5.depends_component \
                     qtsvg
+    if {[vercmp [qt5.active_version] 5.7.0] >= 0} {
+        configure.cxxflags-append \
+                    -stdlib=libc++ \
+                    -std=c++11
+    }
 }
 
 depends_build-append port:git \
@@ -108,6 +101,17 @@
 configure.cflags-append     "-I${qt_includes_dir}"
 configure.ldflags-delete    "-L${prefix}/lib"
 
+# make sure the build system actually sees our settings by amending the toplevel config.mak.
+post-configure {
+    set config.mak [open ${worksrcpath}/config.mak "a"]
+    puts ${config.mak} "CC=${configure.cc}"
+    puts ${config.mak} "CXX=${configure.cxx}"
+    puts ${config.mak} "CFLAGS+=${configure.cflags}"
+    puts ${config.mak} "CXXFLAGS+=${configure.cxxflags}"
+    puts ${config.mak} "LDLAGS+=${configure.ldflags}"
+    close ${config.mak}
+}
+
 build.args-append           CC="${configure.cc}" CXX="${configure.cxx}" CPP="${configure.cpp}"
 
 if {[variant_isset universal]} {
