--- /opt/local/var/macports/sources/svn.macports.org/trunk/dports/multimedia/VLC/Portfile	2015-05-04 17:53:07.000000000 +0200
+++ /opt/local/site-ports/multimedia/VLC/Portfile	2015-05-03 20:02:20.000000000 +0200
@@ -1,60 +1,123 @@
 # -*- 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
+# 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 133968 2015-03-16 09:49:19Z petr@macports.org $
 
 PortSystem          1.0
 PortGroup           compiler_blacklist_versions 1.0
 
 name                VLC
-version             2.1.5
-revision            4
-categories          multimedia
-
-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.
-license             GPL
+version             2.2.1
 
-platforms           darwin
-conflicts           VLC-devel
 
-homepage            http://www.videolan.org
+categories          multimedia devel
+
+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 \
+                        framework on which VLC media player is based.  It allows developers \
+                        to create a wide range of multimedia applications using the VLC features.
+    conflicts           ${name} VLC-devel libVLC-devel
+    homepage            http://www.videolan.org/vlc/libvlc.html
+}
+
+if {${subport} ne "lib${name}"} {
+    maintainers         nomaintainer
+    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.
+    conflicts           lib${name} libVLC-devel VLC-devel
+    homepage            http://www.videolan.org
+}
 
-# http://git.videolan.org/?p=vlc.git
-# http://git.videolan.org/?p=vlc.git;a=forks
-#fetch.type          git
-#git.url             git://git.videolan.org/vlc/vlc-2.1.git
-#git.url             git://git.videolan.org/vlc.git
-#git.branch          edd88358218f273fddde646a172a2104796d46c2
+license             GPL
+
+platforms           darwin
 
 master_sites        http://download.videolan.org/pub/videolan/vlc/${version}/
 distname            vlc-${version}
 use_xz              yes
 
-checksums           md5     3941b561f590cc95ca5e795213cba2f2 \
-                    sha1    7f1cb6324a04cf393896bbb5976ca9febd7b3efc \
-                    rmd160  4a18210f0f01ac8dfaf166926ab10eea6d97fbae
+checksums           rmd160  3b199e3555e8aa52a760a9ed7b89874c782e0dff \
+                    sha256  543d9d7e378ec0fa1ee2e7f7f5acf8c456c7d0ecc32037171523197ef3cf1fcb
+
+# Enable HFS compression.
+depends_extract-append      port:libarchive
+extract.post_args           "| bsdtar -x -k --hfsCompression"
 
 depends_build       port:pkgconfig
 
-depends_lib         \
+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:libxml2 \
+                    port:live555 \
+                    port:lua \
+                    port:ncurses \
+                    port:nettle \
+                    port:opencv \
                     port:openjpeg15 \
+                    port:openssl \
+                    port:orc \
+                    port:p11-kit \
+                    port:readline \
+                    port:schroedinger \
+                    port:speex \
                     port:taglib \
                     port:tiff \
-
-# TODO: live555 opencv FreeRDP
+                    port:twolame \
+                    port:vcdimager \
+                    port:x264
 
 # VLC-2.1 and later are x86_64-only: https://trac.videolan.org/vlc/ticket/8161
 universal_variant   no
@@ -72,11 +135,9 @@
 patchfiles          buildfix-package.mak.patch \
                     configure.ac-no-arch.patch \
                     PR-34741-no__clang_version__.patch \
-                    class_struct.patch \
-                    qtkit.patch \
                     static_assert.patch \
                     no-sparkle.patch \
-                    patch-ffmpeg-2.4.diff
+                    patch-vlc-no-O4.diff
 
 post-patch {
     reinplace "s:librsvg-2/librsvg:librsvg:" \
@@ -101,6 +162,9 @@
 # gl.c:121:3: error: Platform not recognized.
 configure.cppflags-append -D__unix__=1
 
+# live555 is installed to a weird location
+configure.cppflags-append -I${prefix}/lib/live/liveMedia/include
+
 build.target        all
 destroot.target     install
 
@@ -108,287 +172,111 @@
 livecheck.regex     <a href=\"(\\d\[\\d|\.|\\w\]+).*/\">
 
 # Other
-
-depends_lib-append  port:gnutls \
-                    port:lua
-
 configure.args-append \
                     --with-contrib=${worksrcpath}/contrib \
-                    --enable-shared \
-                    --disable-debug \
-                    --disable-update-check \
-                    --disable-dbus \
-                    --disable-growl \
-                    --disable-macosx-vlc-app \
-                    --disable-notify \
-                    --enable-gnutls \
-                    --enable-lua
+                    --disable-debug --disable-update-check --enable-gnutls \
+                    --disable-notify --disable-dbus --enable-lua \
+                    --disable-gnomevfs --disable-growl --disable-macosx-vlc-app
 
 # Input Plugins
-# build fails when FreeRDP is installed
-# build fails when opencv is installed
-
-depends_lib-append  \
-                    port:libbluray \
-                    port:libcddb \
-                    port:libdc1394 \
-                    port:libdvdnav \
-                    port:libdvdread \
-                    port:libssh2
-
 configure.args-append \
-                    --disable-decklink \
-                    --disable-dv1394 \
-                    --disable-gnomevfs \
-                    --disable-libfreerdp \
-                    --disable-libvnc \
-                    --disable-linsys \
-                    --disable-macosx-eyetv \
-                    --disable-macosx-qtkit \
-                    --disable-macosx-avfoundation \
-                    --disable-opencv \
-                    --disable-realrtsp \
-                    --disable-smbclient \
-                    --disable-v4l2 \
-                    --disable-vcdx \
-                    --enable-bluray \
-                    --enable-dc1394 \
-                    --enable-dvdnav \
-                    --enable-dvdread \
-                    --enable-libcddb \
-                    --enable-sftp \
-                    --enable-vcd
+                    --enable-dvdnav --enable-dvdread --disable-smbclient --enable-vcdx \
+                    --disable-macosx-qtkit --disable-macosx-eyetv --disable-realrtsp \
+                    --disable-freerdp --enable-opencv --enable-sftp
 
 # Mux/Demux Plugins
-depends_lib-append \
-                    port:libogg
-
 configure.args-append \
-                    --disable-dvbpsi \
-                    --disable-gme \
-                    --disable-mod \
-                    --disable-mpc \
-                    --disable-sid \
-                    --disable-shout \
-                    --enable-mkv \
-                    --enable-mux_ogg \
-                    --enable-ogg
+                    --enable-dvbpsi --enable-ogg --enable-mux_ogg \
+                    --enable-mkv --enable-mod --enable-mpc --disable-shout
 
 # Codec Plugins
-
-depends_lib-append  \
-                    port:a52dec \
-                    path:lib/libavcodec.dylib:ffmpeg \
-                    port:libdca \
-                    port:dirac \
-                    port:faad2 \
-                    port:flac \
-                    port:fluidsynth \
-                    port:libmad \
-                    port:libopus \
-                    port:libpng \
-                    port:schroedinger \
-                    port:libtheora \
-                    port:twolame \
-                    port:libvorbis \
-                    port:x264
-
-
 configure.args-append \
-                    --disable-crystalhd \
-                    --disable-dxva2 \
-                    --disable-fdkaac \
-                    --disable-kate \
-                    --disable-libass \
-                    --disable-libva \
-                    --disable-live555 \
-                    --disable-omxil \
-                    --disable-omxil-vout \
-                    --disable-quicksync \
-                    --disable-quicktime \
-                    --disable-rpi-omxil \
-                    --disable-speex \
-                    --disable-tiger \
-                    --disable-wma-fixed \
-                    --disable-shine \
-                    --disable-zvbi \
-                    --enable-a52 \
-                    --enable-avcodec \
-                    --enable-avformat \
-                    --enable-dca \
-                    --enable-dirac \
-                    --enable-faad \
-                    --enable-flac \
-                    --enable-fluidsynth \
-                    --enable-mad \
-                    --enable-opus \
-                    --enable-png \
-                    --enable-postproc \
-                    --enable-schroedinger \
-                    --enable-swscale \
-                    --enable-telx \
-                    --enable-theora \
-                    --enable-twolame \
-                    --enable-vorbis \
-                    --enable-x264
-
-# Video Plugins
+                    --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-postproc \
+                    --enable-avcodec --enable-avformat --enable-swscale \
+                    --disable-fluidsynth --enable-schroedinger
 
+# 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 \
-                    --without-x \
-                    --disable-aa \
-                    --disable-caca \
-                    --disable-egl \
-                    --disable-fontconfig \
-                    --disable-freetype \
-                    --disable-fribidi \
-                    --disable-gles1 \
-                    --disable-gles2 \
-                    --disable-glx \
-                    --disable-macosx-vout \
-                    --disable-sdl \
-                    --disable-sdl-image \
-                    --disable-svg \
-                    --disable-vdpau \
-                    --disable-xcb \
-                    --disable-xvideo
+                    --disable-caca --enable-sdl --enable-sdl-image \
+                    --without-x --disable-xcb --disable-xvideo --disable-glx \
+                    --x-includes=${destroot} --x-libraries=${destroot} \
+                    --enable-freetype --enable-fontconfig --enable-fribidi \
+                    --disable-svg
 
 # Audio Plugins
-depends_lib-append  \
-                    port:libsamplerate
-
 configure.args-append \
-                    --disable-chromaprint  \
-                    --disable-macosx-audio \
-                    --enable-samplerate \
-                    --disable-jack \
-                    --disable-pulse
+                    --disable-jack --enable-samplerate --disable-pulse
 
 # Interface Plugins
-depends_lib-append  \
-                    port:ncurses
-
 configure.args-append \
-                    --disable-macosx \
-                    --disable-macosx-dialog-provider \
-                    --disable-qt \
-                    --disable-skins2 \
-                    --enable-ncurses
+                    --disable-macosx --disable-macosx-dialog-provider \
+                    --disable-qt --enable-ncurses --disable-skins2
 
 # Visualisations and Video Filter Plugins
 configure.args-append \
-                    --disable-goom \
-                    --disable-projectm \
-                    --disable-vsxu
+                    --disable-goom
 
 # Service Discovery Plugins
-depends_lib-append  \
-                    port:avahi \
-                    port:libupnp
-
 configure.args-append \
-                    --disable-mtp \
-                    --disable-udev \
-                    --enable-bonjour \
-                    --enable-upnp
+                    --enable-bonjour --enable-upnp
+
+# 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 dbus description {Enable DBus support} {
     depends_lib-append      port:dbus
-    configure.args-delete   --disable-dbus
+    configure.args-delete   --disable-dbus 
     configure.args-append   --enable-dbus
 }
 
-variant pulse description {Enable PulseAudio support} {
-    depends_lib-append      port:pulseaudio
-    configure.args-delete   --disable-pulse
-    configure.args-append   --enable-pulse
-}
-
-variant eyetv description {Enable eyetv plugin} {
-    configure.args-delete --disable-macosx-eyetv
-    configure.args-append --enable-macosx-eyetv
-}
-
-variant dvb description {enable DVB Program Specific Information support} {
-    depends_lib-append      port:libdvbpsi
-    configure.args-delete   --disable-dvbpsi
-    configure.args-append   --enable-dvbpsi
-}
-
-variant fribidi requires osd description {Enable FriBidi Unicode support} {
-    depends_lib-append      port:fribidi
-    configure.args-delete   --disable-fribidi
-    configure.args-append   --enable-fribidi
-}
-
-variant jack description {Enable jack plugin for audio output} {
-    depends_lib-append      port:jack
-    configure.args-delete   --disable-jack
-    configure.args-append   --enable-jack
-}
-
-variant mod description {Enable MOD demuxer support} {
-    depends_lib-append      port:libmodplug
-    configure.args-delete   --disable-mod
-    configure.args-append   --enable-mod
-}
-
-variant mpc description {enable Musepack Decoder library support} {
-    depends_lib-append      port:libmpcdec
-    configure.args-delete   --disable-mpc
-    configure.args-append   --enable-mpc
-}
-
-variant osd description {Enable onscreen display and TrueType font support} {
-    depends_lib-append      port:fontconfig port:freetype
-    configure.args-delete   --disable-freetype --disable-fontconfig
-    configure.args-append   --enable-freetype --enable-fontconfig
-}
-
 variant qtkit description {Enable qtcapture and qtaudio} {
     configure.args-delete   --disable-macosx-qtkit
     configure.args-append   --enable-macosx-qtkit
 }
 
-variant sdl description {Enable SDL/SDL-Image support} {
-    depends_lib-append      port:libsdl port:libsdl_image
-    configure.args-delete   --disable-sdl
-    configure.args-append   --enable-sdl
+variant svg description {Enable SVG support} {
+    depends_lib-append      port:librsvg
+    configure.args-delete   --disable-svg
+    configure.args-append   --enable-svg
 }
 
-variant shout description {Enable Shoutcast support} {
+variant shout description {Enable Shoutcast/Icecast streaming output support} {
     depends_lib-append      port:libshout2
     configure.args-delete   --disable-shout
     configure.args-append   --enable-shout
 }
 
-variant smb description {Enable Samba 3 support} {
+variant smb description {Enable Samba 3 input support} {
     depends_lib-append      port:samba3
     configure.args-delete   --disable-smbclient
     configure.args-append   --enable-smbclient
     configure.ldflags-append    -L${prefix}/lib/samba3
 }
 
-variant speex description {Enable Speex decoder support} {
-    depends_lib-append      path:lib/libspeex.dylib:speex
-    configure.args-delete   --disable-speex
-    configure.args-append   --enable-speex
-}
-
-variant svg description {Enable SVG support} {
-    depends_lib-append      port:librsvg
-    configure.args-delete   --disable-svg
-    configure.args-append   --enable-svg
-}
-
-variant vcd description {Enable VCD support} {
-    depends_lib-append      port:vcdimager
-    configure.args-delete   --disable-vcdx
-    configure.args-append   --enable-vcdx
+variant pulse description {Enable PulseAudio support} {
+    depends_lib-append      port:pulseaudio
+    configure.args-delete   --disable-pulse 
+    configure.args-append   --enable-pulse 
 }
 
 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 \
@@ -396,71 +284,82 @@
         port:xorg-xcb-util \
         port:xorg-xcb-util-keysyms
 
-    configure.args-delete   --without-x \
-                            --disable-glx \
-                            --disable-xcb \
-                            --disable-xvideo
-    configure.args-append   --with-x \
-                            --x-include=${prefix}/include \
-                            --x-lib=${prefix}/lib \
-                            --enable-glx \
-                            --enable-xcb \
-                            --enable-xvideo
-}
-
-variant qt4 description {Build using QT4 UI. This will use qt4-mac} {
-    configure.args-delete   --disable-qt
-    configure.args-append   --enable-qt
-    patchfiles-append       patch-vlc-qt4mac.diff
+    configure.args-delete   --without-x --disable-xvideo --disable-glx --disable-xcb \
+                            --x-includes=${destroot} --x-libraries=${destroot}
+    configure.args-append   --with-x --enable-xvideo --enable-xcb
+}
 
-    PortGroup qt4 1.0
+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
 
-    post-activate {
-        if {![variant_isset quartz]} {
-            ui_info "The qt4 interface module for VLC is not very stable.  If you encounter bugs with it, please file them with VLC and not MacPorts."
-        }
+        configure.args-delete   --disable-qt
+        configure.args-append   --enable-qt
+
+        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-delete   --disable-qt
+        configure.args-append   --enable-qt
+
+        PortGroup               qt5 1.0
     }
 }
 
 variant quartz {
-    patchfiles-append       patch-vlc-for-macports.diff
-
-    depends_lib-append      port:BGHUDAppKit
     depends_lib-delete      port:libsamplerate
+    depends_lib-append      port:BGHUDAppKit
+
+    patchfiles-append       patch-vlc-for-macports.diff \
+                            patch-ignore-libGL.diff
+
     configure.args-delete   --disable-macosx \
-                            --disable-macosx-avfoundation \
-                            --enable-samplerate
-                            
-    configure.args-append   --enable-macosx \
-                            --enable-macosx-avfoundation
+                            --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 \
-                            --enable-libass
+                            --enable-realrtsp
 }
 
-default_variants +mod +mpc +osd +quartz
+# 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-delete --disable-freerdp
+    configure.args-append --enable-freerdp
+}
 
 variant huge \
-    requires dvb eyetv fribidi jack mod mpc osd sdl shout speex svg vcd pulse \
-        description {Enable all variants except quartz, qt4, smb, and x11} {}
+    requires jack shout svg vcd \
+    description {Enable all variants except quartz, smb, freerdp and x11} {}
 
-variant full \
-    requires huge qt4 quartz smb x11 \
-        description {Enable all variants} {}
+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)} {}
+}
 
 platform macosx {
-    default_variants-append +qtkit
+    default_variants-append +quartz +qtkit
 
     configure.args-delete \
-        --disable-macosx-vout --disable-macosx-audio \
+        --disable-macosx-eyetv
 
     configure.args-append \
-        --enable-macosx-vout --enable-macosx-audio \
-        --with-macosx-sdk=/
+        --enable-macosx-eyetv
 
-    if {[variant_isset qt4] || [variant_isset quartz]} {
+    if {${subport} ne "lib${name}"} {
         configure.args-delete --disable-macosx-vlc-app
         configure.args-append --enable-macosx-vlc-app
     }
@@ -494,30 +393,39 @@
     post-destroot {
         eval file delete [glob ${destroot}${prefix}/lib/vlc/plugins/*/*.la]
 
-        if {[variant_isset qt4] || [variant_isset quartz]} {
-            file rename ${worksrcpath}/VLC.app ${destroot}${applications_dir}/VLC.app
-
-            # These are already in ${prefix}, so we don't need to bundle them as well
-            file delete -force ${destroot}${applications_dir}/VLC.app/Contents/Frameworks
-            file delete -force ${destroot}${applications_dir}/VLC.app/Contents/lib
-
-            # There's no need to install these into the bundle and the prefix
-            file delete -force ${destroot}${applications_dir}/VLC.app/Contents/MacOS/include
-            file delete -force ${destroot}${applications_dir}/VLC.app/Contents/MacOS/lib
-            file delete -force ${destroot}${applications_dir}/VLC.app/Contents/MacOS/plugins
-
-            # 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
-            # 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 ^\ :
-            file delete ${destroot}${prefix}/bin/vlc
-            set vlc [open "${workpath}/vlc" "w"]
-            puts ${vlc} "#!/bin/sh"
-            puts ${vlc} ""
-            puts ${vlc} "exec ${applications_dir}/VLC.app/Contents/MacOS/VLC \"$@\""
-            close ${vlc}
-            xinstall -m 755 ${workpath}/vlc ${destroot}${prefix}/bin
+        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
+
+                # 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
+
+                # 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
+
+                # 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
+                xinstall -m 755 ${filespath}/vlc ${destroot}${prefix}/bin
+                reinplace "s|@APPLICATIONS_DIR@|${applications_dir}|g" ${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."
         }
+        system "${prefix}/lib/vlc/vlc-cache-gen -f ${prefix}/lib/vlc"
     }
 }
