Index: Portfile
===================================================================
--- Portfile	(revision 148956)
+++ Portfile	(working copy)
@@ -1,36 +1,35 @@
 # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
 # $Id$
 
-PortSystem          1.0
-PortGroup           compiler_blacklist_versions 1.0
-PortGroup           active_variants 1.1
+PortSystem              1.0
+PortGroup               xcodeversion 1.0
+PortGroup               compiler_blacklist_versions 1.0
+PortGroup               active_variants 1.1
+PortGroup               conflicts_build 1.0
 
-# TODO
-# if {[file exists ${prefix}/etc/macports/locales.tcl]} {
-#     # experimental feature to cut down the NLS/locale files, which take up over 50% of
-#     # the install footprint for VLC. This feature loads the locale_select PortGroup
-#     # if its configuration file exist; a variant is then added which prunes all translations from
-#     # ${destroot}${prefix}/share/locale except those whitelisted in etc/macports/locales.tcl .
-#     PortGroup       locale_select 1.0
-# }
+if {[file exists ${prefix}/etc/macports/locales.tcl]} {
+    # experimental feature to cut down the NLS/locale files, which take up over 50% of
+    # the install footprint for VLC. This feature loads the locale_select PortGroup
+    # if its configuration file exist; a variant is then added which prunes all translations from
+    # ${destroot}${prefix}/share/locale except those whitelisted in etc/macports/locales.tcl .
+    PortGroup           locale_select 1.0
+}
 
-name                VLC
-version             2.2.2
-revision            4
+name                    VLC
 
-categories          multimedia devel
-maintainers         nomaintainer
+categories              multimedia devel
+maintainers             gmail.com:rjvbertin openmaintainer
 
-description         VLC is a cross-platform media player and streaming server
-long_description    VLC media player is a highly portable multimedia player for \
-                    various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, \
-                    mp3, ogg, ...) as well as DVDs, VCDs, and various streaming protocols. \
-                    It can also be used as a server to stream in unicast or multicast \
-                    in IPv4 or IPv6 on a high-bandwidth network.
+description             VLC is a cross-platform media player and streaming server
+long_description        VLC media player is a highly portable multimedia player for \
+                        various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, \
+                        mp3, ogg, ...) as well as DVDs, VCDs, and various streaming protocols. \
+                        It can also be used as a server to stream in unicast or multicast \
+                        in IPv4 or IPv6 on a high-bandwidth network.
 
-homepage            http://www.videolan.org
+homepage                http://www.videolan.org
 
-subport             lib${name} {
+subport lib${name} {
     maintainers         gmail.com:rjvbertin openmaintainer
     description         the core engine and interface to VLC's multimedia framework
     long_description    libVLC is the core engine and the interface to the multimedia \
@@ -40,434 +39,640 @@
     homepage            http://www.videolan.org/vlc/libvlc.html
 }
 
+subport ffmpeg-VLC {}
+set FFMPEG_VLC_PREFIX   ${prefix}/lib/vlc/ffmpeg
+
 if {${subport} eq ${name}} {
     conflicts           lib${name} libVLC-devel VLC-devel
 }
 
-license             GPL-2
+# VLC-2.1 and later are x86_64-only: https://trac.videolan.org/vlc/ticket/8161
+universal_variant       no
+supported_archs         x86_64
 
-platforms           darwin
+##
+###################  ports VLC and libVLC  ###################
+##
+if {(${subport} eq ${name}) || (${subport} eq "lib${name}")} {
+    version             2.2.3
+    license             GPL-2
 
-master_sites        http://download.videolan.org/pub/videolan/vlc/${version}/
-distname            vlc-${version}
-use_xz              yes
+    platforms           darwin
 
-checksums           rmd160  ff302536334622427e06250457c74f061d4329f8 \
-                    sha256  9ad23128be16f9b40ed772961272cb0748ed8e4aa1bc79c129e589feebea5fb5
+    master_sites        http://download.videolan.org/pub/videolan/vlc/${version}/
+    distname            vlc-${version}
+    use_xz              yes
 
-# Enable HFS compression.
-depends_extract-append      port:libarchive
-extract.post_args           "| bsdtar -x --hfsCompression"
+    checksums           rmd160  8c6d4194da37210fe409c965f430898fbe7f2416 \
+                        sha256  b9d7587d35f13c3c981964c8cc8b03f1c7c8edf528be476b3ca1d2efedd5bf5b
 
-depends_build       port:pkgconfig
+    # Enable HFS compression.
+    if {[file exists ${prefix}/bin/bsdtar]} {
+#         depends_extract-append      port:libarchive
+        extract.post_args \
+                        "| ${prefix}/bin/bsdtar -x --hfsCompression"
+    }
 
-depends_lib         port:a52dec \
-                    port:avahi \
-                    port:bzip2 \
-                    port:faad2 \
-                    path:lib/libavcodec.dylib:ffmpeg \
-                    port:flac \
-                    port:fluidsynth \
-                    port:fontconfig \
-                    port:freetype \
-                    port:fribidi \
-                    port:gettext \
-                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
-                    port:gmp \
-                    port:gnutls \
-                    port:jpeg \
-                    port:lame \
-                    port:libass \
-                    port:libbluray \
-                    port:libcddb \
-                    port:libcdio \
-                    port:libdc1394 \
-                    port:libdca \
-                    port:libdvbpsi \
-                    port:libdvdnav \
-                    port:libdvdread \
-                    port:libebml \
-                    port:libgcrypt \
-                    port:libgpg-error \
-                    port:libiconv \
-                    port:libid3tag \
-                    port:libidn \
-                    port:libmad \
-                    port:libmatroska \
-                    port:libmodplug \
-                    port:libmpcdec \
-                    port:libmpeg2 \
-                    port:libmtp \
-                    port:libogg \
-                    port:libopus \
-                    port:libpng \
-                    port:libproxy \
-                    port:libsamplerate \
-                    port:libsdl \
-                    port:libsdl_image \
-                    port:libsndfile \
-                    port:libssh2 \
-                    port:libtheora \
-                    port:libupnp \
-                    port:libusb \
-                    port:libvorbis \
-                    port:libvpx \
-                    port:libxml2 \
-                    port:live555 \
-                    port:ncurses \
-                    port:nettle \
-                    port:opencv \
-                    port:openjpeg15 \
-                    path:lib/libssl.dylib:openssl \
-                    port:orc \
-                    port:p11-kit \
-                    port:readline \
-                    port:schroedinger \
-                    port:speex \
-                    port:taglib \
-                    port:tiff \
-                    port:twolame \
-                    port:vcdimager \
-                    port:x264 \
-                    port:x265
+    depends_build       port:pkgconfig
 
-# the +qt5 and/or +qt4 variants of port:opencv currently lead to build errors
-pre-configure {
-    if {![active_variants opencv "" {qt4 qt5}]} {
-        ui_error "${subport} cannot currently be built against port:opencv with the qt4 or qt5 variant.\
-        Install port:opencv without either qt variant and try again. This is only a build conflict; \
-        after building you can reactivate your preferred opencv variant"
-        return -code error "Install or activate port:opencv without a qt variant before building ${subport}"
+    depends_lib         path:${FFMPEG_VLC_PREFIX}/lib/libavcodec.dylib:ffmpeg-VLC \
+                        port:a52dec \
+                        port:avahi \
+                        port:bzip2 \
+                        port:faad2 \
+                        port:flac \
+                        port:fluidsynth \
+                        port:fontconfig \
+                        port:freetype \
+                        port:fribidi \
+                        port:gettext \
+                        path:lib/pkgconfig/glib-2.0.pc:glib2 \
+                        port:gmp \
+                        port:gnutls \
+                        port:jpeg \
+                        port:lame \
+                        port:libass \
+                        port:libbluray \
+                        port:libcddb \
+                        port:libcdio \
+                        port:libdc1394 \
+                        port:libdca \
+                        port:libdvbpsi \
+                        port:libdvdnav \
+                        port:libdvdread \
+                        port:libebml \
+                        port:libgcrypt \
+                        port:libgpg-error \
+                        port:libiconv \
+                        port:libid3tag \
+                        port:libidn \
+                        port:libmad \
+                        port:libmatroska \
+                        port:libmodplug \
+                        port:libmpcdec \
+                        port:libmpeg2 \
+                        port:libmtp \
+                        port:libogg \
+                        port:libopus \
+                        port:libpng \
+                        port:libproxy \
+                        port:libsamplerate \
+                        port:libsdl \
+                        port:libsdl_image \
+                        port:libsndfile \
+                        port:libssh2 \
+                        port:libtheora \
+                        port:libupnp \
+                        port:libusb \
+                        port:libvorbis \
+                        port:libvpx \
+                        port:libxml2 \
+                        port:live555 \
+                        port:ncurses \
+                        port:nettle \
+                        port:openjpeg15 \
+                        path:lib/libssl.dylib:openssl \
+                        port:orc \
+                        port:p11-kit \
+                        port:readline \
+                        port:schroedinger \
+                        port:speex \
+                        port:taglib \
+                        port:tiff \
+                        port:twolame \
+                        port:vcdimager \
+                        port:x264 \
+                        port:x265
+
+    pre-fetch {
+        if {${os.platform} eq "darwin" && ${os.major} < 10} {
+            ui_error "${name} ${version} requires Mac OS X 10.6 or greater."
+            return -code error "incompatible Mac OS X version"
+        }
     }
-}
 
-# VLC 2.2.2 should have full Lua 5.3 compatibility, for now, depend on port:lua52
-# That requires the patch-for-lua52.diff which is appended to patchfiles below.
-# update 2.2.2 : lua 5.3 gives compiler syntax errors so we stick with 5.2 for now.
-depends_lib-append  port:lua52
-# depends_lib-append  port:lua
+# port:opencv depends on port:ffmpeg and thus enters in conflict with us depending on our own ffmpeg build
+# 1 viable solution as long as this is the case: drop the opencv filter.
+#     depends_lib-append  port:opencv
+#     # the +qt5 and/or +qt4 variants of port:opencv currently lead to build errors. A patch has
+#     # been submitted (but not included) that resolves the issue for qt4, not yet for qt5.
+#     # https://trac.macports.org/ticket/50709
+#     # For regular users a single check in the pre-fetch would suffice, but this maintainer
+#     # needs the check at other opportune moments too.
+#     proc check_opencv {} {
+#         global subport
+#         if {![active_variants opencv "" {qt4 qt5}]} {
+#             ui_error "${subport} cannot currently be built against port:opencv with the qt5 variant.\
+#             Install port:opencv without that variant and try again. This is only a build conflict; \
+#             after building you can reactivate your preferred opencv variant"
+#             return -code error "Install or activate port:opencv without the qt5 variant before building ${subport}"
+#         }
+#     }
+#     pre-fetch {
+#         check_opencv
+#     }
+#     pre-configure {
+#         check_opencv
+#     }
+#     pre-build {
+#         check_opencv
+#     }
+#     patchfiles-append   patch-opencv_includes.diff
+#     # The opencv example apparently builds on 10.11 but I'm having issues with it on 10.9
+#     # it doesn't appear to be indispensable, so simply skip it.
+#     patchfiles-append   patch-no-opencv_example.diff
 
-# VLC-2.1 and later are x86_64-only: https://trac.videolan.org/vlc/ticket/8161
-universal_variant   no
-supported_archs     x86_64
+    # VLC 2.2.2 should have full Lua 5.3 compatibility, for now, depend on port:lua52
+    # That requires the patch-for-lua52.diff which is appended to patchfiles below.
+    # update 2.2.2 : lua 5.3 gives compiler syntax errors so we stick with 5.2 for now.
+    depends_lib-append  port:lua52
+    # depends_lib-append  port:lua
 
-compiler.blacklist  gcc-4.2 llvm-gcc-4.2 {clang < 300}
+    # VLC doesn't currently build for me using port:clang-3.8
+    compiler.blacklist-append \
+                        gcc-4.2 llvm-gcc-4.2 macports-clang-3.8 {clang < 300}
 
-pre-fetch {
-    if {${os.platform} eq "darwin" && ${os.major} < 10} {
-        ui_error "${name} ${version} requires Mac OS X 10.6 or greater."
-        return -code error "incompatible Mac OS X version"
-    }
-}
+    patchfiles          buildfix-package.mak.patch \
+                        configure.ac-no-arch.patch \
+                        PR-34741-no__clang_version__.patch \
+                        static_assert.patch \
+                        no-sparkle.patch \
+                        patch-vlc-no-O4.diff
 
-patchfiles          buildfix-package.mak.patch \
-                    configure.ac-no-arch.patch \
-                    PR-34741-no__clang_version__.patch \
-                    static_assert.patch \
-                    no-sparkle.patch \
-                    patch-vlc-no-O4.diff \
-                    patch-opencv_includes.diff
+    post-patch {
+        reinplace "s:librsvg-2/librsvg:librsvg:" \
+            ${worksrcpath}/modules/text_renderer/svg.c
 
-# The opencv example apparently builds on 10.11 but I'm having issues with it on 10.9
-# it doesn't appear to be indispensable, so simply skip it.
-patchfiles-append   patch-no-opencv_example.diff
+        if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} == "libc++"} {
+            reinplace "s:-lstdc\+\+:-lc++:" \
+                ${worksrcpath}/configure.ac \
+                ${worksrcpath}/modules/access/Makefile.am
+        }
+    }
+    post-configure {
+        system -W ${worksrcpath} "patch -Np0 -i ${filespath}/patch-static_assert.diff"
+    }
 
-post-patch {
-    reinplace "s:librsvg-2/librsvg:librsvg:" \
-        ${worksrcpath}/modules/text_renderer/svg.c
+    use_autoreconf      yes
+    autoreconf.cmd      ./bootstrap
+    autoreconf.pre_args
+    autoreconf.args
+    depends_build-append port:libtool port:autoconf port:automake
 
-    if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} == "libc++"} {
-        reinplace "s:-lstdc\+\+:-lc++:" \
-            ${worksrcpath}/configure.ac \
-            ${worksrcpath}/modules/access/Makefile.am
-    }
-}
+    configure.env-append \
+                        CXXCPP="${configure.cxx} -E"
+    # splice in ffmpeg-VLC's pkgconfig path, hoping that PKG_CONFIG_PATH hasn't been set by anyone else
+    configure.env-append \
+                        PKG_CONFIG_PATH=${FFMPEG_VLC_PREFIX}/lib/pkgconfig
+    build.args-append   DESTDIR=${worksrcpath}/dest_ignore V=1
 
-use_autoreconf      yes
-autoreconf.cmd      ./bootstrap
-autoreconf.pre_args
-autoreconf.args
-depends_build-append port:libtool port:autoconf port:automake
+    # gl.c:121:3: error: Platform not recognized.
+    configure.cppflags-append -D__unix__=1
 
-configure.env-append CXXCPP="${configure.cxx} -E"
-build.args-append    DESTDIR=${worksrcpath}/dest_ignore V=1
+    # live555 is installed to a weird location
+    configure.cppflags-append -I${prefix}/lib/live/liveMedia/include
 
-# gl.c:121:3: error: Platform not recognized.
-configure.cppflags-append -D__unix__=1
+    build.target        all
+    destroot.target     install
 
-# live555 is installed to a weird location
-configure.cppflags-append -I${prefix}/lib/live/liveMedia/include
+    livecheck.url       http://download.videolan.org/pub/videolan/vlc/
+    livecheck.regex     <a href=\"(\\d\[\\d|\.|\\w\]+).*/\">
 
-build.target        all
-destroot.target     install
+    # Other
+    configure.args-append \
+                        --with-contrib=${worksrcpath}/contrib \
+                        --disable-debug --disable-update-check --enable-gnutls \
+                        --disable-notify --disable-dbus --enable-lua \
+                        --disable-gnomevfs --disable-growl --disable-macosx-vlc-app
 
-livecheck.url       http://download.videolan.org/pub/videolan/vlc/
-livecheck.regex     <a href=\"(\\d\[\\d|\.|\\w\]+).*/\">
+    # Input Plugins
+    configure.args-append \
+                        --enable-dvdnav --enable-dvdread --disable-smbclient --enable-vcdx \
+                        --disable-macosx-qtkit --disable-macosx-eyetv --disable-realrtsp \
+                        --disable-freerdp --disable-opencv --enable-sftp
 
-# Other
-configure.args-append \
-                    --with-contrib=${worksrcpath}/contrib \
-                    --disable-debug --disable-update-check --enable-gnutls \
-                    --disable-notify --disable-dbus --enable-lua \
-                    --disable-gnomevfs --disable-growl --disable-macosx-vlc-app
+    # Mux/Demux Plugins
+    configure.args-append \
+                        --enable-dvbpsi --enable-ogg --enable-mux_ogg \
+                        --enable-mkv --enable-mod --enable-mpc --disable-shout
 
-# Input Plugins
-configure.args-append \
-                    --enable-dvdnav --enable-dvdread --disable-smbclient --enable-vcdx \
-                    --disable-macosx-qtkit --disable-macosx-eyetv --disable-realrtsp \
-                    --disable-freerdp --enable-opencv --enable-sftp
+    # Codec Plugins
+    configure.args-append \
+                        --enable-a52 --enable-faad --enable-flac --enable-live555 \
+                        --enable-opus --enable-vorbis --enable-ogg --enable-mad --enable-libass \
+                        --enable-dca --enable-png --disable-quicktime --enable-twolame \
+                        --enable-speex --enable-theora --enable-x264 --enable-x265 --enable-postproc \
+                        --disable-gst-decode --enable-avcodec --enable-avformat --enable-swscale \
+                        --disable-fluidsynth --enable-schroedinger --enable-vpx
 
-# Mux/Demux Plugins
-configure.args-append \
-                    --enable-dvbpsi --enable-ogg --enable-mux_ogg \
-                    --enable-mkv --enable-mod --enable-mpc --disable-shout
+    # Video Plugins. We do our best to deactivate X11 and disable its auto-detection by
+    # claiming the headers and libs are somewhere they're not.
+    configure.args-append \
+                        --disable-caca --enable-sdl --enable-sdl-image \
+                        --without-x --disable-xcb --disable-xvideo \
+                        --x-includes=${destroot} --x-libraries=${destroot} \
+                        --enable-freetype --enable-fontconfig --enable-fribidi \
+                        --disable-svg --disable-svgdec
 
-# Codec Plugins
-configure.args-append \
-                    --enable-a52 --enable-faad --enable-flac --enable-live555 \
-                    --enable-opus --enable-vorbis --enable-ogg --enable-mad --enable-libass \
-                    --enable-dca --enable-png --disable-quicktime --enable-twolame \
-                    --enable-speex --enable-theora --enable-x264 --enable-x265 --enable-postproc \
-                    --disable-gst-decode --enable-avcodec --enable-avformat --enable-swscale \
-                    --disable-fluidsynth --enable-schroedinger --enable-vpx
+    # Audio Plugins
+    configure.args-append \
+                        --disable-jack \
+                        --enable-samplerate \
+                        --disable-pulse \
+                        --disable-chromaprint
 
-# Video Plugins. We do our best to deactivate X11 and disable its auto-detection by
-# claiming the headers and libs are somewhere they're not.
-configure.args-append \
-                    --disable-caca --enable-sdl --enable-sdl-image \
-                    --without-x --disable-xcb --disable-xvideo \
-                    --x-includes=${destroot} --x-libraries=${destroot} \
-                    --enable-freetype --enable-fontconfig --enable-fribidi \
-                    --disable-svg --disable-svgdec
+    # Interface Plugins
+    configure.args-append \
+                        --disable-macosx \
+                        --disable-macosx-dialog-provider \
+                        --disable-qt \
+                        --enable-ncurses \
+                        --disable-skins2 \
+                        --disable-vnc
 
-# Audio Plugins
-configure.args-append \
-                    --disable-jack \
-                    --enable-samplerate \
-                    --disable-pulse \
-                    --disable-chromaprint
+    # Visualisations and Video Filter Plugins
+    configure.args-append \
+                        --disable-goom
 
-# Interface Plugins
-configure.args-append \
-                    --disable-macosx \
-                    --disable-macosx-dialog-provider \
-                    --disable-qt \
-                    --enable-ncurses \
-                    --disable-skins2 \
-                    --disable-vnc
+    # Service Discovery Plugins
+    configure.args-append \
+                        --enable-bonjour \
+                        --enable-upnp
 
-# Visualisations and Video Filter Plugins
-configure.args-append \
-                    --disable-goom
+    # 20150209: Jack really would require a newer variant than what's currently in MacPorts
+    variant jack description {Enable jack and fluidsynth plugins for audio output} {
+        depends_lib-append      port:jack port:fluidsynth port:portaudio
+        configure.args-delete   --disable-jack --disable-fluidsynth
+        configure.args-append   --enable-jack --enable-fluidsynth
+    }
 
-# Service Discovery Plugins
-configure.args-append \
-                    --enable-bonjour \
-                    --enable-upnp
+    variant dbus description {Enable DBus support} {
+        depends_lib-append      port:dbus
+        configure.args-replace  --disable-dbus --enable-dbus
+    }
 
-# 20150209: Jack really would require a newer variant than what's currently in MacPorts
-variant jack description {Enable jack and fluidsynth plugins for audio output} {
-    depends_lib-append      port:jack port:fluidsynth port:portaudio
-    configure.args-delete   --disable-jack --disable-fluidsynth
-    configure.args-append   --enable-jack --enable-fluidsynth
-}
+    variant qtkit description {Enable qtcapture and qtaudio} {
+        configure.args-replace  --disable-macosx-qtkit --enable-macosx-qtkit
+    }
 
-variant dbus description {Enable DBus support} {
-    depends_lib-append      port:dbus
-    configure.args-replace  --disable-dbus --enable-dbus
-}
+    variant svg description {Enable SVG rendering and decoding support} {
+        depends_lib-append      port:librsvg
+        configure.args-replace  --disable-svg --enable-svg
+        configure.args-replace  --disable-svgdec --enable-svgdec
+    }
 
-variant qtkit description {Enable qtcapture and qtaudio} {
-    configure.args-replace  --disable-macosx-qtkit --enable-macosx-qtkit
-}
+    variant shout description {Enable Shoutcast/Icecast streaming output support} {
+        depends_lib-append      port:libshout2
+        configure.args-replace  --disable-shout --enable-shout
+    }
 
-variant svg description {Enable SVG rendering and decoding support} {
-    depends_lib-append      port:librsvg
-    configure.args-replace  --disable-svg --enable-svg
-    configure.args-replace  --disable-svgdec --enable-svgdec
-}
+    variant smb description {Enable Samba 3 input support} {
+        depends_lib-append      port:samba3
+        configure.args-replace  --disable-smbclient --enable-smbclient
+        configure.ldflags-append    -L${prefix}/lib/samba3
+    }
 
-variant shout description {Enable Shoutcast/Icecast streaming output support} {
-    depends_lib-append      port:libshout2
-    configure.args-replace  --disable-shout --enable-shout
-}
+    variant pulse description {Enable PulseAudio support} {
+        depends_lib-append      port:pulseaudio
+        configure.args-replace  --disable-pulse --enable-pulse
+    }
 
-variant smb description {Enable Samba 3 input support} {
-    depends_lib-append      port:samba3
-    configure.args-replace  --disable-smbclient --enable-smbclient
-    configure.ldflags-append    -L${prefix}/lib/samba3
-}
+    variant x11 {
+        depends_lib-append \
+            port:xorg-libX11 \
+            port:xorg-libXau \
+            port:xorg-libXdmcp \
+            port:xorg-libXext \
+            port:xorg-libXrandr \
+            port:xorg-libxcb \
+            port:xrender \
+            port:XviD \
+            port:mesa \
+            port:xorg-libXinerama \
+            port:xorg-libXv \
+            port:xorg-libXxf86vm \
+            port:xorg-xcb-util \
+            port:xorg-xcb-util-keysyms
 
-variant pulse description {Enable PulseAudio support} {
-    depends_lib-append      port:pulseaudio
-    configure.args-replace  --disable-pulse --enable-pulse 
-}
+        configure.args-delete   --without-x --disable-xvideo --disable-xcb \
+                                --x-includes=${destroot} --x-libraries=${destroot}
+        configure.args-append   --with-x --enable-xvideo --enable-xcb
+    }
 
-variant x11 {
-    depends_lib-append \
-        port:xorg-libX11 \
-        port:xorg-libXau \
-        port:xorg-libXdmcp \
-        port:xorg-libXext \
-        port:xorg-libXrandr \
-        port:xorg-libxcb \
-        port:xrender \
-        port:XviD \
-        port:mesa \
-        port:xorg-libXinerama \
-        port:xorg-libXv \
-        port:xorg-libXxf86vm \
-        port:xorg-xcb-util \
-        port:xorg-xcb-util-keysyms
+    if {${subport} ne "lib${name}"} {
+        variant qt4 conflicts qt5 description {Build using Qt4 UI. This will use qt4-mac. Experimental and probably dysfunctional} {
+            patchfiles-append       patch-vlc-no-qt5.diff \
+                                    patch-vlc-qt-configureac.diff \
+                                    patch-simplepreferences.diff
 
-    configure.args-delete   --without-x --disable-xvideo --disable-xcb \
-                            --x-includes=${destroot} --x-libraries=${destroot}
-    configure.args-append   --with-x --enable-xvideo --enable-xcb
-}
+            configure.args-replace  --disable-qt --enable-qt
 
-if {${subport} ne "lib${name}"} {
-    variant qt4 conflicts qt5 description {Build using Qt4 UI. This will use qt4-mac. Experimental and probably dysfunctional} {
-        patchfiles-append       patch-vlc-no-qt5.diff \
-                                patch-vlc-qt-configureac.diff \
-                                patch-simplepreferences.diff
+            PortGroup               qt4 1.0
+        }
+        variant qt5 conflicts qt4 description {Build using Qt5 UI. This will use qt5-mac. Experimental and probably dysfunctional} {
+            patchfiles-append       patch-vlc-qt-configureac.diff \
+                                    patch-simplepreferences.diff
 
-        configure.args-replace  --disable-qt --enable-qt
+            configure.args-replace  --disable-qt --enable-qt
 
-        PortGroup               qt4 1.0
+            PortGroup               qt5 1.0
+        }
     }
-    variant qt5 conflicts qt4 description {Build using Qt5 UI. This will use qt5-mac. Experimental and probably dysfunctional} {
-        patchfiles-append       patch-vlc-qt-configureac.diff \
-                                patch-simplepreferences.diff
 
-        configure.args-replace  --disable-qt --enable-qt
+    variant quartz {
+        depends_lib-delete      port:libsamplerate
+        depends_lib-append      port:BGHUDAppKit
 
-        PortGroup               qt5 1.0
+        patchfiles-append       patch-vlc-for-macports.diff
+
+        configure.args-delete   --disable-macosx \
+                                --enable-samplerate \
+                                --disable-realrtsp
+        configure.args-append   --enable-macosx
+        # taken from VLC's own configure.sh script for OS X:
+        configure.args-append   --disable-samplerate \
+                                --enable-merge-ffmpeg \
+                                --enable-realrtsp
     }
-}
 
-variant quartz {
-    depends_lib-delete      port:libsamplerate
-    depends_lib-append      port:BGHUDAppKit
+    # FreeRDP currently doesn't build with CMake >= 3.1 (#47389)
+    variant freerdp description {Build the FreeRDP support; currently dysfunctional} {
+        depends_lib-append          port:FreeRDP
+        # access/rdp.c:45:11: fatal error: 'freerdp/version.h' file not found
+        configure.cppflags-append   -DFREERDP_INTERFACE_VERSION \
+                                    -DFREERDP_VERSION_MAJOR=1 \
+                                    -DFREERDP_VERSION_MINOR=1
+        configure.args-replace      --disable-freerdp --enable-freerdp
+    }
 
-    patchfiles-append       patch-vlc-for-macports.diff
+    variant huge \
+        requires jack shout svg \
+        description {Enable all variants except quartz, smb, freerdp and x11} {}
 
-    configure.args-delete   --disable-macosx \
-                            --enable-samplerate \
-                            --disable-realrtsp
-    configure.args-append   --enable-macosx 
-    # taken from VLC's own configure.sh script for OS X:
-    configure.args-append   --disable-samplerate \
-                            --enable-merge-ffmpeg \
-                            --enable-realrtsp
-}
+    if {${subport} ne "lib${name}"} {
+        variant full \
+            requires huge quartz smb x11 \
+            description {Enable all variants except x11 (and except freerdp, currently)} {}
+    } else {
+        variant full \
+            requires huge quartz smb \
+            description {Enable all variants (except freerdp, currently)} {}
+    }
 
-# FreeRDP currently doesn't build with CMake >= 3.1 (#47389)
-variant freerdp description {Build the FreeRDP support; currently dysfunctional} {
-    depends_lib-append          port:FreeRDP
-    # access/rdp.c:45:11: fatal error: 'freerdp/version.h' file not found
-    configure.cppflags-append   -DFREERDP_INTERFACE_VERSION \
-                                -DFREERDP_VERSION_MAJOR=1 \
-                                -DFREERDP_VERSION_MINOR=1
-    configure.args-replace      --disable-freerdp --enable-freerdp
-}
+    # this patchfile can probably go with VLC 2.2.2, or should be reviewed then.
+    # update 2.2.2 : lua 5.3 gives compiler syntax errors so we stick with 5.2 for now.
+    patchfiles-append           patch-for-lua52.diff
 
-variant huge \
-    requires jack shout svg \
-    description {Enable all variants except quartz, smb, freerdp and x11} {}
+    platform macosx {
+        default_variants-append +quartz +qtkit
 
-if {${subport} ne "lib${name}"} {
-    variant full \
-        requires huge quartz smb x11 \
-        description {Enable all variants except x11 (and except freerdp, currently)} {}
-} else {
-    variant full \
-        requires huge quartz smb \
-        description {Enable all variants (except freerdp, currently)} {}
-}
+        configure.args-replace  --disable-macosx-eyetv --enable-macosx-eyetv
 
-# this patchfile can probably go with VLC 2.2.2, or should be reviewed then.
-# update 2.2.2 : lua 5.3 gives compiler syntax errors so we stick with 5.2 for now.
-patchfiles-append           patch-for-lua52.diff
+        if {${subport} ne "lib${name}"} {
+            configure.args-replace  --disable-macosx-vlc-app --enable-macosx-vlc-app
+        }
 
-platform macosx {
-    default_variants-append +quartz +qtkit
+        post-patch {
+            reinplace "s/Appkit/AppKit/" ${worksrcpath}/configure.ac
+            reinplace "/Sparkle.framework/d" \
+                ${worksrcpath}/extras/package/macosx/vlc.xcodeproj/project.pbxproj
+            reinplace "/SDKROOT/d" \
+                ${worksrcpath}/extras/package/macosx/vlc.xcodeproj/project.pbxproj
+            reinplace "/Growl.framework/d" \
+                ${worksrcpath}/extras/package/macosx/package.mak
 
-    configure.args-replace  --disable-macosx-eyetv --enable-macosx-eyetv
+            reinplace "s:LD_LIBRARY_PATH:DYLD_LIBRARY_PATH:g" \
+                ${worksrcpath}/Makefile.am
 
-    if {${subport} ne "lib${name}"} {
-        configure.args-replace  --disable-macosx-vlc-app --enable-macosx-vlc-app
-    }
+            reinplace "/argv/s/environ/*_NSGetEnviron()/" \
+                ${worksrcpath}/modules/misc/inhibit/xdg.c \
+                ${worksrcpath}/modules/stream_filter/decomp.c
 
-    post-patch {
-        reinplace "s/Appkit/AppKit/" ${worksrcpath}/configure.ac
-        reinplace "/Sparkle.framework/d" \
-            ${worksrcpath}/extras/package/macosx/vlc.xcodeproj/project.pbxproj
-        reinplace "/SDKROOT/d" \
-            ${worksrcpath}/extras/package/macosx/vlc.xcodeproj/project.pbxproj
-        reinplace "/Growl.framework/d" \
-            ${worksrcpath}/extras/package/macosx/package.mak
+            reinplace "s/extern char \\*\\*environ;/#include <crt_externs.h>/" \
+                ${worksrcpath}/modules/misc/inhibit/xdg.c \
+                ${worksrcpath}/modules/stream_filter/decomp.c
 
-        reinplace "s:LD_LIBRARY_PATH:DYLD_LIBRARY_PATH:g" \
-            ${worksrcpath}/Makefile.am
+            if {![file exists ${worksrcpath}/contrib/BGHUDAppKit.framework]} {
+                ln -s ${frameworks_dir}/BGHUDAppKit.framework ${worksrcpath}/contrib/BGHUDAppKit.framework
+            }
 
-        reinplace "/argv/s/environ/*_NSGetEnviron()/" \
-            ${worksrcpath}/modules/misc/inhibit/xdg.c \
-            ${worksrcpath}/modules/stream_filter/decomp.c
-
-        reinplace "s/extern char \\*\\*environ;/#include <crt_externs.h>/" \
-            ${worksrcpath}/modules/misc/inhibit/xdg.c \
-            ${worksrcpath}/modules/stream_filter/decomp.c
-
-        if {![file exists ${worksrcpath}/contrib/BGHUDAppKit.framework]} {
-            ln -s ${frameworks_dir}/BGHUDAppKit.framework ${worksrcpath}/contrib/BGHUDAppKit.framework
+            # To trick configure
+            file mkdir "${worksrcpath}/contrib/lib"
         }
 
-        # To trick configure
-        file mkdir "${worksrcpath}/contrib/lib"
-    }
+        post-destroot {
+            eval file delete [glob ${destroot}${prefix}/lib/vlc/plugins/*/*.la]
 
-    post-destroot {
-        eval file delete [glob ${destroot}${prefix}/lib/vlc/plugins/*/*.la]
+            if {[variant_isset qt4] || [variant_isset qt5] || [variant_isset quartz]} {
+                if {${subport} ne "lib${name}"} {
+                    copy ${worksrcpath}/VLC.app ${destroot}${applications_dir}/VLC.app
 
-        if {[variant_isset qt4] || [variant_isset qt5] || [variant_isset quartz]} {
-            if {${subport} ne "lib${name}"} {
-                copy ${worksrcpath}/VLC.app ${destroot}${applications_dir}/VLC.app
+                    # These are already in ${prefix}, so we don't need to bundle them as well
+                    delete ${destroot}${applications_dir}/VLC.app/Contents/Frameworks
+                    delete ${destroot}${applications_dir}/VLC.app/Contents/lib
 
-                # These are already in ${prefix}, so we don't need to bundle them as well
-                delete ${destroot}${applications_dir}/VLC.app/Contents/Frameworks
-                delete ${destroot}${applications_dir}/VLC.app/Contents/lib
+                    # There's no need to install these into the bundle and the prefix
+                    delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/include
+                    delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/lib
+                    delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/plugins
+                    delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/locale
+                    delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/lua
 
-                # There's no need to install these into the bundle and the prefix
-                delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/include
-                delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/lib
-                delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/plugins
-                delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/locale
-                delete ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/lua
+                    # http://trac.macports.org/ticket/35131
+                    ln -s ${prefix}/lib ${destroot}${applications_dir}/VLC.app/Contents/MacOS/lib
+                    ln -s ${prefix}/lib/vlc/plugins ${destroot}${applications_dir}/VLC.app/Contents/MacOS/plugins
+                    ln -s ${prefix}/lib/vlc/lua ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/lua
+                    ln -s ${prefix}/share/locale ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/locale
 
-                # http://trac.macports.org/ticket/35131
-                ln -s ${prefix}/lib ${destroot}${applications_dir}/VLC.app/Contents/MacOS/lib
-                ln -s ${prefix}/lib/vlc/plugins ${destroot}${applications_dir}/VLC.app/Contents/MacOS/plugins
-                ln -s ${prefix}/lib/vlc/lua ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/lua
-                ln -s ${prefix}/share/locale ${destroot}${applications_dir}/VLC.app/Contents/MacOS/share/locale
-
-                # the vlc executable needs to be started with a full path to the app bundle executable
-                # or else the Mac OS X interface will hang beyond even a ^C or ^\ :
-                move ${destroot}${prefix}/bin/vlc ${destroot}${prefix}/bin/vlc.exe
-                system "echo \"#!/bin/sh\nexec \\\"${applications_dir}/VLC.app/Contents/MacOS/VLC\\\" \\\"\\\$\@\\\"\" > ${destroot}${prefix}/bin/vlc"
-                system "chmod 755 ${destroot}${prefix}/bin/vlc"
-            } else {
-                delete ${destroot}${prefix}/bin
-                delete ${destroot}${prefix}/share/applications
-                delete ${destroot}${prefix}/share/man
+                    # the vlc executable needs to be started with a full path to the app bundle executable
+                    # or else the Mac OS X interface will hang beyond even a ^C or ^\ :
+                    move ${destroot}${prefix}/bin/vlc ${destroot}${prefix}/bin/vlc.exe
+                    system "echo \"#!/bin/sh\nexec \\\"${applications_dir}/VLC.app/Contents/MacOS/VLC\\\" \\\"\\\$\@\\\"\" > ${destroot}${prefix}/bin/vlc"
+                    system "chmod 755 ${destroot}${prefix}/bin/vlc"
+                } else {
+                    delete ${destroot}${prefix}/bin
+                    delete ${destroot}${prefix}/share/applications
+                    delete ${destroot}${prefix}/share/man
+                }
             }
         }
-    }
-    post-activate {
-        if {[variant_isset qt4] || [variant_isset qt5]} {
-            notes-append "The Qt interface modules for VLC are currently dysfunctional. If you encounter bugs with them, please file them with VLC and not MacPorts."
+        post-activate {
+            if {[variant_isset qt4] || [variant_isset qt5]} {
+                notes-append "The Qt interface modules for VLC are currently dysfunctional. If you encounter bugs with them, please file them with VLC and not MacPorts."
+            }
+            system "${prefix}/lib/vlc/vlc-cache-gen -f ${prefix}/lib/vlc"
         }
-        system "${prefix}/lib/vlc/vlc-cache-gen -f ${prefix}/lib/vlc"
     }
 }
 
+##
+#################  support port ffmpeg-VLC  ##################
+##
+if {${subport} eq "ffmpeg-VLC"} {
+	version             2.8.6
+	revision            1
+	license             LGPL-2.1+
+	categories          multimedia
+	maintainers         gmail.com:rjvbertin openmaintainer
+
+	description         Custom FFMpeg build for port:VLC and port:libVLC.
+	long_description    Custom FFMpeg build for port:VLC and port:libVLC.
+
+	platforms           darwin
+	homepage            http://www.ffmpeg.org/
+	master_sites        http://www.ffmpeg.org/releases/
+
+	use_bzip2           yes
+	distname            ffmpeg-${version}
+
+	checksums           rmd160  5b61b6b0521d39ca31dcfb7fff1dfa26d9e7667a \
+					sha256  40611e329bc354592c6f8f1deb033c31b91f80e91f5707ca4f9afceca78d8e62
+
+	depends_build       port:pkgconfig \
+					port:gmake
+
+# libvpx is static only so can be considered a build dependency (#47934)
+
+	depends_build-append \
+					port:libvpx
+
+	depends_lib         port:lame \
+					port:libiconv \
+					port:openjpeg15 \
+					port:xz \
+					port:zlib
+
+# depends_lib-append  port:libvorbis \
+#                     port:libopus \
+#                     port:libogg \
+#                     port:libtheora \
+#                     port:libass \
+#                     port:gnutls \
+#                     port:fontconfig \
+#                     port:freetype \
+#                     port:bzip2
+
+	build.cmd           ${prefix}/bin/gmake
+	build.env-append    V=1
+
+#
+# enable auto configure of asm optimizations
+# requires Xcode 3.1 or better on Leopard
+#
+	minimum_xcodeversions {9 3.1}
+
+	if {[lsearch [get_canonical_archs] i386] != -1} {
+	    # clang-3.1 hits https://trac.macports.org/ticket/30137 (<rdar://problem/11542429>)
+	    # clang-139 hits https://trac.macports.org/ticket/38141
+	    compiler.blacklist-append {clang < 422.1.7}
+	}
+
+	configure.cflags-append -DHAVE_LRINTF ${configure.cppflags}
+	configure.args      --prefix=${FFMPEG_VLC_PREFIX} \
+					--progs-suffix=-VLC \
+					--build-suffix=-VLC \
+					--disable-doc \
+					--disable-encoder=vorbis \
+					--enable-libopenjpeg \
+					--disable-debug \
+					--disable-avdevice \
+					--disable-devices \
+					--disable-avfilter \
+					--disable-filters \
+					--disable-protocol=concat \
+					--disable-bsfs \
+					--disable-bzlib \
+					--enable-avresample \
+					--enable-libmp3lame \
+					--enable-libvpx \
+					--disable-libbluray \
+					--disable-sdl \
+					--disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape \
+					--enable-shared --disable-static --enable-pthreads \
+					--cc=${configure.cc}
+
+# this is the old gpl2 variant. VLC is GPL2'ed, so we can just as well build ffmpeg
+# with these components.
+	configure.args-append \
+					--enable-gpl \
+					--enable-postproc
+# configure.args-append \
+#                     --enable-libx264 \
+#                     --enable-libxvid
+# depends_lib-append  port:XviD \
+#                     port:x264
+
+	configure.args-append \
+					--arch=${configure.build_arch}
+	configure.env-append \
+					ASFLAGS='[get_canonical_archflags]'
+	if {${build_arch} eq "x86_64"} {
+	    depends_build-append \
+					port:yasm
+	    configure.args-append \
+					--enable-yasm
+	}
+
+	license             GPL-2+
+
+	platform darwin {
+	    if {${os.major} < 9} {
+		   configure.args-append --disable-asm
+	    }
+
+	    # VDA (video hardware acceleration, mostly H264) is only supported on 10.6.3+ up to (excluding) 10.11.
+	    #if {(${os.major} > 10 || (${os.major} == 10 && ${os.minor} >= 3)) && (${os.major} < 15)}
+	    # Due to a bug in ffmpeg(?), we have to enable VDA on 10.11 as well, even though it shouldn't be supported.
+	    # More information: https://github.com/mpv-player/mpv/issues/2299
+	    if {${os.major} > 10 || (${os.major} == 10 && ${os.minor} >= 3)} {
+		   configure.args-delete --disable-vda
+		   configure.args-append --enable-vda
+	    }
+
+	    # VideotoolBox, a new hardware acceleration framework, is supported on 10.8+ and "here to stay".
+	    # It provides support for H264, H263, MPEG1, MPEG2 and MPEG4.
+	    if {${os.major} > 11} {
+		   configure.args-delete --disable-videotoolbox
+		   configure.args-append --enable-videotoolbox
+	    }
+
+	    # Apple GCC has problems with SIMD intrinsics and -Werror=no-missing-prototypes.
+	    if {${os.major} < 11} {
+		   patchfiles-append patch-configure-no-error-on-missing-prototypes.diff
+	    }
+
+	    # kCVPixelFormatType_OneComponent8 used in avfoundation indev is only available on 10.8+
+	    if {${os.major} < 12} {
+		   configure.args-append --disable-indev=avfoundation
+	    }
+	}
+
+#
+# configure isn't autoconf and they do use a dep cache
+#
+
+	platform darwin 8 {
+	    post-patch {
+		   reinplace "s:,-compatibility_version,$\(LIBMAJOR\)::" ${worksrcpath}/configure
+	    }
+	}
+
+	destroot.target     install-libs install-headers
+
+	post-destroot {
+	    file delete -force ${destroot}${prefix}/share/examples
+	    # We need to make sure that the linker will use our libraries and not one
+	    # from a location like ${prefix}/lib . That's why we use --build-suffix, but
+	    # that still requires us to provide pkg-config files with the standard names:
+	    foreach pc [glob ${destroot}${FFMPEG_VLC_PREFIX}/lib/pkgconfig/*.pc] {
+		   set standardname [strsed ${pc} "s/-VLC.pc/.pc/"]
+		   ln -s [file tail ${pc}] ${standardname}
+	    }
+	}
+
+	livecheck.type      regex
+	livecheck.url       ${master_sites}
+	livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
+}
+
 # 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;
Index: files/patch-static_assert.diff
===================================================================
--- files/patch-static_assert.diff	(nonexistent)
+++ files/patch-static_assert.diff	(working copy)
@@ -0,0 +1,11 @@
+--- config.h.orig    2016-03-22 15:34:33.000000000 +0000
++++ config.h 2016-03-22 15:34:57.000000000 +0000
+@@ -793,6 +793,7 @@
+ /* Define to `int' if <stddef.h> does not define. */
+ /* #undef ssize_t */
+
++#define static_assert _Static_assert
+ #include <vlc_fixups.h>
+
+
+
